diff options
Diffstat (limited to 'src/google')
152 files changed, 9438 insertions, 5232 deletions
diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index 80e96528..fa9d18a2 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -44,20 +44,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto() { Any_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Any_descriptor_, - Any::default_instance_, + Any::internal_default_instance(), Any_offsets_, -1, -1, -1, sizeof(Any), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _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_2fany_2eproto); } @@ -66,37 +65,49 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Any_descriptor_, &Any::default_instance()); + Any_descriptor_, Any::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto() { - delete Any::default_instance_; delete Any_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::internal::GetEmptyString(); + Any::default_instance_.DefaultConstruct(); + Any::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\031google/protobuf/any.proto\022\017google.prot" "obuf\"&\n\003Any\022\020\n\010type_url\030\001 \001(\t\022\r\n\005value\030\002" - " \001(\014Br\n\023com.google.protobufB\010AnyProtoP\001Z" - "%github.com/golang/protobuf/ptypes/any\240\001" - "\001\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypes" - "b\006proto3", 208); + " \001(\014Bo\n\023com.google.protobufB\010AnyProtoP\001Z" + "%github.com/golang/protobuf/ptypes/any\242\002" + "\003GPB\252\002\036Google.Protobuf.WellKnownTypesb\006p" + "roto3", 205); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/any.proto", &protobuf_RegisterTypes); - Any::default_instance_ = new Any(); - Any::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto() { @@ -104,6 +115,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fany_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 + + // =================================================================== void Any::PackFrom(const ::google::protobuf::Message& message) { @@ -126,12 +147,12 @@ const int Any::kValueFieldNumber; Any::Any() : ::google::protobuf::Message(), _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Any) } void Any::InitAsDefaultInstance() { - _is_default_instance_ = true; } Any::Any(const Any& from) @@ -139,16 +160,14 @@ Any::Any(const Any& from) _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Any) } void Any::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + _cached_size_ = 0; } Any::~Any() { @@ -159,8 +178,6 @@ Any::~Any() { void Any::SharedDtor() { type_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void Any::SetCachedSize(int size) const { @@ -174,11 +191,11 @@ const ::google::protobuf::Descriptor* Any::descriptor() { } const Any& Any::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); + return *internal_default_instance(); } -Any* Any::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<Any> Any::default_instance_; Any* Any::New(::google::protobuf::Arena* arena) const { Any* n = new Any; @@ -302,9 +319,9 @@ void Any::SerializeWithCachedSizes( return target; } -int Any::ByteSize() const { +size_t Any::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Any) - int total_size = 0; + size_t total_size = 0; // optional string type_url = 1; if (this->type_url().size() > 0) { @@ -320,18 +337,17 @@ int Any::ByteSize() const { this->value()); } + 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 Any::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Any) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Any* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Any* source = ::google::protobuf::internal::DynamicCastToGenerated<const Any>( &from); if (source == NULL) { @@ -339,15 +355,21 @@ void Any::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Any) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Any::MergeFrom(const Any& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Any::UnsafeMergeFrom(const Any& from) { + GOOGLE_DCHECK(&from != this); if (from.type_url().size() > 0) { type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_); @@ -369,7 +391,7 @@ void Any::CopyFrom(const Any& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Any) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Any::IsInitialized() const { @@ -403,37 +425,37 @@ void Any::InternalSwap(Any* other) { void Any::clear_type_url() { type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Any::type_url() const { +const ::std::string& Any::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.type_url) return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Any::set_type_url(const ::std::string& value) { +void Any::set_type_url(const ::std::string& value) { type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url) } - void Any::set_type_url(const char* value) { +void Any::set_type_url(const char* value) { type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Any.type_url) } - void Any::set_type_url(const char* value, size_t size) { +void Any::set_type_url(const char* value, size_t size) { type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.type_url) } - ::std::string* Any::mutable_type_url() { +::std::string* Any::mutable_type_url() { // @@protoc_insertion_point(field_mutable:google.protobuf.Any.type_url) return type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Any::release_type_url() { +::std::string* Any::release_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Any.type_url) return type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Any::set_allocated_type_url(::std::string* type_url) { +void Any::set_allocated_type_url(::std::string* type_url) { if (type_url != NULL) { } else { @@ -447,37 +469,37 @@ void Any::clear_type_url() { void Any::clear_value() { value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Any::value() const { +const ::std::string& Any::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.value) return value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Any::set_value(const ::std::string& value) { +void Any::set_value(const ::std::string& value) { value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Any.value) } - void Any::set_value(const char* value) { +void Any::set_value(const char* value) { value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Any.value) } - void Any::set_value(const void* value, size_t size) { +void Any::set_value(const void* value, size_t size) { value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.value) } - ::std::string* Any::mutable_value() { +::std::string* Any::mutable_value() { // @@protoc_insertion_point(field_mutable:google.protobuf.Any.value) return value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Any::release_value() { +::std::string* Any::release_value() { // @@protoc_insertion_point(field_release:google.protobuf.Any.value) return value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Any::set_allocated_value(::std::string* value) { +void Any::set_allocated_value(::std::string* value) { if (value != NULL) { } else { diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index d8cbee2d..853b3c95 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -35,6 +35,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto(); @@ -57,6 +58,10 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in static const ::google::protobuf::Descriptor* descriptor(); static const Any& default_instance(); + static inline const Any* internal_default_instance() { + return &default_instance_.get(); + } + // implements Any ----------------------------------------------- void PackFrom(const ::google::protobuf::Message& message); @@ -81,7 +86,7 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -97,6 +102,7 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Any* other); + void UnsafeMergeFrom(const Any& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -138,17 +144,17 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; ::google::protobuf::internal::ArenaStringPtr type_url_; ::google::protobuf::internal::ArenaStringPtr value_; mutable int _cached_size_; ::google::protobuf::internal::AnyMetadata _any_metadata_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto(); void InitAsDefaultInstance(); - static Any* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Any> default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/any.proto b/src/google/protobuf/any.proto index 81dcf46c..9bd3f50a 100644 --- a/src/google/protobuf/any.proto +++ b/src/google/protobuf/any.proto @@ -37,7 +37,6 @@ option go_package = "github.com/golang/protobuf/ptypes/any"; option java_package = "com.google.protobuf"; option java_outer_classname = "AnyProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; // `Any` contains an arbitrary serialized protocol buffer message along with a diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index d7fb644c..bd85bbdb 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -55,14 +55,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() { Api_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Api_descriptor_, - Api::default_instance_, + Api::internal_default_instance(), Api_offsets_, -1, -1, -1, sizeof(Api), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_)); Method_descriptor_ = file->message_type(1); static const int Method_offsets_[7] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, name_), @@ -76,14 +75,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() { Method_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Method_descriptor_, - Method::default_instance_, + Method::internal_default_instance(), Method_offsets_, -1, -1, -1, sizeof(Method), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_)); Mixin_descriptor_ = file->message_type(2); static const int Mixin_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, name_), @@ -92,20 +90,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() { Mixin_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Mixin_descriptor_, - Mixin::default_instance_, + Mixin::internal_default_instance(), Mixin_offsets_, -1, -1, -1, sizeof(Mixin), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _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_2fapi_2eproto); } @@ -114,33 +111,46 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Api_descriptor_, &Api::default_instance()); + Api_descriptor_, Api::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Method_descriptor_, &Method::default_instance()); + Method_descriptor_, Method::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Mixin_descriptor_, &Mixin::default_instance()); + Mixin_descriptor_, Mixin::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto() { - delete Api::default_instance_; delete Api_reflection_; - delete Method::default_instance_; delete Method_reflection_; - delete Mixin::default_instance_; delete Mixin_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); + ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); + ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + ::google::protobuf::internal::GetEmptyString(); + Api::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + Method::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + Mixin::default_instance_.DefaultConstruct(); + Api::default_instance_.get_mutable()->InitAsDefaultInstance(); + Method::default_instance_.get_mutable()->InitAsDefaultInstance(); + Mixin::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\031google/protobuf/api.proto\022\017google.prot" "obuf\032$google/protobuf/source_context.pro" @@ -157,20 +167,21 @@ void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() { "esponse_streaming\030\005 \001(\010\022(\n\007options\030\006 \003(\013" "2\027.google.protobuf.Option\022\'\n\006syntax\030\007 \001(" "\0162\027.google.protobuf.Syntax\"#\n\005Mixin\022\014\n\004n" - "ame\030\001 \001(\t\022\014\n\004root\030\002 \001(\tBK\n\023com.google.pr" - "otobufB\010ApiProtoP\001\240\001\001\242\002\003GPB\252\002\036Google.Pro" - "tobuf.WellKnownTypesb\006proto3", 708); + "ame\030\001 \001(\t\022\014\n\004root\030\002 \001(\tBH\n\023com.google.pr" + "otobufB\010ApiProtoP\001\242\002\003GPB\252\002\036Google.Protob" + "uf.WellKnownTypesb\006proto3", 705); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/api.proto", &protobuf_RegisterTypes); - Api::default_instance_ = new Api(); - Method::default_instance_ = new Method(); - Mixin::default_instance_ = new Mixin(); - Api::default_instance_->InitAsDefaultInstance(); - Method::default_instance_->InitAsDefaultInstance(); - Mixin::default_instance_->InitAsDefaultInstance(); + ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); + ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto() { @@ -178,6 +189,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fapi_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 @@ -192,31 +213,30 @@ const int Api::kSyntaxFieldNumber; Api::Api() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Api) } void Api::InitAsDefaultInstance() { - _is_default_instance_ = true; - source_context_ = const_cast< ::google::protobuf::SourceContext*>(&::google::protobuf::SourceContext::default_instance()); + source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); } Api::Api(const Api& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Api) } void Api::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); version_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); source_context_ = NULL; syntax_ = 0; + _cached_size_ = 0; } Api::~Api() { @@ -227,9 +247,7 @@ Api::~Api() { void Api::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); version_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete source_context_; - } + delete source_context_; } void Api::SetCachedSize(int size) const { @@ -243,11 +261,11 @@ const ::google::protobuf::Descriptor* Api::descriptor() { } const Api& Api::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + return *internal_default_instance(); } -Api* Api::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<Api> Api::default_instance_; Api* Api::New(::google::protobuf::Arena* arena) const { Api* n = new Api; @@ -532,9 +550,9 @@ void Api::SerializeWithCachedSizes( return target; } -int Api::ByteSize() const { +size_t Api::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Api) - int total_size = 0; + size_t total_size = 0; // optional string name = 1; if (this->name().size() > 0) { @@ -564,41 +582,49 @@ int Api::ByteSize() const { } // repeated .google.protobuf.Method methods = 2; - total_size += 1 * this->methods_size(); - for (int i = 0; i < this->methods_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->methods(i)); + { + unsigned int count = this->methods_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->methods(i)); + } } // repeated .google.protobuf.Option options = 3; - total_size += 1 * this->options_size(); - for (int i = 0; i < this->options_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(i)); + } } // repeated .google.protobuf.Mixin mixins = 6; - total_size += 1 * this->mixins_size(); - for (int i = 0; i < this->mixins_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->mixins(i)); + { + unsigned int count = this->mixins_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->mixins(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 Api::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Api) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Api* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Api* source = ::google::protobuf::internal::DynamicCastToGenerated<const Api>( &from); if (source == NULL) { @@ -606,15 +632,21 @@ void Api::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Api) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Api::MergeFrom(const Api& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Api) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Api::UnsafeMergeFrom(const Api& from) { + GOOGLE_DCHECK(&from != this); methods_.MergeFrom(from.methods_); options_.MergeFrom(from.options_); mixins_.MergeFrom(from.mixins_); @@ -645,7 +677,7 @@ void Api::CopyFrom(const Api& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Api) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Api::IsInitialized() const { @@ -684,37 +716,37 @@ void Api::InternalSwap(Api* other) { void Api::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Api::name() const { +const ::std::string& Api::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Api::set_name(const ::std::string& value) { +void Api::set_name(const ::std::string& value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Api.name) } - void Api::set_name(const char* value) { +void Api::set_name(const char* value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Api.name) } - void Api::set_name(const char* value, size_t size) { +void Api::set_name(const char* value, size_t size) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.name) } - ::std::string* Api::mutable_name() { +::std::string* Api::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Api.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Api::release_name() { +::std::string* Api::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Api.name) return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Api::set_allocated_name(::std::string* name) { +void Api::set_allocated_name(::std::string* name) { if (name != NULL) { } else { @@ -788,37 +820,37 @@ Api::options() const { void Api::clear_version() { version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Api::version() const { +const ::std::string& Api::version() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.version) return version_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Api::set_version(const ::std::string& value) { +void Api::set_version(const ::std::string& value) { version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Api.version) } - void Api::set_version(const char* value) { +void Api::set_version(const char* value) { version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Api.version) } - void Api::set_version(const char* value, size_t size) { +void Api::set_version(const char* value, size_t size) { version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.version) } - ::std::string* Api::mutable_version() { +::std::string* Api::mutable_version() { // @@protoc_insertion_point(field_mutable:google.protobuf.Api.version) return version_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Api::release_version() { +::std::string* Api::release_version() { // @@protoc_insertion_point(field_release:google.protobuf.Api.version) return version_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Api::set_allocated_version(::std::string* version) { +void Api::set_allocated_version(::std::string* version) { if (version != NULL) { } else { @@ -830,7 +862,7 @@ void Api::clear_version() { // optional .google.protobuf.SourceContext source_context = 5; bool Api::has_source_context() const { - return !_is_default_instance_ && source_context_ != NULL; + return this != internal_default_instance() && source_context_ != NULL; } void Api::clear_source_context() { if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; @@ -838,7 +870,8 @@ void Api::clear_source_context() { } const ::google::protobuf::SourceContext& Api::source_context() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.source_context) - return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_; + return source_context_ != NULL ? *source_context_ + : *::google::protobuf::SourceContext::internal_default_instance(); } ::google::protobuf::SourceContext* Api::mutable_source_context() { @@ -900,11 +933,11 @@ Api::mixins() const { void Api::clear_syntax() { syntax_ = 0; } - ::google::protobuf::Syntax Api::syntax() const { +::google::protobuf::Syntax Api::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.syntax) return static_cast< ::google::protobuf::Syntax >(syntax_); } - void Api::set_syntax(::google::protobuf::Syntax value) { +void Api::set_syntax(::google::protobuf::Syntax value) { syntax_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Api.syntax) @@ -926,32 +959,29 @@ const int Method::kSyntaxFieldNumber; Method::Method() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Method) } void Method::InitAsDefaultInstance() { - _is_default_instance_ = true; } Method::Method(const Method& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Method) } void Method::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); request_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - request_streaming_ = false; response_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - response_streaming_ = false; - syntax_ = 0; + ::memset(&request_streaming_, 0, reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&request_streaming_) + sizeof(syntax_)); + _cached_size_ = 0; } Method::~Method() { @@ -963,8 +993,6 @@ void Method::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); request_type_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); response_type_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void Method::SetCachedSize(int size) const { @@ -978,11 +1006,11 @@ const ::google::protobuf::Descriptor* Method::descriptor() { } const Method& Method::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + return *internal_default_instance(); } -Method* Method::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<Method> Method::default_instance_; Method* Method::New(::google::protobuf::Arena* arena) const { Method* n = new Method; @@ -1068,10 +1096,10 @@ bool Method::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_request_streaming: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &request_streaming_))); - } else { goto handle_unusual; } @@ -1100,10 +1128,10 @@ bool Method::MergePartialFromCodedStream( case 5: { if (tag == 40) { parse_response_streaming: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &response_streaming_))); - } else { goto handle_unusual; } @@ -1287,9 +1315,9 @@ void Method::SerializeWithCachedSizes( return target; } -int Method::ByteSize() const { +size_t Method::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Method) - int total_size = 0; + size_t total_size = 0; // optional string name = 1; if (this->name().size() > 0) { @@ -1329,25 +1357,27 @@ int Method::ByteSize() const { } // repeated .google.protobuf.Option options = 6; - total_size += 1 * this->options_size(); - for (int i = 0; i < this->options_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(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 Method::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Method) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Method* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Method* source = ::google::protobuf::internal::DynamicCastToGenerated<const Method>( &from); if (source == NULL) { @@ -1355,15 +1385,21 @@ void Method::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Method) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Method::MergeFrom(const Method& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Method) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Method::UnsafeMergeFrom(const Method& from) { + GOOGLE_DCHECK(&from != this); options_.MergeFrom(from.options_); if (from.name().size() > 0) { @@ -1399,7 +1435,7 @@ void Method::CopyFrom(const Method& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Method) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Method::IsInitialized() const { @@ -1438,37 +1474,37 @@ void Method::InternalSwap(Method* other) { void Method::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Method::name() const { +const ::std::string& Method::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Method::set_name(const ::std::string& value) { +void Method::set_name(const ::std::string& value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Method.name) } - void Method::set_name(const char* value) { +void Method::set_name(const char* value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Method.name) } - void Method::set_name(const char* value, size_t size) { +void Method::set_name(const char* value, size_t size) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.name) } - ::std::string* Method::mutable_name() { +::std::string* Method::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Method.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Method::release_name() { +::std::string* Method::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Method.name) return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Method::set_allocated_name(::std::string* name) { +void Method::set_allocated_name(::std::string* name) { if (name != NULL) { } else { @@ -1482,37 +1518,37 @@ void Method::clear_name() { void Method::clear_request_type_url() { request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Method::request_type_url() const { +const ::std::string& Method::request_type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url) return request_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Method::set_request_type_url(const ::std::string& value) { +void Method::set_request_type_url(const ::std::string& value) { request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url) } - void Method::set_request_type_url(const char* value) { +void Method::set_request_type_url(const char* value) { request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Method.request_type_url) } - void Method::set_request_type_url(const char* value, size_t size) { +void Method::set_request_type_url(const char* value, size_t size) { request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.request_type_url) } - ::std::string* Method::mutable_request_type_url() { +::std::string* Method::mutable_request_type_url() { // @@protoc_insertion_point(field_mutable:google.protobuf.Method.request_type_url) return request_type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Method::release_request_type_url() { +::std::string* Method::release_request_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Method.request_type_url) return request_type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Method::set_allocated_request_type_url(::std::string* request_type_url) { +void Method::set_allocated_request_type_url(::std::string* request_type_url) { if (request_type_url != NULL) { } else { @@ -1526,11 +1562,11 @@ void Method::clear_request_type_url() { void Method::clear_request_streaming() { request_streaming_ = false; } - bool Method::request_streaming() const { +bool Method::request_streaming() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.request_streaming) return request_streaming_; } - void Method::set_request_streaming(bool value) { +void Method::set_request_streaming(bool value) { request_streaming_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming) @@ -1540,37 +1576,37 @@ void Method::clear_request_streaming() { void Method::clear_response_type_url() { response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Method::response_type_url() const { +const ::std::string& Method::response_type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url) return response_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Method::set_response_type_url(const ::std::string& value) { +void Method::set_response_type_url(const ::std::string& value) { response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url) } - void Method::set_response_type_url(const char* value) { +void Method::set_response_type_url(const char* value) { response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Method.response_type_url) } - void Method::set_response_type_url(const char* value, size_t size) { +void Method::set_response_type_url(const char* value, size_t size) { response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.response_type_url) } - ::std::string* Method::mutable_response_type_url() { +::std::string* Method::mutable_response_type_url() { // @@protoc_insertion_point(field_mutable:google.protobuf.Method.response_type_url) return response_type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Method::release_response_type_url() { +::std::string* Method::release_response_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Method.response_type_url) return response_type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Method::set_allocated_response_type_url(::std::string* response_type_url) { +void Method::set_allocated_response_type_url(::std::string* response_type_url) { if (response_type_url != NULL) { } else { @@ -1584,11 +1620,11 @@ void Method::clear_response_type_url() { void Method::clear_response_streaming() { response_streaming_ = false; } - bool Method::response_streaming() const { +bool Method::response_streaming() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.response_streaming) return response_streaming_; } - void Method::set_response_streaming(bool value) { +void Method::set_response_streaming(bool value) { response_streaming_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Method.response_streaming) @@ -1628,11 +1664,11 @@ Method::options() const { void Method::clear_syntax() { syntax_ = 0; } - ::google::protobuf::Syntax Method::syntax() const { +::google::protobuf::Syntax Method::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.syntax) return static_cast< ::google::protobuf::Syntax >(syntax_); } - void Method::set_syntax(::google::protobuf::Syntax value) { +void Method::set_syntax(::google::protobuf::Syntax value) { syntax_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Method.syntax) @@ -1649,28 +1685,26 @@ const int Mixin::kRootFieldNumber; Mixin::Mixin() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Mixin) } void Mixin::InitAsDefaultInstance() { - _is_default_instance_ = true; } Mixin::Mixin(const Mixin& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin) } void Mixin::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); root_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + _cached_size_ = 0; } Mixin::~Mixin() { @@ -1681,8 +1715,6 @@ Mixin::~Mixin() { void Mixin::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); root_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void Mixin::SetCachedSize(int size) const { @@ -1696,11 +1728,11 @@ const ::google::protobuf::Descriptor* Mixin::descriptor() { } const Mixin& Mixin::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + return *internal_default_instance(); } -Mixin* Mixin::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<Mixin> Mixin::default_instance_; Mixin* Mixin::New(::google::protobuf::Arena* arena) const { Mixin* n = new Mixin; @@ -1836,9 +1868,9 @@ void Mixin::SerializeWithCachedSizes( return target; } -int Mixin::ByteSize() const { +size_t Mixin::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Mixin) - int total_size = 0; + size_t total_size = 0; // optional string name = 1; if (this->name().size() > 0) { @@ -1854,18 +1886,17 @@ int Mixin::ByteSize() const { this->root()); } + 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 Mixin::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Mixin) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Mixin* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Mixin* source = ::google::protobuf::internal::DynamicCastToGenerated<const Mixin>( &from); if (source == NULL) { @@ -1873,15 +1904,21 @@ void Mixin::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Mixin) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Mixin::MergeFrom(const Mixin& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Mixin) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Mixin::UnsafeMergeFrom(const Mixin& from) { + GOOGLE_DCHECK(&from != this); if (from.name().size() > 0) { name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -1903,7 +1940,7 @@ void Mixin::CopyFrom(const Mixin& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Mixin) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Mixin::IsInitialized() const { @@ -1937,37 +1974,37 @@ void Mixin::InternalSwap(Mixin* other) { void Mixin::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Mixin::name() const { +const ::std::string& Mixin::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Mixin::set_name(const ::std::string& value) { +void Mixin::set_name(const ::std::string& value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name) } - void Mixin::set_name(const char* value) { +void Mixin::set_name(const char* value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.name) } - void Mixin::set_name(const char* value, size_t size) { +void Mixin::set_name(const char* value, size_t size) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.name) } - ::std::string* Mixin::mutable_name() { +::std::string* Mixin::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Mixin::release_name() { +::std::string* Mixin::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Mixin.name) return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Mixin::set_allocated_name(::std::string* name) { +void Mixin::set_allocated_name(::std::string* name) { if (name != NULL) { } else { @@ -1981,37 +2018,37 @@ void Mixin::clear_name() { void Mixin::clear_root() { root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Mixin::root() const { +const ::std::string& Mixin::root() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root) return root_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Mixin::set_root(const ::std::string& value) { +void Mixin::set_root(const ::std::string& value) { root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root) } - void Mixin::set_root(const char* value) { +void Mixin::set_root(const char* value) { root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.root) } - void Mixin::set_root(const char* value, size_t size) { +void Mixin::set_root(const char* value, size_t size) { root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.root) } - ::std::string* Mixin::mutable_root() { +::std::string* Mixin::mutable_root() { // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.root) return root_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Mixin::release_root() { +::std::string* Mixin::release_root() { // @@protoc_insertion_point(field_release:google.protobuf.Mixin.root) return root_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Mixin::set_allocated_root(::std::string* root) { +void Mixin::set_allocated_root(::std::string* root) { if (root != NULL) { } else { diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index c9ec923a..2036e516 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -36,6 +36,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); @@ -60,6 +61,10 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in static const ::google::protobuf::Descriptor* descriptor(); static const Api& default_instance(); + static inline const Api* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(Api* other); // implements Message ---------------------------------------------- @@ -74,7 +79,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -90,6 +95,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Api* other); + void UnsafeMergeFrom(const Api& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -182,21 +188,21 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; - ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method > methods_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin > mixins_; + ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr version_; ::google::protobuf::SourceContext* source_context_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin > mixins_; int syntax_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); void InitAsDefaultInstance(); - static Api* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Api> default_instance_; }; // ------------------------------------------------------------------- @@ -215,6 +221,10 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc static const ::google::protobuf::Descriptor* descriptor(); static const Method& default_instance(); + static inline const Method* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(Method* other); // implements Message ---------------------------------------------- @@ -229,7 +239,7 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -245,6 +255,7 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Method* other); + void UnsafeMergeFrom(const Method& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -327,21 +338,21 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr request_type_url_; ::google::protobuf::internal::ArenaStringPtr response_type_url_; bool request_streaming_; bool response_streaming_; int syntax_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); void InitAsDefaultInstance(); - static Method* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Method> default_instance_; }; // ------------------------------------------------------------------- @@ -360,6 +371,10 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ static const ::google::protobuf::Descriptor* descriptor(); static const Mixin& default_instance(); + static inline const Mixin* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(Mixin* other); // implements Message ---------------------------------------------- @@ -374,7 +389,7 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -390,6 +405,7 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Mixin* other); + void UnsafeMergeFrom(const Mixin& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -431,16 +447,16 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr root_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); void InitAsDefaultInstance(); - static Mixin* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Mixin> default_instance_; }; // =================================================================== @@ -600,7 +616,7 @@ inline void Api::set_allocated_version(::std::string* version) { // optional .google.protobuf.SourceContext source_context = 5; inline bool Api::has_source_context() const { - return !_is_default_instance_ && source_context_ != NULL; + return this != internal_default_instance() && source_context_ != NULL; } inline void Api::clear_source_context() { if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; @@ -608,7 +624,8 @@ inline void Api::clear_source_context() { } inline const ::google::protobuf::SourceContext& Api::source_context() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.source_context) - return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_; + return source_context_ != NULL ? *source_context_ + : *::google::protobuf::SourceContext::internal_default_instance(); } inline ::google::protobuf::SourceContext* Api::mutable_source_context() { diff --git a/src/google/protobuf/api.proto b/src/google/protobuf/api.proto index dbe87b8f..bbbe9833 100644 --- a/src/google/protobuf/api.proto +++ b/src/google/protobuf/api.proto @@ -39,7 +39,6 @@ option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option java_package = "com.google.protobuf"; option java_outer_classname = "ApiProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; // Api is a light-weight descriptor for a protocol buffer service. diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index 78e20946..aa4e587c 100755 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc @@ -30,6 +30,9 @@ #include <google/protobuf/arena.h> +#include <algorithm> +#include <limits> + #ifdef ADDRESS_SANITIZER #include <sanitizer/asan_interface.h> @@ -125,10 +128,9 @@ Arena::Block* Arena::NewBlock(void* me, Block* my_last_block, size_t n, } else { size = start_block_size; } - if (n > size - kHeaderSize) { - // TODO(sanjay): Check if n + kHeaderSize would overflow - size = kHeaderSize + n; - } + // Verify that n + kHeaderSize won't overflow. + GOOGLE_CHECK_LE(n, std::numeric_limits<size_t>::max() - kHeaderSize); + size = std::max(size, kHeaderSize + n); Block* b = reinterpret_cast<Block*>(options_.block_alloc(size)); b->pos = kHeaderSize + n; diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 0a5eacee..f05277ed 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -79,8 +79,12 @@ template<typename T> void arena_destruct_object(void* object) { template<typename T> void arena_delete_object(void* object) { delete reinterpret_cast<T*>(object); } -inline void arena_free(void* object, size_t /* size */) { - free(object); +inline void arena_free(void* object, size_t size) { +#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) + ::operator delete(object, size); +#else + ::operator delete(object); +#endif } } // namespace internal @@ -144,7 +148,7 @@ struct ArenaOptions { max_block_size(kDefaultMaxBlockSize), initial_block(NULL), initial_block_size(0), - block_alloc(&malloc), + block_alloc(&::operator new), block_dealloc(&internal::arena_free), on_arena_init(NULL), on_arena_reset(NULL), @@ -454,7 +458,7 @@ class LIBPROTOBUF_EXPORT Arena { // Combines SpaceAllocated and SpaceUsed. Returns a pair of // <space_allocated, space_used>. - GOOGLE_ATTRIBUTE_NOINLINE pair<uint64, uint64> SpaceAllocatedAndUsed() const; + GOOGLE_ATTRIBUTE_NOINLINE std::pair<uint64, uint64> SpaceAllocatedAndUsed() const; // Frees all storage allocated by this arena after calling destructors // registered with OwnDestructor() and freeing objects registered with Own(). @@ -608,6 +612,7 @@ class LIBPROTOBUF_EXPORT Arena { const T>(static_cast<const T*>(0))) == sizeof(char) || google::protobuf::internal::has_trivial_destructor<T>::value> {}; + private: // CreateMessage<T> requires that T supports arenas, but this private method // works whether or not T supports arenas. These are not exposed to user code // as it can cause confusing API usages, and end up having double free in diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc index 5f33e939..35d00463 100644 --- a/src/google/protobuf/arena_unittest.cc +++ b/src/google/protobuf/arena_unittest.cc @@ -151,8 +151,6 @@ class MustBeConstructedWithOneThroughEight { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MustBeConstructedWithOneThroughEight); }; -} // namespace - TEST(ArenaTest, ArenaConstructable) { EXPECT_TRUE(Arena::is_arena_constructable<TestAllTypes>::type::value); EXPECT_TRUE(Arena::is_arena_constructable<const TestAllTypes>::type::value); @@ -893,6 +891,24 @@ TEST(ArenaTest, UnsafeArenaRelease) { delete s; } +TEST(ArenaTest, OneofMerge) { + Arena arena; + TestAllTypes* message0 = Arena::CreateMessage<TestAllTypes>(&arena); + TestAllTypes* message1 = Arena::CreateMessage<TestAllTypes>(&arena); + + message0->unsafe_arena_set_allocated_oneof_string(new string("x")); + ASSERT_TRUE(message0->has_oneof_string()); + message1->unsafe_arena_set_allocated_oneof_string(new string("y")); + ASSERT_TRUE(message1->has_oneof_string()); + EXPECT_EQ("x", message0->oneof_string()); + EXPECT_EQ("y", message1->oneof_string()); + message0->MergeFrom(*message1); + EXPECT_EQ("y", message0->oneof_string()); + EXPECT_EQ("y", message1->oneof_string()); + delete message0->unsafe_arena_release_oneof_string(); + delete message1->unsafe_arena_release_oneof_string(); +} + TEST(ArenaTest, ArenaOneofReflection) { Arena arena; TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena); @@ -923,7 +939,6 @@ TEST(ArenaTest, ArenaOneofReflection) { delete submsg; } -namespace { void TestSwapRepeatedField(Arena* arena1, Arena* arena2) { // Test "safe" (copying) semantics for direct Swap() on RepeatedPtrField // between arenas. @@ -962,7 +977,6 @@ void TestSwapRepeatedField(Arena* arena1, Arena* arena2) { EXPECT_EQ(i, field2.Get(i).optional_int32()); } } -} // namespace TEST(ArenaTest, SwapRepeatedField) { Arena arena; @@ -1104,8 +1118,6 @@ TEST(ArenaTest, MutableMessageReflection) { #endif // !GOOGLE_PROTOBUF_NO_RTTI -namespace { - void FillArenaAwareFields(TestAllTypes* message) { string test_string = "hello world"; message->set_optional_int32(42); @@ -1124,8 +1136,6 @@ void FillArenaAwareFields(TestAllTypes* message) { message->mutable_optional_lazy_message()->set_bb(42); } -} - // Test: no allocations occur on heap while touching all supported field types. TEST(ArenaTest, NoHeapAllocationsTest) { // Allocate a large initial block to avoid mallocs during hooked test. @@ -1196,9 +1206,7 @@ TEST(ArenaTest, RepeatedFieldWithNonPODType) { } // Align n to next multiple of 8 -namespace { uint64 Align8(uint64 n) { return (n + 7) & -8; } -} // namespace TEST(ArenaTest, SpaceAllocated_and_Used) { ArenaOptions options; @@ -1249,6 +1257,22 @@ TEST(ArenaTest, Alignment) { } } +TEST(ArenaTest, BlockSizeSmallerThanAllocation) { + for (size_t i = 0; i <= 8; ++i) { + ::google::protobuf::ArenaOptions opt; + opt.start_block_size = opt.max_block_size = i; + ::google::protobuf::Arena arena(opt); + + *::google::protobuf::Arena::Create<int64>(&arena) = 42; + EXPECT_GE(arena.SpaceAllocated(), 8); + EXPECT_EQ(8, arena.SpaceUsed()); + + *::google::protobuf::Arena::Create<int64>(&arena) = 42; + EXPECT_GE(arena.SpaceAllocated(), 16); + EXPECT_EQ(16, arena.SpaceUsed()); + } +} + TEST(ArenaTest, GetArenaShouldReturnTheArenaForArenaAllocatedMessages) { ::google::protobuf::Arena arena; ArenaMessage* message = Arena::CreateMessage<ArenaMessage>(&arena); @@ -1349,5 +1373,7 @@ TEST(ArenaTest, ArenaHooksSanity) { EXPECT_EQ(1, ArenaHooksTestUtil::num_destruct); } + +} // namespace } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/compiler/code_generator.cc b/src/google/protobuf/compiler/code_generator.cc index 473eb4e6..f6ff1e5d 100644 --- a/src/google/protobuf/compiler/code_generator.cc +++ b/src/google/protobuf/compiler/code_generator.cc @@ -36,6 +36,7 @@ #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> +#include <google/protobuf/descriptor.h> #include <google/protobuf/stubs/strutil.h> namespace google { @@ -43,6 +44,33 @@ namespace protobuf { namespace compiler { CodeGenerator::~CodeGenerator() {} + +bool CodeGenerator::GenerateAll( + const vector<const FileDescriptor*>& files, + const string& parameter, + GeneratorContext* generator_context, + string* error) const { + // Default implemenation is just to call the per file method, and prefix any + // error string with the file to provide context. + bool succeeded = true; + for (int i = 0; i < files.size(); i++) { + const FileDescriptor* file = files[i]; + succeeded = Generate(file, parameter, generator_context, error); + if (!succeeded && error && error->empty()) { + *error = "Code generator returned false but provided no error " + "description."; + } + if (error && !error->empty()) { + *error = file->name() + ": " + *error; + break; + } + if (!succeeded) { + break; + } + } + return succeeded; +} + GeneratorContext::~GeneratorContext() {} io::ZeroCopyOutputStream* diff --git a/src/google/protobuf/compiler/code_generator.h b/src/google/protobuf/compiler/code_generator.h index b989f151..642bbfad 100644 --- a/src/google/protobuf/compiler/code_generator.h +++ b/src/google/protobuf/compiler/code_generator.h @@ -66,11 +66,11 @@ class LIBPROTOC_EXPORT CodeGenerator { // Generates code for the given proto file, generating one or more files in // the given output directory. // - // A parameter to be passed to the generator can be specified on the - // command line. This is intended to be used by Java and similar languages - // to specify which specific class from the proto file is to be generated, - // though it could have other uses as well. It is empty if no parameter was - // given. + // A parameter to be passed to the generator can be specified on the command + // line. This is intended to be used to pass generator specific parameters. + // It is empty if no parameter was given. ParseGeneratorParameter (below), + // can be used to accept multiple parameters within the single parameter + // command line flag. // // Returns true if successful. Otherwise, sets *error to a description of // the problem (e.g. "invalid parameter") and returns false. @@ -79,18 +79,11 @@ class LIBPROTOC_EXPORT CodeGenerator { GeneratorContext* generator_context, string* error) const = 0; - // Generates code for all given proto files, generating one or more files in - // the given output directory. - // - // This method should be called instead of |Generate()| when - // |HasGenerateAll()| returns |true|. It is used to emulate legacy semantics - // when more than one `.proto` file is specified on one compiler invocation. + // Generates code for all given proto files. // - // WARNING: Please do not use unless legacy semantics force the code generator - // to produce a single output file for all input files, or otherwise require - // an examination of all input files first. The canonical code generator - // design produces one output file per input .proto file, and we do not wish - // to encourage alternate designs. + // WARNING: The canonical code generator design produces one or two output + // files per input .proto file, and we do not wish to encourage alternate + // designs. // // A parameter is given as passed on the command line, as in |Generate()| // above. @@ -100,15 +93,13 @@ class LIBPROTOC_EXPORT CodeGenerator { virtual bool GenerateAll(const vector<const FileDescriptor*>& files, const string& parameter, GeneratorContext* generator_context, - string* error) const { - *error = "Unimplemented GenerateAll() method."; - return false; - } - - // Returns true if the code generator expects to receive all FileDescriptors - // at once (via |GenerateAll()|), rather than one at a time (via - // |Generate()|). This is required to implement legacy semantics. - virtual bool HasGenerateAll() const { return false; } + string* error) const; + + // This is no longer used, but this class is part of the opensource protobuf + // library, so it has to remain to keep vtables the same for the current + // version of the library. When protobufs does a api breaking change, the + // method can be removed. + virtual bool HasGenerateAll() const { return true; } private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodeGenerator); diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index bb781b0a..0d1c30ce 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -704,6 +704,7 @@ CommandLineInterface::CommandLineInterface() : mode_(MODE_COMPILE), print_mode_(PRINT_NONE), error_format_(ERROR_FORMAT_GCC), + direct_dependencies_explicitly_set_(false), imports_in_descriptor_set_(false), source_info_in_descriptor_set_(false), disallow_services_(false), @@ -784,6 +785,24 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { "--disallow_services was used." << endl; return 1; } + + // Enforce --direct_dependencies + if (direct_dependencies_explicitly_set_) { + bool indirect_imports = false; + for (int i = 0; i < parsed_file->dependency_count(); i++) { + if (direct_dependencies_.find(parsed_file->dependency(i)->name()) == + direct_dependencies_.end()) { + indirect_imports = true; + cerr << parsed_file->name() + << ": File is imported but not declared in " + << "--direct_dependencies: " + << parsed_file->dependency(i)->name() << std::endl; + } + } + if (indirect_imports) { + return 1; + } + } } // We construct a separate GeneratorContext for each output location. Note @@ -897,6 +916,7 @@ void CommandLineInterface::Clear() { executable_name_.clear(); proto_path_.clear(); input_files_.clear(); + direct_dependencies_.clear(); output_directives_.clear(); codec_type_.clear(); descriptor_set_name_.clear(); @@ -907,6 +927,7 @@ void CommandLineInterface::Clear() { imports_in_descriptor_set_ = false; source_info_in_descriptor_set_ = false; disallow_services_ = false; + direct_dependencies_explicitly_set_ = false; } bool CommandLineInterface::MakeInputsBeProtoPathRelative( @@ -1154,6 +1175,21 @@ CommandLineInterface::InterpretArgument(const string& name, proto_path_.push_back(pair<string, string>(virtual_path, disk_path)); } + } else if (name == "--direct_dependencies") { + if (direct_dependencies_explicitly_set_) { + std::cerr << name << " may only be passed once. To specify multiple " + "direct dependencies, pass them all as a single " + "parameter separated by '" + << kPathSeparator << "'." << std::endl; + return PARSE_ARGUMENT_FAIL; + } + + direct_dependencies_explicitly_set_ = true; + vector<string> direct = Split( + value, kPathSeparator, true); + GOOGLE_DCHECK(direct_dependencies_.empty()); + direct_dependencies_.insert(direct.begin(), direct.end()); + } else if (name == "-o" || name == "--descriptor_set_out") { if (!descriptor_set_name_.empty()) { std::cerr << name << " may only be passed once." << std::endl; @@ -1447,24 +1483,11 @@ bool CommandLineInterface::GenerateOutput( } parameters.append(generator_parameters_[output_directive.name]); } - if (output_directive.generator->HasGenerateAll()) { - if (!output_directive.generator->GenerateAll( - parsed_files, parameters, generator_context, &error)) { - // Generator returned an error. - std::cerr << output_directive.name << ": " - << ": " << error << std::endl; - return false; - } - } else { - for (int i = 0; i < parsed_files.size(); i++) { - if (!output_directive.generator->Generate(parsed_files[i], parameters, - generator_context, &error)) { - // Generator returned an error. - std::cerr << output_directive.name << ": " << parsed_files[i]->name() - << ": " << error << std::endl; - return false; - } - } + if (!output_directive.generator->GenerateAll( + parsed_files, parameters, generator_context, &error)) { + // Generator returned an error. + std::cerr << output_directive.name << ": " << error << std::endl; + return false; } } diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h index 32084567..c38e65a3 100644 --- a/src/google/protobuf/compiler/command_line_interface.h +++ b/src/google/protobuf/compiler/command_line_interface.h @@ -352,6 +352,11 @@ class LIBPROTOC_EXPORT CommandLineInterface { vector<pair<string, string> > proto_path_; // Search path for proto files. vector<string> input_files_; // Names of the input proto files. + // Names of proto files which are allowed to be imported. Used by build + // systems to enforce depend-on-what-you-import. + set<string> direct_dependencies_; + bool direct_dependencies_explicitly_set_; + // output_directives_ lists all the files we are supposed to output and what // generator to use for each. struct OutputDirective { diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index dee438c6..56a07dbf 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -871,6 +871,92 @@ TEST_F(CommandLineInterfaceTest, AllowServicesHasService) { ExpectGenerated("test_generator", "", "foo.proto", "Foo"); } +TEST_F(CommandLineInterfaceTest, DirectDependencies_Missing_EmptyList) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"bar.proto\";\n" + "message Foo { optional Bar bar = 1; }"); + CreateTempFile("bar.proto", + "syntax = \"proto2\";\n" + "message Bar { optional string text = 1; }"); + + Run("protocol_compiler --test_out=$tmpdir --proto_path=$tmpdir " + "--direct_dependencies= foo.proto"); + + ExpectErrorText( + "foo.proto: File is imported but not declared in --direct_dependencies: " + "bar.proto\n"); +} + +TEST_F(CommandLineInterfaceTest, DirectDependencies_Missing) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"bar.proto\";\n" + "import \"bla.proto\";\n" + "message Foo { optional Bar bar = 1; optional Bla bla = 2; }"); + CreateTempFile("bar.proto", + "syntax = \"proto2\";\n" + "message Bar { optional string text = 1; }"); + CreateTempFile("bla.proto", + "syntax = \"proto2\";\n" + "message Bla { optional int64 number = 1; }"); + + Run("protocol_compiler --test_out=$tmpdir --proto_path=$tmpdir " + "--direct_dependencies=bla.proto foo.proto"); + + ExpectErrorText( + "foo.proto: File is imported but not declared in --direct_dependencies: " + "bar.proto\n"); +} + +TEST_F(CommandLineInterfaceTest, DirectDependencies_NoViolation) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"bar.proto\";\n" + "message Foo { optional Bar bar = 1; }"); + CreateTempFile("bar.proto", + "syntax = \"proto2\";\n" + "message Bar { optional string text = 1; }"); + + Run("protocol_compiler --test_out=$tmpdir --proto_path=$tmpdir " + "--direct_dependencies=bar.proto foo.proto"); + + ExpectNoErrors(); +} + +TEST_F(CommandLineInterfaceTest, DirectDependencies_NoViolation_MultiImports) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"bar.proto\";\n" + "import \"bla.proto\";\n" + "message Foo { optional Bar bar = 1; optional Bla bla = 2; }"); + CreateTempFile("bar.proto", + "syntax = \"proto2\";\n" + "message Bar { optional string text = 1; }"); + CreateTempFile("bla.proto", + "syntax = \"proto2\";\n" + "message Bla { optional int64 number = 1; }"); + + Run("protocol_compiler --test_out=$tmpdir --proto_path=$tmpdir " + "--direct_dependencies=bar.proto:bla.proto foo.proto"); + + ExpectNoErrors(); +} + +TEST_F(CommandLineInterfaceTest, DirectDependencies_ProvidedMultipleTimes) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n"); + + Run("protocol_compiler --test_out=$tmpdir --proto_path=$tmpdir " + "--direct_dependencies=bar.proto --direct_dependencies=bla.proto " + "foo.proto"); + + ExpectErrorText( + "--direct_dependencies may only be passed once. To specify multiple " + "direct dependencies, pass them all as a single parameter separated by " + "':'.\n"); +} + TEST_F(CommandLineInterfaceTest, CwdRelativeInputs) { // Test that we can accept working-directory-relative input files. diff --git a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc index 77451ab1..deef290b 100644 --- a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc @@ -99,7 +99,6 @@ class MockGeneratorContext : public GeneratorContext { &actual_contents, true)); EXPECT_TRUE(actual_contents == *expected_contents) << physical_filename << " needs to be regenerated. Please run " - "google/protobuf/compiler/release_compiler.sh and " "generate_descriptor_proto.sh. Then add this file " "to your CL."; } diff --git a/src/google/protobuf/compiler/cpp/cpp_enum.cc b/src/google/protobuf/compiler/cpp/cpp_enum.cc index 62b7ed4e..6ced26bc 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum.cc @@ -260,7 +260,7 @@ void EnumGenerator::GenerateMethods(io::Printer* printer) { printer->Print(vars, "bool $classname$_IsValid(int value) {\n" - " switch(value) {\n"); + " switch (value) {\n"); // Multiple values may have the same number. Make sure we only cover // each number once by first constructing a set containing all valid diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc index ffd81529..c3dfa817 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc @@ -83,13 +83,13 @@ void EnumFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ $type$ $classname$::$name$() const {\n" + "$inline$$type$ $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return static_cast< $type$ >($name$_);\n" "}\n" - "$inline$ void $classname$::set_$name$($type$ value) {\n"); + "$inline$void $classname$::set_$name$($type$ value) {\n"); if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) { printer->Print(variables, " assert($type$_IsValid(value));\n"); @@ -187,16 +187,16 @@ void EnumOneofFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ $type$ $classname$::$name$() const {\n" + "$inline$$type$ $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " if (has_$name$()) {\n" " return static_cast< $type$ >($oneof_prefix$$name$_);\n" " }\n" " return static_cast< $type$ >($default$);\n" "}\n" - "$inline$ void $classname$::set_$name$($type$ value) {\n"); + "$inline$void $classname$::set_$name$($type$ value) {\n"); if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) { printer->Print(variables, " assert($type$_IsValid(value));\n"); @@ -263,13 +263,13 @@ void RepeatedEnumFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ $type$ $classname$::$name$(int index) const {\n" + "$inline$$type$ $classname$::$name$(int index) const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return static_cast< $type$ >($name$_.Get(index));\n" "}\n" - "$inline$ void $classname$::set_$name$(int index, $type$ value) {\n"); + "$inline$void $classname$::set_$name$(int index, $type$ value) {\n"); if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) { printer->Print(variables, " assert($type$_IsValid(value));\n"); @@ -278,7 +278,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " $name$_.Set(index, value);\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$ void $classname$::add_$name$($type$ value) {\n"); + "$inline$void $classname$::add_$name$($type$ value) {\n"); if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) { printer->Print(variables, " assert($type$_IsValid(value));\n"); @@ -288,12 +288,12 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " // @@protoc_insertion_point(field_add:$full_name$)\n" "}\n"); printer->Print(variables, - "$inline$ const ::google::protobuf::RepeatedField<int>&\n" + "$inline$const ::google::protobuf::RepeatedField<int>&\n" "$classname$::$name$() const {\n" " // @@protoc_insertion_point(field_list:$full_name$)\n" " return $name$_;\n" "}\n" - "$inline$ ::google::protobuf::RepeatedField<int>*\n" + "$inline$::google::protobuf::RepeatedField<int>*\n" "$classname$::mutable_$name$() {\n" " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" " return &$name$_;\n" @@ -311,6 +311,11 @@ GenerateMergingCode(io::Printer* printer) const { } void RepeatedEnumFieldGenerator:: +GenerateUnsafeMergingCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_.UnsafeMergeFrom(from.$name$_);\n"); +} + +void RepeatedEnumFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n"); } @@ -475,10 +480,11 @@ void RepeatedEnumFieldGenerator:: GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, "{\n" - " int data_size = 0;\n"); + " size_t data_size = 0;\n" + " unsigned int count = this->$name$_size();"); printer->Indent(); printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n" + "for (unsigned int i = 0; i < count; i++) {\n" " data_size += ::google::protobuf::internal::WireFormatLite::EnumSize(\n" " this->$name$(i));\n" "}\n"); @@ -489,13 +495,14 @@ GenerateByteSize(io::Printer* printer) const { " total_size += $tag_size$ +\n" " ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n" "}\n" + "int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n" "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" - "_$name$_cached_byte_size_ = data_size;\n" + "_$name$_cached_byte_size_ = cached_size;\n" "GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" "total_size += data_size;\n"); } else { printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size() + data_size;\n"); + "total_size += ($tag_size$UL * count) + data_size;\n"); } printer->Outdent(); printer->Print("}\n"); diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.h b/src/google/protobuf/compiler/cpp/cpp_enum_field.h index fe21c575..57ffeec5 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.h @@ -101,6 +101,7 @@ class RepeatedEnumFieldGenerator : public FieldGenerator { bool is_inline) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; + void GenerateUnsafeMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; diff --git a/src/google/protobuf/compiler/cpp/cpp_extension.cc b/src/google/protobuf/compiler/cpp/cpp_extension.cc index c42f1627..4554c72c 100644 --- a/src/google/protobuf/compiler/cpp/cpp_extension.cc +++ b/src/google/protobuf/compiler/cpp/cpp_extension.cc @@ -178,28 +178,30 @@ void ExtensionGenerator::GenerateRegistration(io::Printer* printer) { switch (descriptor_->cpp_type()) { case FieldDescriptor::CPPTYPE_ENUM: - printer->Print(vars, - "::google::protobuf::internal::ExtensionSet::RegisterEnumExtension(\n" - " &$extendee$::default_instance(),\n" - " $number$, $field_type$, $is_repeated$, $is_packed$,\n"); + printer->Print( + vars, + "::google::protobuf::internal::ExtensionSet::RegisterEnumExtension(\n" + " $extendee$::internal_default_instance(),\n" + " $number$, $field_type$, $is_repeated$, $is_packed$,\n"); printer->Print( " &$type$_IsValid);\n", "type", ClassName(descriptor_->enum_type(), true)); break; case FieldDescriptor::CPPTYPE_MESSAGE: - printer->Print(vars, - "::google::protobuf::internal::ExtensionSet::RegisterMessageExtension(\n" - " &$extendee$::default_instance(),\n" - " $number$, $field_type$, $is_repeated$, $is_packed$,\n"); printer->Print( - " &$type$::default_instance());\n", - "type", ClassName(descriptor_->message_type(), true)); + vars, + "::google::protobuf::internal::ExtensionSet::RegisterMessageExtension(\n" + " $extendee$::internal_default_instance(),\n" + " $number$, $field_type$, $is_repeated$, $is_packed$,\n"); + printer->Print(" $type$::internal_default_instance());\n", "type", + ClassName(descriptor_->message_type(), true)); break; default: - printer->Print(vars, - "::google::protobuf::internal::ExtensionSet::RegisterExtension(\n" - " &$extendee$::default_instance(),\n" - " $number$, $field_type$, $is_repeated$, $is_packed$);\n"); + printer->Print( + vars, + "::google::protobuf::internal::ExtensionSet::RegisterExtension(\n" + " $extendee$::internal_default_instance(),\n" + " $number$, $field_type$, $is_repeated$, $is_packed$);\n"); break; } } diff --git a/src/google/protobuf/compiler/cpp/cpp_field.h b/src/google/protobuf/compiler/cpp/cpp_field.h index 3b012527..fdd338a6 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_field.h @@ -136,6 +136,13 @@ class FieldGenerator { // GenerateMergeFrom method. virtual void GenerateMergingCode(io::Printer* printer) const = 0; + // The same, but the generated code may or may not check the possibility that + // the two objects being merged have the same address. To be safe, callers + // should avoid calling this unless they know the objects are different. + virtual void GenerateUnsafeMergingCode(io::Printer* printer) const { + GenerateMergingCode(printer); + } + // Generate lines of code (statements, not declarations) which swaps // this field and the corresponding field of another message, which // is stored in the generated code variable "other". This is used to diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index b3eca660..369497ce 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -89,7 +89,7 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) new ExtensionGenerator(file->extension(i), options)); } - SplitStringUsing(file_->package(), ".", &package_parts_); + package_parts_ = Split(file_->package(), ".", true); } FileGenerator::~FileGenerator() {} @@ -336,6 +336,20 @@ void FileGenerator::GenerateSource(io::Printer* printer) { // Generate classes. for (int i = 0; i < file_->message_type_count(); i++) { + if (i == 0 && HasGeneratedMethods(file_, options_)) { + printer->Print( + "\n" + "namespace {\n" + "\n" + "static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD" + " GOOGLE_ATTRIBUTE_NORETURN;\n" + "static void MergeFromFail(int line) {\n" + " ::google::protobuf::internal::MergeFromFail(__FILE__, line);\n" + "}\n" + "\n" + "} // namespace\n" + "\n"); + } printer->Print("\n"); printer->Print(kThickSeparator); printer->Print("\n"); @@ -449,6 +463,7 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // In optimize_for = LITE_RUNTIME mode, we don't generate AssignDescriptors() // and we only use AddDescriptors() to allocate default instances. + if (HasDescriptorMethods(file_, options_)) { printer->Print( "\n" @@ -500,15 +515,15 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // AssignDescriptors(). All later times, waits for the first call to // complete and then returns. printer->Print( - "namespace {\n" - "\n" - "GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\n" - "inline void protobuf_AssignDescriptorsOnce() {\n" - " ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n" - " &$assigndescriptorsname$);\n" - "}\n" - "\n", - "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name())); + "namespace {\n" + "\n" + "GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\n" + "void protobuf_AssignDescriptorsOnce() {\n" + " ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n" + " &$assigndescriptorsname$);\n" + "}\n" + "\n", + "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name())); // protobuf_RegisterTypes(): Calls // MessageFactory::InternalRegisterGeneratedType() for each message type. @@ -548,44 +563,68 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // ----------------------------------------------------------------- - // Now generate the AddDescriptors() function. - PrintHandlingOptionalStaticInitializers( - file_, options_, printer, - // With static initializers. - // Note that we don't need any special synchronization in the following - // code - // because it is called at static init time before any threads exist. - "void $adddescriptorsname$() GOOGLE_ATTRIBUTE_COLD;\n" - "void $adddescriptorsname$() {\n" - " static bool already_here = false;\n" - " if (already_here) return;\n" - " already_here = true;\n" - " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" - "\n", - // Without. - "void $adddescriptorsname$_impl() {\n" + // Now generate the InitDefaults() function. + printer->Print( + "void $initdefaultsname$_impl() {\n" " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" "\n", // Vars. - "adddescriptorsname", GlobalAddDescriptorsName(file_->name())); + "initdefaultsname", GlobalInitDefaultsName(file_->name())); printer->Indent(); - // Call the AddDescriptors() methods for all of our dependencies, to make + // Call the InitDefaults() methods for all of our dependencies, to make // sure they get added first. for (int i = 0; i < file_->dependency_count(); i++) { const FileDescriptor* dependency = file_->dependency(i); // Print the namespace prefix for the dependency. string add_desc_name = QualifiedFileLevelSymbol( - dependency->package(), GlobalAddDescriptorsName(dependency->name())); + dependency->package(), GlobalInitDefaultsName(dependency->name())); // Call its AddDescriptors function. printer->Print( "$name$();\n", "name", add_desc_name); } + // Allocate and initialize default instances. This can't be done lazily + // since default instances are returned by simple accessors and are used with + // extensions. Speaking of which, we also register extensions at this time. + for (int i = 0; i < file_->message_type_count(); i++) { + message_generators_[i]->GenerateDefaultInstanceAllocator(printer); + } + for (int i = 0; i < file_->extension_count(); i++) { + extension_generators_[i]->GenerateRegistration(printer); + } + for (int i = 0; i < file_->message_type_count(); i++) { + message_generators_[i]->GenerateDefaultInstanceInitializer(printer); + } + printer->Outdent(); + printer->Print( + "}\n" + "\n" + "GOOGLE_PROTOBUF_DECLARE_ONCE($initdefaultsname$_once_);\n" + "void $initdefaultsname$() {\n" + " ::google::protobuf::GoogleOnceInit(&$initdefaultsname$_once_,\n" + " &$initdefaultsname$_impl);\n" + "}\n", + "initdefaultsname", GlobalInitDefaultsName(file_->name())); + + // ----------------------------------------------------------------- + + // Now generate the AddDescriptors() function. + printer->Print( + "void $adddescriptorsname$_impl() {\n" + " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" + "\n" + " $initdefaultsname$();\n", + // Vars. + "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), + "initdefaultsname", GlobalInitDefaultsName(file_->name())); + + printer->Indent(); if (HasDescriptorMethods(file_, options_)) { - // Embed the descriptor. We simply serialize the entire FileDescriptorProto + // Embed the descriptor. We simply serialize the entire + // FileDescriptorProto // and embed it as a string literal, which is parsed and built into real // descriptors at initialization time. FileDescriptorProto file_proto; @@ -655,30 +694,37 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { "filename", file_->name()); } - // Allocate and initialize default instances. This can't be done lazily - // since default instances are returned by simple accessors and are used with - // extensions. Speaking of which, we also register extensions at this time. - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateDefaultInstanceAllocator(printer); - } - for (int i = 0; i < file_->extension_count(); i++) { - extension_generators_[i]->GenerateRegistration(printer); - } - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateDefaultInstanceInitializer(printer); + // Call the AddDescriptors() methods for all of our dependencies, to make + // sure they get added first. + for (int i = 0; i < file_->dependency_count(); i++) { + const FileDescriptor* dependency = file_->dependency(i); + // Print the namespace prefix for the dependency. + string add_desc_name = QualifiedFileLevelSymbol( + dependency->package(), GlobalAddDescriptorsName(dependency->name())); + // Call its AddDescriptors function. + printer->Print("$adddescriptorsname$();\n", "adddescriptorsname", + add_desc_name); } printer->Print( - "::google::protobuf::internal::OnShutdown(&$shutdownfilename$);\n", - "shutdownfilename", GlobalShutdownFileName(file_->name())); + "::google::protobuf::internal::OnShutdown(&$shutdownfilename$);\n", + "shutdownfilename", GlobalShutdownFileName(file_->name())); printer->Outdent(); printer->Print( - "}\n" - "\n"); + "}\n" + "\n" + "GOOGLE_PROTOBUF_DECLARE_ONCE($adddescriptorsname$_once_);\n" + "void $adddescriptorsname$() {\n" + " ::google::protobuf::GoogleOnceInit(&$adddescriptorsname$_once_,\n" + " &$adddescriptorsname$_impl);\n" + "}\n", + "adddescriptorsname", GlobalAddDescriptorsName(file_->name())); - PrintHandlingOptionalStaticInitializers( - file_, options_, printer, + if (!StaticInitializersForced(file_, options_)) { + printer->Print("#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); + } + printer->Print( // With static initializers. "// Force AddDescriptors() to be called at static initialization time.\n" "struct StaticDescriptorInitializer_$filename$ {\n" @@ -686,15 +732,12 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { " $adddescriptorsname$();\n" " }\n" "} static_descriptor_initializer_$filename$_;\n", - // Without. - "GOOGLE_PROTOBUF_DECLARE_ONCE($adddescriptorsname$_once_);\n" - "void $adddescriptorsname$() {\n" - " ::google::protobuf::GoogleOnceInit(&$adddescriptorsname$_once_,\n" - " &$adddescriptorsname$_impl);\n" - "}\n", // Vars. "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), "filename", FilenameIdentifier(file_->name())); + if (!StaticInitializersForced(file_, options_)) { + printer->Print("#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); + } } void FileGenerator::GenerateNamespaceOpeners(io::Printer* printer) { @@ -892,12 +935,14 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations( // Forward-declare the AddDescriptors, AssignDescriptors, and ShutdownFile // functions, so that we can declare them to be friends of each class. printer->Print( - "\n" - "// Internal implementation detail -- do not call these.\n" - "void $dllexport_decl$$adddescriptorsname$();\n", - "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), - "dllexport_decl", - options_.dllexport_decl.empty() ? "" : options_.dllexport_decl + " "); + "\n" + "// Internal implementation detail -- do not call these.\n" + "void $dllexport_decl$$adddescriptorsname$();\n" + "void $dllexport_decl$$initdefaultsname$();\n", + "initdefaultsname", GlobalInitDefaultsName(file_->name()), + "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), + "dllexport_decl", + options_.dllexport_decl.empty() ? "" : options_.dllexport_decl + " "); printer->Print( // Note that we don't put dllexport_decl on these because they are only diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 2ad4d36a..6d844cc2 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -415,7 +415,8 @@ string DefaultValue(const FieldDescriptor* field) { CEscape(field->default_value_string())) + "\""; case FieldDescriptor::CPPTYPE_MESSAGE: - return FieldMessageTypeName(field) + "::default_instance()"; + return "*" + FieldMessageTypeName(field) + + "::internal_default_instance()"; } // Can't actually get here; make compiler happy. (We could add a default // case above but then we wouldn't get the nice compiler warning when a @@ -444,6 +445,10 @@ string GlobalAddDescriptorsName(const string& filename) { return "protobuf_AddDesc_" + FilenameIdentifier(filename); } +string GlobalInitDefaultsName(const string& filename) { + return "protobuf_InitDefaults_" + FilenameIdentifier(filename); +} + // Return the name of the AssignDescriptors() function for a given file. string GlobalAssignDescriptorsName(const string& filename) { return "protobuf_AssignDesc_" + FilenameIdentifier(filename); @@ -500,40 +505,6 @@ bool StaticInitializersForced(const FileDescriptor* file, return false; } -void PrintHandlingOptionalStaticInitializers( - const FileDescriptor* file, const Options& options, io::Printer* printer, - const char* with_static_init, const char* without_static_init, - const char* var1, const string& val1, const char* var2, - const string& val2) { - map<string, string> vars; - if (var1) { - vars[var1] = val1; - } - if (var2) { - vars[var2] = val2; - } - PrintHandlingOptionalStaticInitializers( - vars, file, options, printer, with_static_init, without_static_init); -} - -void PrintHandlingOptionalStaticInitializers(const map<string, string>& vars, - const FileDescriptor* file, - const Options& options, - io::Printer* printer, - const char* with_static_init, - const char* without_static_init) { - if (StaticInitializersForced(file, options)) { - printer->Print(vars, with_static_init); - } else { - printer->Print(vars, (string( - "#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n") + - without_static_init + - "#else\n" + - with_static_init + - "#endif\n").c_str()); - } -} - static bool HasMapFields(const Descriptor* descriptor) { for (int i = 0; i < descriptor->field_count(); ++i) { diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h index 018acfca..3a0c0388 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -147,6 +147,9 @@ string FilenameIdentifier(const string& filename); // Return the name of the AddDescriptors() function for a given file. string GlobalAddDescriptorsName(const string& filename); +// Return the name of the InitDefaults() function for a given file. +string GlobalInitDefaultsName(const string& filename); + // Return the name of the AssignDescriptors() function for a given file. string GlobalAssignDescriptorsName(const string& filename); @@ -223,22 +226,6 @@ inline bool HasFastArraySerialization(const FileDescriptor* file, bool StaticInitializersForced(const FileDescriptor* file, const Options& options); -// Prints 'with_static_init' if static initializers have to be used for the -// provided file. Otherwise emits both 'with_static_init' and -// 'without_static_init' using #ifdef. -void PrintHandlingOptionalStaticInitializers( - const FileDescriptor* file, const Options& options, io::Printer* printer, - const char* with_static_init, const char* without_static_init, - const char* var1 = NULL, const string& val1 = "", const char* var2 = NULL, - const string& val2 = ""); - -void PrintHandlingOptionalStaticInitializers(const map<string, string>& vars, - const FileDescriptor* file, - const Options& options, - io::Printer* printer, - const char* with_static_init, - const char* without_static_init); - inline bool IsMapEntryMessage(const Descriptor* descriptor) { return descriptor->options().map_entry(); diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc index 0588e34e..31ac9ca7 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc @@ -399,7 +399,8 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizes( void MapFieldGenerator:: GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size();\n" + "total_size += $tag_size$ *\n" + " ::google::protobuf::internal::FromIntSize(this->$name$_size());\n" "{\n" " ::google::protobuf::scoped_ptr<$map_classname$> entry;\n" " for (::google::protobuf::Map< $key_cpp$, $val_cpp$ >::const_iterator\n" diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 0034b121..f5648663 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -85,14 +85,13 @@ struct FieldOrderingByNumber { // Sort the fields of the given Descriptor by number into a new[]'d array // and return it. -const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) { - const FieldDescriptor** fields = - new const FieldDescriptor*[descriptor->field_count()]; +std::vector<const FieldDescriptor*> SortFieldsByNumber( + const Descriptor* descriptor) { + std::vector<const FieldDescriptor*> fields(descriptor->field_count()); for (int i = 0; i < descriptor->field_count(); i++) { fields[i] = descriptor->field(i); } - std::sort(fields, fields + descriptor->field_count(), - FieldOrderingByNumber()); + std::sort(fields.begin(), fields.end(), FieldOrderingByNumber()); return fields; } @@ -227,59 +226,150 @@ class FieldGroup { // used in a vector. }; +// Helper for the code that emits the Clear() method. +bool CanInitializeByZeroing(const FieldDescriptor* field) { + if (field->is_repeated() || field->is_extension()) return false; + switch (field->cpp_type()) { + case internal::WireFormatLite::CPPTYPE_ENUM: + return field->default_value_enum()->number() == 0; + case internal::WireFormatLite::CPPTYPE_INT32: + return field->default_value_int32() == 0; + case internal::WireFormatLite::CPPTYPE_INT64: + return field->default_value_int64() == 0; + case internal::WireFormatLite::CPPTYPE_UINT32: + return field->default_value_uint32() == 0; + case internal::WireFormatLite::CPPTYPE_UINT64: + return field->default_value_uint64() == 0; + case internal::WireFormatLite::CPPTYPE_FLOAT: + return field->default_value_float() == 0; + case internal::WireFormatLite::CPPTYPE_DOUBLE: + return field->default_value_double() == 0; + case internal::WireFormatLite::CPPTYPE_BOOL: + return field->default_value_bool() == false; + default: + return false; + } +} + // Reorder 'fields' so that if the fields are output into a c++ class in the new -// order, the alignment padding is minimized. We try to do this while keeping -// each field as close as possible to its original position so that we don't -// reduce cache locality much for function that access each field in order. +// order, fields of similiar family (see below) are together and within each +// family, alignment padding is minimized. +// +// We try to do this while keeping each field as close as possible to its +// declaration order (from the .proto file) so that we don't reduce cache +// locality much for function that access each field in order. This is also the +// only (weak) signal we have for author intent concerning field layout. +// +// TODO(ckennelly): Update these functions to use the optimized layout order +// for their access patterns. +// +// TODO(ckennelly): If/when we have profiles available for the compiler, use +// those rather than respect declaration order. +// +// We classify each field into a particular "family" of fields, that we perform +// the same operation on in our generated functions. +// +// REPEATED is placed first, as the C++ compiler automatically initializes +// these fields in layout order. +// +// STRING is grouped next, as our Clear/SharedCtor/SharedDtor walks it and +// calls ArenaStringPtr::Destroy on each. +// +// MESSAGE is grouped next, as our Clear/SharedDtor code walks it and calls +// delete on each. We initialize these fields with a NULL pointer (see +// MessageFieldGenerator::GenerateConstructorCode). +// TODO(ckennelly): memset these in SharedCtor. +// +// ZERO_INITIALIZABLE is memset in Clear/SharedCtor +// +// OTHER these fields are initialized one-by-one. void OptimizePadding(vector<const FieldDescriptor*>* fields) { + // The sorted numeric order of Family determines the declaration order in the + // memory layout. + enum Family { + REPEATED = 0, + STRING = 1, + MESSAGE = 2, + ZERO_INITIALIZABLE = 3, + OTHER = 4, + kMaxFamily + }; + // First divide fields into those that align to 1 byte, 4 bytes or 8 bytes. - vector<FieldGroup> aligned_to_1, aligned_to_4, aligned_to_8; + vector<FieldGroup> aligned_to_1[kMaxFamily]; + vector<FieldGroup> aligned_to_4[kMaxFamily]; + vector<FieldGroup> aligned_to_8[kMaxFamily]; for (int i = 0; i < fields->size(); ++i) { - switch (EstimateAlignmentSize((*fields)[i])) { - case 1: aligned_to_1.push_back(FieldGroup(i, (*fields)[i])); break; - case 4: aligned_to_4.push_back(FieldGroup(i, (*fields)[i])); break; - case 8: aligned_to_8.push_back(FieldGroup(i, (*fields)[i])); break; - default: - GOOGLE_LOG(FATAL) << "Unknown alignment size."; + const FieldDescriptor* field = (*fields)[i]; + + Family f = OTHER; + if (field->is_repeated()) { + f = REPEATED; + } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { + f = STRING; + } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + f = MESSAGE; + } else if (CanInitializeByZeroing(field)) { + f = ZERO_INITIALIZABLE; } - } - // Now group fields aligned to 1 byte into sets of 4, and treat those like a - // single field aligned to 4 bytes. - for (int i = 0; i < aligned_to_1.size(); i += 4) { - FieldGroup field_group; - for (int j = i; j < aligned_to_1.size() && j < i + 4; ++j) { - field_group.Append(aligned_to_1[j]); + switch (EstimateAlignmentSize(field)) { + case 1: aligned_to_1[f].push_back(FieldGroup(i, field)); break; + case 4: aligned_to_4[f].push_back(FieldGroup(i, field)); break; + case 8: aligned_to_8[f].push_back(FieldGroup(i, field)); break; + default: + GOOGLE_LOG(FATAL) << "Unknown alignment size."; } - aligned_to_4.push_back(field_group); } - // Sort by preferred location to keep fields as close to their original - // location as possible. Using stable_sort ensures that the output is - // consistent across runs. - std::stable_sort(aligned_to_4.begin(), aligned_to_4.end()); - // Now group fields aligned to 4 bytes (or the 4-field groups created above) - // into pairs, and treat those like a single field aligned to 8 bytes. - for (int i = 0; i < aligned_to_4.size(); i += 2) { - FieldGroup field_group; - for (int j = i; j < aligned_to_4.size() && j < i + 2; ++j) { - field_group.Append(aligned_to_4[j]); - } - if (i == aligned_to_4.size() - 1) { - // Move incomplete 4-byte block to the end. - field_group.SetPreferredLocation(fields->size() + 1); + // For each family, group fields to optimize padding. + for (int f = 0; f < kMaxFamily; f++) { + // Now group fields aligned to 1 byte into sets of 4, and treat those like a + // single field aligned to 4 bytes. + for (int i = 0; i < aligned_to_1[f].size(); i += 4) { + FieldGroup field_group; + for (int j = i; j < aligned_to_1[f].size() && j < i + 4; ++j) { + field_group.Append(aligned_to_1[f][j]); + } + aligned_to_4[f].push_back(field_group); + } + // Sort by preferred location to keep fields as close to their declaration + // order as possible. Using stable_sort ensures that the output is + // consistent across runs. + std::stable_sort(aligned_to_4[f].begin(), aligned_to_4[f].end()); + + // Now group fields aligned to 4 bytes (or the 4-field groups created above) + // into pairs, and treat those like a single field aligned to 8 bytes. + for (int i = 0; i < aligned_to_4[f].size(); i += 2) { + FieldGroup field_group; + for (int j = i; j < aligned_to_4[f].size() && j < i + 2; ++j) { + field_group.Append(aligned_to_4[f][j]); + } + if (i == aligned_to_4[f].size() - 1) { + if (f == OTHER) { + // Move incomplete 4-byte block to the beginning. This is done to + // pair with the (possible) leftover blocks from the + // ZERO_INITIALIZABLE family. + field_group.SetPreferredLocation(-1); + } else { + // Move incomplete 4-byte block to the end. + field_group.SetPreferredLocation(fields->size() + 1); + } + } + aligned_to_8[f].push_back(field_group); } - aligned_to_8.push_back(field_group); + // Sort by preferred location. + std::stable_sort(aligned_to_8[f].begin(), aligned_to_8[f].end()); } - // Sort by preferred location. - std::stable_sort(aligned_to_8.begin(), aligned_to_8.end()); // Now pull out all the FieldDescriptors in order. fields->clear(); - for (int i = 0; i < aligned_to_8.size(); ++i) { - fields->insert(fields->end(), - aligned_to_8[i].fields().begin(), - aligned_to_8[i].fields().end()); + for (int f = 0; f < kMaxFamily; ++f) { + for (int i = 0; i < aligned_to_8[f].size(); ++i) { + fields->insert(fields->end(), + aligned_to_8[f][i].fields().begin(), + aligned_to_8[f][i].fields().end()); + } } } @@ -337,6 +427,20 @@ bool HasHasMethod(const FieldDescriptor* field) { return field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE; } +size_t HasBitsSize(const Descriptor* descriptor) { + // TODO(jieluo) - Optimize _has_bits_ for repeated and oneof fields. + size_t sizeof_has_bits = (descriptor->field_count() + 31) / 32 * 4; + if (descriptor->field_count() == 0) { + // Zero-size arrays aren't technically allowed, and MSVC in particular + // doesn't like them. We still need to declare these arrays to make + // other code compile. Since this is an uncommon case, we'll just declare + // them with size 1 and waste some space. Oh well. + sizeof_has_bits = 4; + } + + return sizeof_has_bits; +} + // Collects map entry message type information. void CollectMapInfo(const Descriptor* descriptor, map<string, string>* variables) { @@ -389,6 +493,15 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, ExtensionGenerator>[descriptor->extension_count()]), use_dependent_base_(false) { + // Compute optimized field order to be used for layout and initialization + // purposes. + for (int i = 0; i < descriptor_->field_count(); i++) { + if (!descriptor_->field(i)->containing_oneof()) { + optimized_order_.push_back(descriptor_->field(i)); + } + } + OptimizePadding(&optimized_order_); + for (int i = 0; i < descriptor->nested_type_count(); i++) { nested_generators_[i].reset( new MessageGenerator(descriptor->nested_type(i), options)); @@ -644,11 +757,12 @@ GenerateSingularFieldHasBits(const FieldDescriptor* field, " return !$name$_.IsCleared();\n" "}\n"); } else { - printer->Print(vars, - "$inline$" - "bool $classname$::has_$name$() const {\n" - " return !_is_default_instance_ && $name$_ != NULL;\n" - "}\n"); + printer->Print( + vars, + "$inline$" + "bool $classname$::has_$name$() const {\n" + " return this != internal_default_instance() && $name$_ != NULL;\n" + "}\n"); } } } @@ -805,31 +919,6 @@ GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline) { } } -// Helper for the code that emits the Clear() method. -static bool CanClearByZeroing(const FieldDescriptor* field) { - if (field->is_repeated() || field->is_extension()) return false; - switch (field->cpp_type()) { - case internal::WireFormatLite::CPPTYPE_ENUM: - return field->default_value_enum()->number() == 0; - case internal::WireFormatLite::CPPTYPE_INT32: - return field->default_value_int32() == 0; - case internal::WireFormatLite::CPPTYPE_INT64: - return field->default_value_int64() == 0; - case internal::WireFormatLite::CPPTYPE_UINT32: - return field->default_value_uint32() == 0; - case internal::WireFormatLite::CPPTYPE_UINT64: - return field->default_value_uint64() == 0; - case internal::WireFormatLite::CPPTYPE_FLOAT: - return field->default_value_float() == 0; - case internal::WireFormatLite::CPPTYPE_DOUBLE: - return field->default_value_double() == 0; - case internal::WireFormatLite::CPPTYPE_BOOL: - return field->default_value_bool() == false; - default: - return false; - } -} - void MessageGenerator:: GenerateDependentBaseClassDefinition(io::Printer* printer) { if (!use_dependent_base_) { @@ -1009,19 +1098,13 @@ GenerateClassDefinition(io::Printer* printer) { "\n"); } - if (!StaticInitializersForced(descriptor_->file(), options_)) { - printer->Print(vars, - "#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n" - "// Returns the internal default instance pointer. This function can\n" - "// return NULL thus should not be used by the user. This is intended\n" - "// for Protobuf internal code. Please use default_instance() declared\n" - "// above instead.\n" + // TODO(gerbens) make this private, while still granting other protos access. + printer->Print( + vars, "static inline const $classname$* internal_default_instance() {\n" - " return default_instance_;\n" + " return &default_instance_.get();\n" "}\n" - "#endif\n" "\n"); - } if (SupportsArenas(descriptor_)) { @@ -1068,7 +1151,7 @@ GenerateClassDefinition(io::Printer* printer) { "void Clear();\n" "bool IsInitialized() const;\n" "\n" - "int ByteSize() const;\n" + "size_t ByteSizeLong() const;\n" "bool MergePartialFromCodedStream(\n" " ::google::protobuf::io::CodedInputStream* input);\n" "void SerializeWithCachedSizes(\n" @@ -1131,7 +1214,8 @@ GenerateClassDefinition(io::Printer* printer) { "void SharedCtor();\n" "void SharedDtor();\n" "void SetCachedSize(int size) const;\n" - "void InternalSwap($classname$* other);\n", + "void InternalSwap($classname$* other);\n" + "void UnsafeMergeFrom(const $classname$& from);\n", "classname", classname_); if (SupportsArenas(descriptor_)) { printer->Print( @@ -1260,8 +1344,8 @@ GenerateClassDefinition(io::Printer* printer) { !descriptor_->options().message_set_wire_format() && num_required_fields_ > 1) { printer->Print( - "// helper for ByteSize()\n" - "int RequiredFieldsByteSizeFallback() const;\n\n"); + "// helper for ByteSizeLong()\n" + "size_t RequiredFieldsByteSizeFallback() const;\n\n"); } // Prepare decls for _cached_size_ and _has_bits_. Their position in the @@ -1271,18 +1355,10 @@ GenerateClassDefinition(io::Printer* printer) { // TODO(kenton): Make _cached_size_ an atomic<int> when C++ supports it. const string cached_size_decl = "mutable int _cached_size_;\n"; - // TODO(jieluo) - Optimize _has_bits_ for repeated and oneof fields. - size_t sizeof_has_bits = (descriptor_->field_count() + 31) / 32 * 4; - if (descriptor_->field_count() == 0) { - // Zero-size arrays aren't technically allowed, and MSVC in particular - // doesn't like them. We still need to declare these arrays to make - // other code compile. Since this is an uncommon case, we'll just declare - // them with size 1 and waste some space. Oh well. - sizeof_has_bits = 4; - } + const size_t sizeof_has_bits = HasBitsSize(descriptor_); const string has_bits_decl = sizeof_has_bits == 0 ? "" : - "::google::protobuf::uint32 _has_bits_[" + SimpleItoa(sizeof_has_bits / 4) + "];\n"; - + "::google::protobuf::internal::HasBits<" + SimpleItoa(sizeof_has_bits / 4) + + "> _has_bits_;\n"; // To minimize padding, data members are divided into three sections: // (1) members assumed to align to 8 bytes @@ -1326,45 +1402,27 @@ GenerateClassDefinition(io::Printer* printer) { printer->Print(cached_size_decl.c_str()); need_to_emit_cached_size = false; } - } else { - // Without field presence, we need another way to disambiguate the default - // instance, because the default instance's submessage fields (if any) store - // pointers to the default instances of the submessages even when they - // aren't present. Alternatives to this approach might be to (i) use a - // tagged pointer on all message fields, setting a tag bit for "not really - // present, just default instance"; or (ii) comparing |this| against the - // return value from GeneratedMessageFactory::GetPrototype() in all - // has_$field$() calls. However, both of these options are much more - // expensive (in code size and CPU overhead) than just checking a field in - // the message. Long-term, the best solution would be to rearchitect the - // default instance design not to store pointers to submessage default - // instances, and have reflection get those some other way; but that change - // would have too much impact on proto2. - printer->Print( - "bool _is_default_instance_;\n"); } // Field members: // List fields which doesn't belong to any oneof - vector<const FieldDescriptor*> fields; hash_map<string, int> fieldname_to_chunk; for (int i = 0; i < descriptor_->field_count(); i++) { if (!descriptor_->field(i)->containing_oneof()) { const FieldDescriptor* field = descriptor_->field(i); - fields.push_back(field); fieldname_to_chunk[FieldName(field)] = i / 8; } } - OptimizePadding(&fields); + // Emit some private and static members runs_of_fields_ = vector< vector<string> >(1); - for (int i = 0; i < fields.size(); ++i) { - const FieldDescriptor* field = fields[i]; + for (int i = 0; i < optimized_order_.size(); ++i) { + const FieldDescriptor* field = optimized_order_[i]; const FieldGenerator& generator = field_generators_.get(field); generator.GenerateStaticMembers(printer); generator.GeneratePrivateMembers(printer); - if (CanClearByZeroing(field)) { + if (CanInitializeByZeroing(field)) { const string& fieldname = FieldName(field); if (!runs_of_fields_.back().empty() && (fieldname_to_chunk[runs_of_fields_.back().back()] != @@ -1424,15 +1482,15 @@ GenerateClassDefinition(io::Printer* printer) { // Declare AddDescriptors(), BuildDescriptors(), and ShutdownFile() as // friends so that they can access private static variables like // default_instance_ and reflection_. - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - "friend void $dllexport_decl$ $adddescriptorsname$();\n", - // Without. - "friend void $dllexport_decl$ $adddescriptorsname$_impl();\n", - // Vars. - "dllexport_decl", options_.dllexport_decl, "adddescriptorsname", - GlobalAddDescriptorsName(descriptor_->file()->name())); + printer->Print("friend void $dllexport_decl$ $initdefaultsname$_impl();\n", + // Vars. + "dllexport_decl", options_.dllexport_decl, "initdefaultsname", + GlobalInitDefaultsName(descriptor_->file()->name())); + printer->Print("friend void $dllexport_decl$ $adddescriptorsname$_impl();\n", + // Vars. + "dllexport_decl", options_.dllexport_decl, + "adddescriptorsname", + GlobalAddDescriptorsName(descriptor_->file()->name())); printer->Print( "friend void $assigndescriptorsname$();\n" @@ -1443,12 +1501,12 @@ GenerateClassDefinition(io::Printer* printer) { "shutdownfilename", GlobalShutdownFileName(descriptor_->file()->name())); printer->Print( - "void InitAsDefaultInstance();\n" - "static $classname$* default_instance_;\n", - "classname", classname_); + "void InitAsDefaultInstance();\n" + "static ::google::protobuf::internal::ExplicitlyConstructed<$classname$> default_instance_;\n", + "classname", classname_); printer->Outdent(); - printer->Print(vars, "};"); + printer->Print("};"); GOOGLE_DCHECK(!need_to_emit_cached_size); } @@ -1578,18 +1636,18 @@ GenerateDescriptorInitializer(io::Printer* printer, int index) { "::NewGeneratedMessageReflection"; // Construct the reflection object. printer->Print(vars, - "$classname$_reflection_ =\n" - " $fn$(\n" - " $classname$_descriptor_,\n" - " $classname$::default_instance_,\n" - " $classname$_offsets_,\n"); + "$classname$_reflection_ =\n" + " $fn$(\n" + " $classname$_descriptor_,\n" + " $classname$::internal_default_instance(),\n" + " $classname$_offsets_,\n"); if (!HasFieldPresence(descriptor_->file())) { // If we don't have field presence, then _has_bits_ does not exist. printer->Print(vars, " -1,\n"); } else { printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _has_bits_[0]),\n"); + " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _has_bits_),\n"); } // Unknown field offset: either points to the unknown field set if embedded @@ -1637,22 +1695,12 @@ GenerateDescriptorInitializer(io::Printer* printer, int index) { // not (because e.g. we don't have an unknown field set). if (UseUnknownFieldSet(descriptor_->file(), options_)) { printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _internal_metadata_),\n"); + " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" + "$classname$, _internal_metadata_));\n"); } else { printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _arena_),\n"); - } - - // is_default_instance_ offset. - if (HasFieldPresence(descriptor_->file())) { - printer->Print(vars, - " -1);\n"); - } else { - printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _is_default_instance_));\n"); + " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" + "$classname$, _arena_));\n"); } // Handle nested types. @@ -1670,11 +1718,11 @@ GenerateTypeRegistrations(io::Printer* printer) { // Register this message type with the message factory. if (!IsMapEntryMessage(descriptor_)) { printer->Print( - "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n" - " $classname$_descriptor_, &$classname$::default_instance());\n", - "classname", classname_); - } - else { + "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n" + " $classname$_descriptor_, " + "$classname$::internal_default_instance());\n", + "classname", classname_); + } else { map<string, string> vars; CollectMapInfo(descriptor_, &vars); vars["classname"] = classname_; @@ -1708,6 +1756,12 @@ GenerateTypeRegistrations(io::Printer* printer) { void MessageGenerator:: GenerateDefaultInstanceAllocator(io::Printer* printer) { + // Force initialization of primitive values we depend on. + printer->Print( + StrCat( + uses_string_ ? "::google::protobuf::internal::GetEmptyString();\n" : "") + .c_str()); + // Construct the default instances of all fields, as they will be used // when creating the default instance of the entire message. for (int i = 0; i < descriptor_->field_count(); i++) { @@ -1720,9 +1774,8 @@ GenerateDefaultInstanceAllocator(io::Printer* printer) { // Construct the default instance. We can't call InitAsDefaultInstance() yet // because we need to make sure all default instances that this one might // depend on are constructed first. - printer->Print( - "$classname$::default_instance_ = new $classname$();\n", - "classname", classname_); + printer->Print("$classname$::default_instance_.DefaultConstruct();\n", + "classname", classname_); if ((descriptor_->oneof_decl_count() > 0) && HasDescriptorMethods(descriptor_->file(), options_)) { @@ -1741,8 +1794,9 @@ GenerateDefaultInstanceAllocator(io::Printer* printer) { void MessageGenerator:: GenerateDefaultInstanceInitializer(io::Printer* printer) { printer->Print( - "$classname$::default_instance_->InitAsDefaultInstance();\n", - "classname", classname_); + "$classname$::default_instance_.get_mutable()->InitAsDefaultInstance();" + "\n", + "classname", classname_); // Register extensions. for (int i = 0; i < descriptor_->extension_count(); i++) { @@ -1761,10 +1815,6 @@ GenerateDefaultInstanceInitializer(io::Printer* printer) { void MessageGenerator:: GenerateShutdownCode(io::Printer* printer) { - printer->Print( - "delete $classname$::default_instance_;\n", - "classname", classname_); - if (HasDescriptorMethods(descriptor_->file(), options_)) { if (descriptor_->oneof_decl_count() > 0) { printer->Print( @@ -1894,6 +1944,12 @@ GenerateClassMethods(io::Printer* printer) { GenerateIsInitialized(printer); printer->Print("\n"); + } else { + printer->Print( + "void $classname$::UnsafeMergeFrom(const $classname$& from) {\n" + " MergeFrom(from);\n" + "}\n", + "classname", classname_); } GenerateSwap(printer); @@ -1966,15 +2022,15 @@ GenerateSharedConstructorCode(io::Printer* printer) { "classname", classname_); printer->Indent(); - if (!HasFieldPresence(descriptor_->file())) { - printer->Print( - " _is_default_instance_ = false;\n"); + bool need_to_clear_cached_size = true; + // We reproduce the logic used for laying out _cached_sized_ in the class + // definition, as to initialize it in-order. + if (HasFieldPresence(descriptor_->file()) && + (HasBitsSize(descriptor_) % 8) != 0) { + printer->Print("_cached_size_ = 0;\n"); + need_to_clear_cached_size = false; } - printer->Print(StrCat( - uses_string_ ? "::google::protobuf::internal::GetEmptyString();\n" : "", - "_cached_size_ = 0;\n").c_str()); - if (PreserveUnknownFields(descriptor_) && !UseUnknownFieldSet(descriptor_->file(), options_)) { printer->Print( @@ -1982,16 +2038,52 @@ GenerateSharedConstructorCode(io::Printer* printer) { " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n"); } - for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->containing_oneof()) { - field_generators_.get(descriptor_->field(i)) - .GenerateConstructorCode(printer); + const FieldDescriptor* last_start = NULL; + // RunMap maps from fields that start each run to the number of fields in that + // run. This is optimized for the common case that there are very few runs in + // a message and that most of the eligible fields appear together. + typedef hash_map<const FieldDescriptor*, size_t> RunMap; + RunMap runs; + + for (int i = 0; i < optimized_order_.size(); ++i) { + const FieldDescriptor* field = optimized_order_[i]; + // TODO(ckennelly): Scalar messages (raw pointers) can be initialized by + // zero as well. + if (CanInitializeByZeroing(field)) { + if (last_start == NULL) { + last_start = field; + } + + runs[last_start]++; + } else { + last_start = NULL; } } - if (HasFieldPresence(descriptor_->file())) { - printer->Print( - "::memset(_has_bits_, 0, sizeof(_has_bits_));\n"); + for (int i = 0; i < optimized_order_.size(); ++i) { + const FieldDescriptor* field = optimized_order_[i]; + RunMap::const_iterator it = runs.find(field); + + // We only apply the memset technique to runs of more than one field, as + // assignment is better than memset for generated code clarity. + if (it != runs.end() && it->second > 1) { + // Use a memset, then skip run_length fields. + const size_t run_length = it->second; + const string first_field_name = FieldName(field); + const string last_field_name = + FieldName(optimized_order_[i + run_length - 1]); + + printer->Print( + "::memset(&$first$_, 0, reinterpret_cast<char*>(&$last$_) -\n" + " reinterpret_cast<char*>(&$first$_) + sizeof($last$_));\n", + "first", first_field_name, + "last", last_field_name); + + i += run_length - 1; + // ++i at the top of the loop. + } else { + field_generators_.get(field).GenerateConstructorCode(printer); + } } for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { @@ -2000,6 +2092,10 @@ GenerateSharedConstructorCode(io::Printer* printer) { "oneof_name", descriptor_->oneof_decl(i)->name()); } + if (need_to_clear_cached_size) { + printer->Print("_cached_size_ = 0;\n"); + } + printer->Outdent(); printer->Print("}\n\n"); } @@ -2013,7 +2109,8 @@ GenerateSharedDestructorCode(io::Printer* printer) { if (SupportsArenas(descriptor_)) { // Do nothing when the message is allocated in an arena. printer->Print( - "if (GetArenaNoVirtual() != NULL) {\n" + "::google::protobuf::Arena* arena = GetArenaNoVirtual();\n" + "if (arena != NULL) {\n" " return;\n" "}\n" "\n"); @@ -2026,7 +2123,7 @@ GenerateSharedDestructorCode(io::Printer* printer) { printer->Print( "_unknown_fields_.Destroy(\n" " &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n" - " GetArenaNoVirtual());\n"); + " arena);\n"); } else { printer->Print( "_unknown_fields_.DestroyNoArena(\n" @@ -2035,11 +2132,10 @@ GenerateSharedDestructorCode(io::Printer* printer) { } // Write the destructors for each field except oneof members. - for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->containing_oneof()) { - field_generators_.get(descriptor_->field(i)) - .GenerateDestructorCode(printer); - } + // optimized_order_ does not contain oneof fields. + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + field_generators_.get(field).GenerateDestructorCode(printer); } // Generate code to destruct oneofs. Clearing should do the work. @@ -2051,13 +2147,6 @@ GenerateSharedDestructorCode(io::Printer* printer) { "oneof_name", descriptor_->oneof_decl(i)->name()); } - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - "if (this != default_instance_) {\n", - // Without. - "if (this != &default_instance()) {\n"); - // We need to delete all embedded messages. // TODO(kenton): If we make unset messages point at default instances // instead of NULL, then it would make sense to move this code into @@ -2069,16 +2158,13 @@ GenerateSharedDestructorCode(io::Printer* printer) { field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { // Skip oneof members if (!field->containing_oneof()) { - printer->Print( - " delete $name$_;\n", - "name", FieldName(field)); + printer->Print("delete $name$_;\n", "name", FieldName(field)); } } } printer->Outdent(); printer->Print( - " }\n" "}\n" "\n"); } @@ -2151,16 +2237,18 @@ GenerateStructors(io::Printer* printer) { } // Initialize member variables with arena constructor. - for (int i = 0; i < descriptor_->field_count(); i++) { - bool has_arena_constructor = descriptor_->field(i)->is_repeated(); + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + + bool has_arena_constructor = field->is_repeated(); if (has_arena_constructor) { initializer_with_arena += string(",\n ") + - FieldName(descriptor_->field(i)) + string("_(arena)"); + FieldName(field) + string("_(arena)"); } } if (IsAnyMessage(descriptor_)) { - initializer_with_arena += ",\n _any_metadata_(&type_url, &value_)"; + initializer_with_arena += ",\n _any_metadata_(&type_url_, &value_)"; } string initializer_null; @@ -2173,27 +2261,31 @@ GenerateStructors(io::Printer* printer) { printer->Print( "$classname$::$classname$()\n" " : $superclass$()$initializer$ {\n" + " if (this != internal_default_instance()) $initdefaultsname$();\n" " SharedCtor();\n" " // @@protoc_insertion_point(constructor:$full_name$)\n" "}\n", - "classname", classname_, - "superclass", superclass, - "full_name", descriptor_->full_name(), - "initializer", initializer_null); + "classname", classname_, "superclass", superclass, "full_name", + descriptor_->full_name(), "initializer", initializer_null, + "initdefaultsname", GlobalInitDefaultsName(descriptor_->file()->name())); if (SupportsArenas(descriptor_)) { printer->Print( - "\n" "$classname$::$classname$(::google::protobuf::Arena* arena)\n" " : $initializer$ {\n" + // When arenas are used it's safe to assume we have finished + // static init time (protos with arenas are unsafe during static init) + "#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n" + " $initdefaultsname$();\n" + "#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n" " SharedCtor();\n" " RegisterArenaDtor(arena);\n" " // @@protoc_insertion_point(arena_constructor:$full_name$)\n" "}\n", - "initializer", initializer_with_arena, - "classname", classname_, - "superclass", superclass, - "full_name", descriptor_->full_name()); + "initializer", initializer_with_arena, "classname", classname_, + "superclass", superclass, "full_name", descriptor_->full_name(), + "initdefaultsname", + GlobalInitDefaultsName(descriptor_->file()->name())); } printer->Print( @@ -2201,11 +2293,6 @@ GenerateStructors(io::Printer* printer) { "void $classname$::InitAsDefaultInstance() {\n", "classname", classname_); - if (!HasFieldPresence(descriptor_->file())) { - printer->Print( - " _is_default_instance_ = true;\n"); - } - // The default instance needs all of its embedded message pointers // cross-linked to other default instances. We can't do this initialization // in the constructor because some other default instances may not have been @@ -2224,11 +2311,7 @@ GenerateStructors(io::Printer* printer) { name = classname_ + "_default_oneof_instance_->"; } name += FieldName(field); - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - " $name$_ = const_cast< $type$*>(&$type$::default_instance());\n", - // Without. + printer->Print( " $name$_ = const_cast< $type$*>(\n" " $type$::internal_default_instance());\n", // Vars. @@ -2262,7 +2345,7 @@ GenerateStructors(io::Printer* printer) { printer->Print(" {\n"); printer->Print( " SharedCtor();\n" - " MergeFrom(from);\n" + " UnsafeMergeFrom(from);\n" " // @@protoc_insertion_point(copy_constructor:$full_name$)\n" "}\n" "\n", @@ -2304,37 +2387,29 @@ GenerateStructors(io::Printer* printer) { if (HasDescriptorMethods(descriptor_->file(), options_) && !descriptor_->options().no_standard_descriptor_accessor()) { printer->Print( - "const ::google::protobuf::Descriptor* $classname$::descriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" - "}\n" - "\n", - "classname", classname_, - "adddescriptorsname", - GlobalAddDescriptorsName(descriptor_->file()->name())); + "const ::google::protobuf::Descriptor* $classname$::descriptor() {\n" + " protobuf_AssignDescriptorsOnce();\n" + " return $classname$_descriptor_;\n" + "}\n" + "\n", + "classname", classname_, "initdefaultsname", + GlobalInitDefaultsName(descriptor_->file()->name())); } printer->Print( - "const $classname$& $classname$::default_instance() {\n", - "classname", classname_); - - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - " if (default_instance_ == NULL) $adddescriptorsname$();\n", - // Without. - " $adddescriptorsname$();\n", - // Vars. - "adddescriptorsname", - GlobalAddDescriptorsName(descriptor_->file()->name())); + "const $classname$& $classname$::default_instance() {\n" + " $initdefaultsname$();\n" + " return *internal_default_instance();\n" + "}\n", + "classname", classname_, "initdefaultsname", + GlobalInitDefaultsName(descriptor_->file()->name())); printer->Print( - " return *default_instance_;\n" - "}\n" - "\n" - "$classname$* $classname$::default_instance_ = NULL;\n" - "\n", - "classname", classname_); + "\n" + "::google::protobuf::internal::ExplicitlyConstructed<$classname$> " + "$classname$::default_instance_;\n" + "\n", + "classname", classname_); if (SupportsArenas(descriptor_)) { printer->Print( @@ -2463,7 +2538,7 @@ GenerateClear(io::Printer* printer) { int count = popcnt(mask); GOOGLE_DCHECK_GE(count, 1); if (count == 1 || - (count <= 4 && count == memset_field_count_for_chunk[i / 8])) { + count == memset_field_count_for_chunk[i / 8]) { // No "if" here because the chunk is trivial. } else { if (HasFieldPresence(descriptor_->file())) { @@ -2540,8 +2615,7 @@ GenerateClear(io::Printer* printer) { if (HasFieldPresence(descriptor_->file())) { // Step 5: Everything else. - printer->Print( - "::memset(_has_bits_, 0, sizeof(_has_bits_));\n"); + printer->Print("_has_bits_.Clear();\n"); } if (PreserveUnknownFields(descriptor_)) { @@ -2584,7 +2658,7 @@ GenerateOneofClear(io::Printer* printer) { "$full_name$)\n"); printer->Indent(); printer->Print(oneof_vars, - "switch($oneofname$_case()) {\n"); + "switch ($oneofname$_case()) {\n"); printer->Indent(); for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); @@ -2639,7 +2713,7 @@ GenerateSwap(io::Printer* printer) { " InternalSwap(other);\n" " } else {\n" " $classname$ temp;\n" - " temp.MergeFrom(*this);\n" + " temp.UnsafeMergeFrom(*this);\n" " CopyFrom(*other);\n" " other->CopyFrom(temp);\n" " }\n" @@ -2715,9 +2789,7 @@ GenerateMergeFrom(io::Printer* printer) { "void $classname$::MergeFrom(const ::google::protobuf::Message& from) {\n" "// @@protoc_insertion_point(generalized_merge_from_start:" "$full_name$)\n" - " if (GOOGLE_PREDICT_FALSE(&from == this)) {\n" - " ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n" - " }\n", + " if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);\n", "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); @@ -2726,7 +2798,7 @@ GenerateMergeFrom(io::Printer* printer) { // system, as the GOOGLE_CHECK above ensured that we have the same descriptor // for each message. printer->Print( - "const $classname$* source = \n" + "const $classname$* source =\n" " ::google::protobuf::internal::DynamicCastToGenerated<const $classname$>(\n" " &from);\n" "if (source == NULL) {\n" @@ -2736,7 +2808,7 @@ GenerateMergeFrom(io::Printer* printer) { "} else {\n" "// @@protoc_insertion_point(generalized_merge_from_cast_success:" "$full_name$)\n" - " MergeFrom(*source);\n" + " UnsafeMergeFrom(*source);\n" "}\n", "classname", classname_, "full_name", descriptor_->full_name()); @@ -2758,9 +2830,15 @@ GenerateMergeFrom(io::Printer* printer) { "void $classname$::MergeFrom(const $classname$& from) {\n" "// @@protoc_insertion_point(class_specific_merge_from_start:" "$full_name$)\n" - " if (GOOGLE_PREDICT_FALSE(&from == this)) {\n" - " ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n" - " }\n", + " if (GOOGLE_PREDICT_TRUE(&from != this)) {\n" + " UnsafeMergeFrom(from);\n" + " } else {\n" + " MergeFromFail(__LINE__);\n" + " }\n" + "}\n" + "\n" + "void $classname$::UnsafeMergeFrom(const $classname$& from) {\n" + " GOOGLE_DCHECK(&from != this);\n", "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); @@ -2770,7 +2848,7 @@ GenerateMergeFrom(io::Printer* printer) { const FieldDescriptor* field = descriptor_->field(i); if (field->is_repeated()) { - field_generators_.get(field).GenerateMergingCode(printer); + field_generators_.get(field).GenerateUnsafeMergingCode(printer); } } @@ -2865,7 +2943,8 @@ GenerateMergeFrom(io::Printer* printer) { if (UseUnknownFieldSet(descriptor_->file(), options_)) { printer->Print( "if (from._internal_metadata_.have_unknown_fields()) {\n" - " mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n" + " ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(\n" + " from.unknown_fields(), &_internal_metadata_);\n" "}\n"); } else { printer->Print( @@ -2911,7 +2990,7 @@ GenerateCopyFrom(io::Printer* printer) { printer->Print( "if (&from == this) return;\n" "Clear();\n" - "MergeFrom(from);\n"); + "UnsafeMergeFrom(from);\n"); printer->Outdent(); printer->Print("}\n"); @@ -2926,13 +3005,9 @@ GenerateMergeFromCodedStream(io::Printer* printer) { " ::google::protobuf::io::CodedInputStream* input) {\n", "classname", classname_); - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - " return _extensions_.ParseMessageSet(input, default_instance_,\n" - " mutable_unknown_fields());\n", - // Without. - " return _extensions_.ParseMessageSet(input, &default_instance(),\n" + printer->Print( + " return _extensions_.ParseMessageSet(input, " + "internal_default_instance(),\n" " mutable_unknown_fields());\n", // Vars. "classname", classname_); @@ -2971,8 +3046,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) { printer->Print("for (;;) {\n"); printer->Indent(); - google::protobuf::scoped_array<const FieldDescriptor * > ordered_fields( - SortFieldsByNumber(descriptor_)); + std::vector<const FieldDescriptor*> ordered_fields = + SortFieldsByNumber(descriptor_); uint32 maxtag = descriptor_->field_count() == 0 ? 0 : WireFormat::MakeTag(ordered_fields[descriptor_->field_count() - 1]); const int kCutoff0 = 127; // fits in 1-byte varint @@ -3000,7 +3075,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { // Find repeated messages and groups now, to simplify what follows. hash_set<int> fields_with_parse_loop; - for (int i = 0; i < descriptor_->field_count(); i++) { + for (int i = 0; i < ordered_fields.size(); i++) { const FieldDescriptor* field = ordered_fields[i]; if (field->is_repeated() && (field->type() == FieldDescriptor::TYPE_MESSAGE || @@ -3012,7 +3087,13 @@ GenerateMergeFromCodedStream(io::Printer* printer) { // need_label is true if we generated "goto parse_$name$" while handling the // previous field. bool need_label = false; - for (int i = 0; i < descriptor_->field_count(); i++) { + // Pay attention to whether we are in a run of fields from the same oneof. + // Motivation: it would be unusual to parse multiple values for a single + // oneof, since only the last would be used. + const FieldDescriptor* last_of_current_oneof = NULL; + // The following is valid iff last_of_current_oneof is non-NULL. + int index_of_last_of_current_oneof = -1; + for (int i = 0; i < ordered_fields.size(); i++) { const FieldDescriptor* field = ordered_fields[i]; const bool loops = fields_with_parse_loop.count(i) > 0; const bool next_field_loops = fields_with_parse_loop.count(i + 1) > 0; @@ -3111,21 +3192,53 @@ GenerateMergeFromCodedStream(io::Printer* printer) { "input->UnsafeDecrementRecursionDepth();\n"); } - // If there are more fields, expect the next one. + // If there are more fields, expect the next one, unless we just parsed + // a oneof and the next field would be from the same oneof. (There's no + // reason to expect something that makes what we just read irrelevant, + // so guess something after the current string of fields from this oneof.) need_label = false; if (!emitted_goto_next_tag) { - if (i + 1 == descriptor_->field_count()) { + // delta is the distance in ordered_fields[] from the current field to + // the field we'll guess is next. + int delta = last_of_current_oneof == NULL + ? 1 + : std::max(index_of_last_of_current_oneof - i, 1); + if (i == index_of_last_of_current_oneof) { + printer->Outdent(); + printer->Print( + " after_$last$:\n", + "last", FieldName(last_of_current_oneof)); + printer->Indent(); + last_of_current_oneof = NULL; + } else if (last_of_current_oneof == NULL) { + delta = 1; + // Check for the unlikely case that delta > 1 is better. + if (field->containing_oneof() != NULL) { + while (i + delta < ordered_fields.size() && + ordered_fields[i + delta]->containing_oneof() == + field->containing_oneof()) { + index_of_last_of_current_oneof = i + delta; + last_of_current_oneof = ordered_fields[i + delta]; + ++delta; + } + } + } + if (delta > 1) { + printer->Print( + "goto after_$last$;\n", + "last", FieldName(last_of_current_oneof)); + } else if (i + delta == descriptor_->field_count()) { // Expect EOF. // TODO(kenton): Expect group end-tag? printer->Print( "if (input->ExpectAtEnd()) goto success;\n"); } else { - const FieldDescriptor* next_field = ordered_fields[i + 1]; + const FieldDescriptor* next_field = ordered_fields[i + delta]; printer->Print( "if (input->ExpectTag($next_tag$)) goto parse_$next_name$;\n", "next_tag", SimpleItoa(WireFormat::MakeTag(next_field)), "next_name", next_field->name()); - need_label = true; + need_label = delta == 1; } } @@ -3179,31 +3292,21 @@ GenerateMergeFromCodedStream(io::Printer* printer) { printer->Print(") {\n"); if (PreserveUnknownFields(descriptor_)) { if (UseUnknownFieldSet(descriptor_->file(), options_)) { - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - " DO_(_extensions_.ParseField(tag, input, default_instance_,\n" - " mutable_unknown_fields()));\n", - // Without. - " DO_(_extensions_.ParseField(tag, input, &default_instance(),\n" + printer->Print( + " DO_(_extensions_.ParseField(tag, input, " + "internal_default_instance(),\n" " mutable_unknown_fields()));\n"); } else { - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - " DO_(_extensions_.ParseField(tag, input, default_instance_,\n" - " &unknown_fields_stream));\n", - // Without. - " DO_(_extensions_.ParseField(tag, input, &default_instance(),\n" + printer->Print( + " DO_(_extensions_.ParseField(tag, input, " + "internal_default_instance(),\n" " &unknown_fields_stream));\n"); } } else { - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, + printer->Print( // With static initializers. - " DO_(_extensions_.ParseField(tag, input, default_instance_);\n", - // Without. - " DO_(_extensions_.ParseField(tag, input, &default_instance());\n"); + " DO_(_extensions_.ParseField(tag, input, " + "internal_default_instance());\n"); } printer->Print( " continue;\n" @@ -3248,6 +3351,43 @@ GenerateMergeFromCodedStream(io::Printer* printer) { "}\n", "full_name", descriptor_->full_name()); } +void MessageGenerator::GenerateSerializeOneofFields( + io::Printer* printer, const vector<const FieldDescriptor*>& fields, + bool to_array) { + GOOGLE_CHECK(!fields.empty()); + if (fields.size() == 1) { + GenerateSerializeOneField(printer, fields[0], to_array); + return; + } + // We have multiple mutually exclusive choices. Emit a switch statement. + const OneofDescriptor* oneof = fields[0]->containing_oneof(); + printer->Print( + "switch ($oneofname$_case()) {\n", + "oneofname", oneof->name()); + printer->Indent(); + for (int i = 0; i < fields.size(); i++) { + const FieldDescriptor* field = fields[i]; + printer->Print( + "case k$field_name$:\n", + "field_name", UnderscoresToCamelCase(field->name(), true)); + printer->Indent(); + if (to_array) { + field_generators_.get(field).GenerateSerializeWithCachedSizesToArray( + printer); + } else { + field_generators_.get(field).GenerateSerializeWithCachedSizes(printer); + } + printer->Print( + "break;\n"); + printer->Outdent(); + } + printer->Outdent(); + // Doing nothing is an option. + printer->Print( + " default: ;\n" + "}\n"); +} + void MessageGenerator::GenerateSerializeOneField( io::Printer* printer, const FieldDescriptor* field, bool to_array) { PrintFieldComment(printer, field); @@ -3382,10 +3522,61 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) { void MessageGenerator:: GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) { - google::protobuf::scoped_array<const FieldDescriptor * > ordered_fields( - SortFieldsByNumber(descriptor_)); + // If there are multiple fields in a row from the same oneof then we + // coalesce them and emit a switch statement. This is more efficient + // because it lets the C++ compiler know this is a "at most one can happen" + // situation. If we emitted "if (has_x()) ...; if (has_y()) ..." the C++ + // compiler's emitted code might check has_y() even when has_x() is true. + class LazySerializerEmitter { + public: + LazySerializerEmitter(MessageGenerator* mg, io::Printer* printer, + bool to_array) + : mg_(mg), + printer_(printer), + to_array_(to_array), + eager_(!HasFieldPresence(mg->descriptor_->file())) {} + + ~LazySerializerEmitter() { Flush(); } + + // If conditions allow, try to accumulate a run of fields from the same + // oneof, and handle them at the next Flush(). + void Emit(const FieldDescriptor* field) { + if (eager_ || MustFlush(field)) { + Flush(); + } + if (field->containing_oneof() == NULL) { + mg_->GenerateSerializeOneField(printer_, field, to_array_); + } else { + v_.push_back(field); + } + } - vector<const Descriptor::ExtensionRange*> sorted_extensions; + void Flush() { + if (!v_.empty()) { + mg_->GenerateSerializeOneofFields(printer_, v_, to_array_); + v_.clear(); + } + } + + private: + // If we have multiple fields in v_ then they all must be from the same + // oneof. Would adding field to v_ break that invariant? + bool MustFlush(const FieldDescriptor* field) { + return !v_.empty() && + v_[0]->containing_oneof() != field->containing_oneof(); + } + + MessageGenerator* mg_; + io::Printer* printer_; + const bool to_array_; + const bool eager_; + vector<const FieldDescriptor*> v_; + }; + + std::vector<const FieldDescriptor*> ordered_fields = + SortFieldsByNumber(descriptor_); + + std::vector<const Descriptor::ExtensionRange*> sorted_extensions; for (int i = 0; i < descriptor_->extension_range_count(); ++i) { sorted_extensions.push_back(descriptor_->extension_range(i)); } @@ -3393,22 +3584,26 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) { ExtensionRangeSorter()); // Merge the fields and the extension ranges, both sorted by field number. - int i, j; - for (i = 0, j = 0; - i < descriptor_->field_count() || j < sorted_extensions.size(); - ) { - if (i == descriptor_->field_count()) { - GenerateSerializeOneExtensionRange(printer, - sorted_extensions[j++], - to_array); - } else if (j == sorted_extensions.size()) { - GenerateSerializeOneField(printer, ordered_fields[i++], to_array); - } else if (ordered_fields[i]->number() < sorted_extensions[j]->start) { - GenerateSerializeOneField(printer, ordered_fields[i++], to_array); - } else { - GenerateSerializeOneExtensionRange(printer, - sorted_extensions[j++], - to_array); + { + LazySerializerEmitter e(this, printer, to_array); + int i, j; + for (i = 0, j = 0; + i < ordered_fields.size() || j < sorted_extensions.size();) { + if (i == descriptor_->field_count()) { + e.Flush(); + GenerateSerializeOneExtensionRange(printer, + sorted_extensions[j++], + to_array); + } else if (j == sorted_extensions.size()) { + e.Emit(ordered_fields[i++]); + } else if (ordered_fields[i]->number() < sorted_extensions[j]->start) { + e.Emit(ordered_fields[i++]); + } else { + e.Flush(); + GenerateSerializeOneExtensionRange(printer, + sorted_extensions[j++], + to_array); + } } } @@ -3480,9 +3675,9 @@ GenerateByteSize(io::Printer* printer) { if (descriptor_->options().message_set_wire_format()) { // Special-case MessageSet. printer->Print( - "int $classname$::ByteSize() const {\n" + "size_t $classname$::ByteSizeLong() const {\n" "// @@protoc_insertion_point(message_set_byte_size_start:$full_name$)\n" - " int total_size = _extensions_.MessageSetByteSize();\n", + " size_t total_size = _extensions_.MessageSetByteSize();\n", "classname", classname_, "full_name", descriptor_->full_name()); GOOGLE_CHECK(UseUnknownFieldSet(descriptor_->file(), options_)); printer->Print( @@ -3491,8 +3686,9 @@ GenerateByteSize(io::Printer* printer) { " ComputeUnknownMessageSetItemsSize(unknown_fields());\n" "}\n"); printer->Print( + " int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);\n" " GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" - " _cached_size_ = total_size;\n" + " _cached_size_ = cached_size;\n" " GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" " return total_size;\n" "}\n"); @@ -3503,12 +3699,12 @@ GenerateByteSize(io::Printer* printer) { // Emit a function (rarely used, we hope) that handles the required fields // by checking for each one individually. printer->Print( - "int $classname$::RequiredFieldsByteSizeFallback() const {\n" + "size_t $classname$::RequiredFieldsByteSizeFallback() const {\n" "// @@protoc_insertion_point(required_fields_byte_size_fallback_start:" "$full_name$)\n", "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); - printer->Print("int total_size = 0;\n"); + printer->Print("size_t total_size = 0;\n"); for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); if (field->is_required()) { @@ -3529,12 +3725,12 @@ GenerateByteSize(io::Printer* printer) { } printer->Print( - "int $classname$::ByteSize() const {\n" + "size_t $classname$::ByteSizeLong() const {\n" "// @@protoc_insertion_point(message_byte_size_start:$full_name$)\n", "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); printer->Print( - "int total_size = 0;\n" + "size_t total_size = 0;\n" "\n"); // Handle required fields (if any). We expect all of them to be @@ -3727,8 +3923,9 @@ GenerateByteSize(io::Printer* printer) { // exact same value, it works on all common processors. In a future version // of C++, _cached_size_ should be made into an atomic<int>. printer->Print( + "int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);\n" "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" - "_cached_size_ = total_size;\n" + "_cached_size_ = cached_size;\n" "GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" "return total_size;\n"); @@ -3804,7 +4001,9 @@ GenerateIsInitialized(io::Printer* printer) { if (descriptor_->extension_range_count() > 0) { printer->Print( "\n" - "if (!_extensions_.IsInitialized()) return false;"); + "if (!_extensions_.IsInitialized()) {\n" + " return false;\n" + "}\n"); } printer->Outdent(); diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h index b1e3fe21..3bdc0ed3 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.h +++ b/src/google/protobuf/compiler/cpp/cpp_message.h @@ -165,6 +165,11 @@ class MessageGenerator { void GenerateSerializeOneField(io::Printer* printer, const FieldDescriptor* field, bool unbounded); + // Generate a switch statement to serialize 2+ fields from the same oneof. + // Or, if fields.size() == 1, just call GenerateSerializeOneField(). + void GenerateSerializeOneofFields( + io::Printer* printer, const vector<const FieldDescriptor*>& fields, + bool to_array); void GenerateSerializeOneExtensionRange( io::Printer* printer, const Descriptor::ExtensionRange* range, bool unbounded); @@ -189,6 +194,11 @@ class MessageGenerator { string classname_; Options options_; FieldGeneratorMap field_generators_; + // optimized_order_ is the order we layout the message's fields in the class. + // This is reused to initialize the fields in-order for cache efficiency. + // + // optimized_order_ excludes oneof fields. + vector<const FieldDescriptor *> optimized_order_; vector< vector<string> > runs_of_fields_; // that might be trivially cleared google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > nested_generators_; google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_; diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc index d021035d..ca7bae02 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc @@ -161,8 +161,7 @@ void MessageFieldGenerator::GenerateNonInlineAccessorDefinitions( " if ($name$_ == NULL) {\n" " return NULL;\n" " } else {\n" - " $type$* temp = new $type$;\n" - " temp->MergeFrom(*$name$_);\n" + " $type$* temp = new $type$(*$name$_);\n" " $name$_ = NULL;\n" " return temp;\n" " }\n" @@ -346,23 +345,29 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { void MessageFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { + if (dependent_field_) { + // for dependent fields we cannot access its internal_default_instance, + // because the type is incomplete. + // TODO(gerbens) deprecate dependent base class. + map<string, string> variables(variables_); + variables["inline"] = is_inline ? "inline " : ""; + printer->Print(variables, + "$inline$const $type$& $classname$::$name$() const {\n" + " // @@protoc_insertion_point(field_get:$full_name$)\n" + " return $name$_ != NULL ? *$name$_\n" + " : *internal_default_instance()->$name$_;\n" + "}\n"); + return; + } + map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$const $type$& $classname$::$name$() const {\n" - " // @@protoc_insertion_point(field_get:$full_name$)\n"); - - PrintHandlingOptionalStaticInitializers( - variables, descriptor_->file(), options_, printer, - // With static initializers. - " return $name$_ != NULL ? *$name$_ : *default_instance_->$name$_;\n", - // Without. - " return $name$_ != NULL ? *$name$_ : *default_instance().$name$_;\n"); - printer->Print(variables, "}\n"); - - if (dependent_field_) { - return; - } + " // @@protoc_insertion_point(field_get:$full_name$)\n" + " return $name$_ != NULL ? *$name$_\n" + " : *$type$::internal_default_instance();\n" + "}\n"); if (SupportsArenas(descriptor_)) { printer->Print(variables, @@ -663,8 +668,8 @@ InternalGenerateInlineAccessorDefinitions(const map<string, string>& variables, " if ($this_message$GetArenaNoVirtual() != NULL) {\n" // N.B.: safe to use the underlying field pointer here because we are sure // that it is non-NULL (because has_$name$() returned true). - " $dependent_typename$* temp = new $dependent_typename$;\n" - " temp->MergeFrom(*$field_member$);\n" + " $dependent_typename$* temp = " + "new $dependent_typename$(*$field_member$);\n" " $field_member$ = NULL;\n" " return temp;\n" " } else {\n" @@ -1041,12 +1046,18 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { void RepeatedMessageFieldGenerator:: GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size();\n" - "for (int i = 0; i < this->$name$_size(); i++) {\n" + "{\n" + " unsigned int count = this->$name$_size();\n"); + printer->Indent(); + printer->Print(variables_, + "total_size += $tag_size$UL * count;\n" + "for (unsigned int i = 0; i < count; i++) {\n" " total_size +=\n" " ::google::protobuf::internal::WireFormatLite::$declared_type$SizeNoVirtual(\n" " this->$name$(i));\n" "}\n"); + printer->Outdent(); + printer->Print("}\n"); } } // namespace cpp diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc index 650f0381..54b3d24a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc @@ -123,13 +123,13 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void PrimitiveFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ $type$ $classname$::$name$() const {\n" + "$inline$$type$ $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return $name$_;\n" "}\n" - "$inline$ void $classname$::set_$name$($type$ value) {\n" + "$inline$void $classname$::set_$name$($type$ value) {\n" " $set_hasbit$\n" " $name$_ = value;\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" @@ -159,10 +159,10 @@ GenerateConstructorCode(io::Printer* printer) const { void PrimitiveFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { printer->Print(variables_, + "$set_hasbit$\n" "DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n" " $type$, $wire_format_field_type$>(\n" - " input, &$name$_)));\n" - "$set_hasbit$\n"); + " input, &$name$_)));\n"); } void PrimitiveFieldGenerator:: @@ -207,16 +207,16 @@ PrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {} void PrimitiveOneofFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ $type$ $classname$::$name$() const {\n" + "$inline$$type$ $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " if (has_$name$()) {\n" " return $oneof_prefix$$name$_;\n" " }\n" " return $default$;\n" "}\n" - "$inline$ void $classname$::set_$name$($type$ value) {\n" + "$inline$void $classname$::set_$name$($type$ value) {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" @@ -298,27 +298,27 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void RepeatedPrimitiveFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ $type$ $classname$::$name$(int index) const {\n" + "$inline$$type$ $classname$::$name$(int index) const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return $name$_.Get(index);\n" "}\n" - "$inline$ void $classname$::set_$name$(int index, $type$ value) {\n" + "$inline$void $classname$::set_$name$(int index, $type$ value) {\n" " $name$_.Set(index, value);\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$ void $classname$::add_$name$($type$ value) {\n" + "$inline$void $classname$::add_$name$($type$ value) {\n" " $name$_.Add(value);\n" " // @@protoc_insertion_point(field_add:$full_name$)\n" "}\n"); printer->Print(variables, - "$inline$ const ::google::protobuf::RepeatedField< $type$ >&\n" + "$inline$const ::google::protobuf::RepeatedField< $type$ >&\n" "$classname$::$name$() const {\n" " // @@protoc_insertion_point(field_list:$full_name$)\n" " return $name$_;\n" "}\n" - "$inline$ ::google::protobuf::RepeatedField< $type$ >*\n" + "$inline$::google::protobuf::RepeatedField< $type$ >*\n" "$classname$::mutable_$name$() {\n" " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" " return &$name$_;\n" @@ -336,6 +336,11 @@ GenerateMergingCode(io::Printer* printer) const { } void RepeatedPrimitiveFieldGenerator:: +GenerateUnsafeMergingCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_.UnsafeMergeFrom(from.$name$_);\n"); +} + +void RepeatedPrimitiveFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n"); } @@ -420,18 +425,19 @@ void RepeatedPrimitiveFieldGenerator:: GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, "{\n" - " int data_size = 0;\n"); + " size_t data_size = 0;\n" + " unsigned int count = this->$name$_size();\n"); printer->Indent(); int fixed_size = FixedSize(descriptor_->type()); if (fixed_size == -1) { printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n" + "for (unsigned int i = 0; i < count; i++) {\n" " data_size += ::google::protobuf::internal::WireFormatLite::\n" " $declared_type$Size(this->$name$(i));\n" "}\n"); } else { printer->Print(variables_, - "data_size = $fixed_size$ * this->$name$_size();\n"); + "data_size = $fixed_size$UL * count;\n"); } if (descriptor_->is_packed()) { @@ -440,13 +446,16 @@ GenerateByteSize(io::Printer* printer) const { " total_size += $tag_size$ +\n" " ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n" "}\n" + "int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n" "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" - "_$name$_cached_byte_size_ = data_size;\n" + "_$name$_cached_byte_size_ = cached_size;\n" "GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" "total_size += data_size;\n"); } else { printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size() + data_size;\n"); + "total_size += $tag_size$ *\n" + " ::google::protobuf::internal::FromIntSize(this->$name$_size());\n" + "total_size += data_size;\n"); } printer->Outdent(); printer->Print("}\n"); diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h index 655ebde4..23cc697e 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h @@ -103,6 +103,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { bool is_inline) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; + virtual void GenerateUnsafeMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index 1d743457..aee3d1ea 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -166,25 +166,25 @@ void StringFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; if (SupportsArenas(descriptor_)) { printer->Print(variables, - "$inline$ const ::std::string& $classname$::$name$() const {\n" + "$inline$const ::std::string& $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return $name$_.Get($default_variable$);\n" "}\n" - "$inline$ void $classname$::set_$name$(const ::std::string& value) {\n" + "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" " $set_hasbit$\n" " $name$_.Set($default_variable$, value, GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$ void $classname$::set_$name$(const char* value) {\n" + "$inline$void $classname$::set_$name$(const char* value) {\n" " $set_hasbit$\n" " $name$_.Set($default_variable$, $string_piece$(value),\n" " GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n" - "$inline$ " + "$inline$" "void $classname$::set_$name$(const $pointer_type$* value,\n" " size_t size) {\n" " $set_hasbit$\n" @@ -192,24 +192,24 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " reinterpret_cast<const char*>(value), size), GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$ ::std::string* $classname$::mutable_$name$() {\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" " $set_hasbit$\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n" " return $name$_.Mutable($default_variable$, GetArenaNoVirtual());\n" "}\n" - "$inline$ ::std::string* $classname$::$release_name$() {\n" + "$inline$::std::string* $classname$::$release_name$() {\n" " // @@protoc_insertion_point(field_release:$full_name$)\n" " $clear_hasbit$\n" " return $name$_.Release($default_variable$, GetArenaNoVirtual());\n" "}\n" - "$inline$ ::std::string* $classname$::unsafe_arena_release_$name$() {\n" + "$inline$::std::string* $classname$::unsafe_arena_release_$name$() {\n" " // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" " $clear_hasbit$\n" " return $name$_.UnsafeArenaRelease($default_variable$,\n" " GetArenaNoVirtual());\n" "}\n" - "$inline$ void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" " if ($name$ != NULL) {\n" " $set_hasbit$\n" " } else {\n" @@ -219,7 +219,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" "}\n" - "$inline$ void $classname$::unsafe_arena_set_allocated_$name$(\n" + "$inline$void $classname$::unsafe_arena_set_allocated_$name$(\n" " ::std::string* $name$) {\n" " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" " if ($name$ != NULL) {\n" @@ -235,21 +235,21 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, } else { // No-arena case. printer->Print(variables, - "$inline$ const ::std::string& $classname$::$name$() const {\n" + "$inline$const ::std::string& $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return $name$_.GetNoArena($default_variable$);\n" "}\n" - "$inline$ void $classname$::set_$name$(const ::std::string& value) {\n" + "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" " $set_hasbit$\n" " $name$_.SetNoArena($default_variable$, value);\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$ void $classname$::set_$name$(const char* value) {\n" + "$inline$void $classname$::set_$name$(const char* value) {\n" " $set_hasbit$\n" " $name$_.SetNoArena($default_variable$, $string_piece$(value));\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n" - "$inline$ " + "$inline$" "void $classname$::set_$name$(const $pointer_type$* value, " "size_t size) {\n" " $set_hasbit$\n" @@ -257,17 +257,17 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " $string_piece$(reinterpret_cast<const char*>(value), size));\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$ ::std::string* $classname$::mutable_$name$() {\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" " $set_hasbit$\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n" " return $name$_.MutableNoArena($default_variable$);\n" "}\n" - "$inline$ ::std::string* $classname$::$release_name$() {\n" + "$inline$::std::string* $classname$::$release_name$() {\n" " // @@protoc_insertion_point(field_release:$full_name$)\n" " $clear_hasbit$\n" " return $name$_.ReleaseNoArena($default_variable$);\n" "}\n" - "$inline$ void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" " if ($name$ != NULL) {\n" " $set_hasbit$\n" " } else {\n" @@ -339,8 +339,10 @@ GenerateConstructorCode(io::Printer* printer) const { void StringFieldGenerator:: GenerateDestructorCode(io::Printer* printer) const { if (SupportsArenas(descriptor_)) { + // The variable |arena| is defined by the enclosing code. + // See MessageGenerator::GenerateSharedDestructorCode. printer->Print(variables_, - "$name$_.Destroy($default_variable$, GetArenaNoVirtual());\n"); + "$name$_.Destroy($default_variable$, arena);\n"); } else { printer->Print(variables_, "$name$_.DestroyNoArena($default_variable$);\n"); @@ -426,17 +428,17 @@ void StringOneofFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; if (SupportsArenas(descriptor_)) { printer->Print(variables, - "$inline$ const ::std::string& $classname$::$name$() const {\n" + "$inline$const ::std::string& $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " if (has_$name$()) {\n" " return $oneof_prefix$$name$_.Get($default_variable$);\n" " }\n" " return *$default_variable$;\n" "}\n" - "$inline$ void $classname$::set_$name$(const ::std::string& value) {\n" + "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" @@ -446,7 +448,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$ void $classname$::set_$name$(const char* value) {\n" + "$inline$void $classname$::set_$name$(const char* value) {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" @@ -456,7 +458,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " $string_piece$(value), GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n" - "$inline$ " + "$inline$" "void $classname$::set_$name$(const $pointer_type$* value,\n" " size_t size) {\n" " if (!has_$name$()) {\n" @@ -469,7 +471,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$ ::std::string* $classname$::mutable_$name$() {\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" @@ -479,7 +481,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n" "}\n" - "$inline$ ::std::string* $classname$::$release_name$() {\n" + "$inline$::std::string* $classname$::$release_name$() {\n" " // @@protoc_insertion_point(field_release:$full_name$)\n" " if (has_$name$()) {\n" " clear_has_$oneof_name$();\n" @@ -489,7 +491,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " return NULL;\n" " }\n" "}\n" - "$inline$ ::std::string* $classname$::unsafe_arena_release_$name$() {\n" + "$inline$::std::string* $classname$::unsafe_arena_release_$name$() {\n" " // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" " if (has_$name$()) {\n" @@ -500,7 +502,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " return NULL;\n" " }\n" "}\n" - "$inline$ void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" " if (!has_$name$()) {\n" " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" " }\n" @@ -512,7 +514,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " }\n" " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" "}\n" - "$inline$ void $classname$::unsafe_arena_set_allocated_$name$(" + "$inline$void $classname$::unsafe_arena_set_allocated_$name$(" "::std::string* $name$) {\n" " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" " if (!has_$name$()) {\n" @@ -530,14 +532,14 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, } else { // No-arena case. printer->Print(variables, - "$inline$ const ::std::string& $classname$::$name$() const {\n" + "$inline$const ::std::string& $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " if (has_$name$()) {\n" " return $oneof_prefix$$name$_.GetNoArena($default_variable$);\n" " }\n" " return *$default_variable$;\n" "}\n" - "$inline$ void $classname$::set_$name$(const ::std::string& value) {\n" + "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" @@ -547,7 +549,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " $oneof_prefix$$name$_.SetNoArena($default_variable$, value);\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$ void $classname$::set_$name$(const char* value) {\n" + "$inline$void $classname$::set_$name$(const char* value) {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" @@ -557,7 +559,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " $string_piece$(value));\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n" - "$inline$ " + "$inline$" "void $classname$::set_$name$(const $pointer_type$* value, size_t size) {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" @@ -568,7 +570,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " reinterpret_cast<const char*>(value), size));\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$ ::std::string* $classname$::mutable_$name$() {\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" @@ -577,7 +579,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " // @@protoc_insertion_point(field_mutable:$full_name$)\n" " return $oneof_prefix$$name$_.MutableNoArena($default_variable$);\n" "}\n" - "$inline$ ::std::string* $classname$::$release_name$() {\n" + "$inline$::std::string* $classname$::$release_name$() {\n" " // @@protoc_insertion_point(field_release:$full_name$)\n" " if (has_$name$()) {\n" " clear_has_$oneof_name$();\n" @@ -586,7 +588,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " return NULL;\n" " }\n" "}\n" - "$inline$ void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" " if (!has_$name$()) {\n" " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" " }\n" @@ -732,55 +734,55 @@ void RepeatedStringFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map<string, string> variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ const ::std::string& $classname$::$name$(int index) const {\n" + "$inline$const ::std::string& $classname$::$name$(int index) const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return $name$_.$cppget$(index);\n" "}\n" - "$inline$ ::std::string* $classname$::mutable_$name$(int index) {\n" + "$inline$::std::string* $classname$::mutable_$name$(int index) {\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n" " return $name$_.Mutable(index);\n" "}\n" - "$inline$ void $classname$::set_$name$(int index, const ::std::string& value) {\n" + "$inline$void $classname$::set_$name$(int index, const ::std::string& value) {\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" " $name$_.Mutable(index)->assign(value);\n" "}\n" - "$inline$ void $classname$::set_$name$(int index, const char* value) {\n" + "$inline$void $classname$::set_$name$(int index, const char* value) {\n" " $name$_.Mutable(index)->assign(value);\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n" - "$inline$ void " + "$inline$void " "$classname$::set_$name$" "(int index, const $pointer_type$* value, size_t size) {\n" " $name$_.Mutable(index)->assign(\n" " reinterpret_cast<const char*>(value), size);\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$ ::std::string* $classname$::add_$name$() {\n" + "$inline$::std::string* $classname$::add_$name$() {\n" " // @@protoc_insertion_point(field_add_mutable:$full_name$)\n" " return $name$_.Add();\n" "}\n" - "$inline$ void $classname$::add_$name$(const ::std::string& value) {\n" + "$inline$void $classname$::add_$name$(const ::std::string& value) {\n" " $name$_.Add()->assign(value);\n" " // @@protoc_insertion_point(field_add:$full_name$)\n" "}\n" - "$inline$ void $classname$::add_$name$(const char* value) {\n" + "$inline$void $classname$::add_$name$(const char* value) {\n" " $name$_.Add()->assign(value);\n" " // @@protoc_insertion_point(field_add_char:$full_name$)\n" "}\n" - "$inline$ void " + "$inline$void " "$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n" " $name$_.Add()->assign(reinterpret_cast<const char*>(value), size);\n" " // @@protoc_insertion_point(field_add_pointer:$full_name$)\n" "}\n"); printer->Print(variables, - "$inline$ const ::google::protobuf::RepeatedPtrField< ::std::string>&\n" + "$inline$const ::google::protobuf::RepeatedPtrField< ::std::string>&\n" "$classname$::$name$() const {\n" " // @@protoc_insertion_point(field_list:$full_name$)\n" " return $name$_;\n" "}\n" - "$inline$ ::google::protobuf::RepeatedPtrField< ::std::string>*\n" + "$inline$::google::protobuf::RepeatedPtrField< ::std::string>*\n" "$classname$::mutable_$name$() {\n" " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" " return &$name$_;\n" @@ -798,6 +800,11 @@ GenerateMergingCode(io::Printer* printer) const { } void RepeatedStringFieldGenerator:: +GenerateUnsafeMergingCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_.UnsafeMergeFrom(from.$name$_);\n"); +} + +void RepeatedStringFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n"); } @@ -858,7 +865,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { void RepeatedStringFieldGenerator:: GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size();\n" + "total_size += $tag_size$ *\n" + " ::google::protobuf::internal::FromIntSize(this->$name$_size());\n" "for (int i = 0; i < this->$name$_size(); i++) {\n" " total_size += ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n" " this->$name$(i));\n" diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.h b/src/google/protobuf/compiler/cpp/cpp_string_field.h index cb4e8772..1dea7663 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.h @@ -110,6 +110,7 @@ class RepeatedStringFieldGenerator : public FieldGenerator { bool is_inline) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; + void GenerateUnsafeMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_unittest.cc index b7b6039a..d214ef0a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc @@ -129,12 +129,12 @@ TEST(GeneratedDescriptorTest, IdenticalDescriptors) { // Test that descriptors are generated correctly by converting them to // FileDescriptorProtos and comparing. - FileDescriptorProto generated_decsriptor_proto, parsed_descriptor_proto; - generated_descriptor->CopyTo(&generated_decsriptor_proto); + FileDescriptorProto generated_descriptor_proto, parsed_descriptor_proto; + generated_descriptor->CopyTo(&generated_descriptor_proto); parsed_descriptor->CopyTo(&parsed_descriptor_proto); EXPECT_EQ(parsed_descriptor_proto.DebugString(), - generated_decsriptor_proto.DebugString()); + generated_descriptor_proto.DebugString()); } #if !defined(GOOGLE_PROTOBUF_CMAKE_BUILD) && !defined(_MSC_VER) diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc index 5e387285..3cbc530e 100644 --- a/src/google/protobuf/compiler/java/java_file.cc +++ b/src/google/protobuf/compiler/java/java_file.cc @@ -189,8 +189,6 @@ void MaybeRestartJavaMethod(io::Printer* printer, *bytecode_estimate = 0; } } - - } // namespace FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options, diff --git a/src/google/protobuf/compiler/java/java_map_field.cc b/src/google/protobuf/compiler/java/java_map_field.cc index 16c5bec5..07aa3565 100644 --- a/src/google/protobuf/compiler/java/java_map_field.cc +++ b/src/google/protobuf/compiler/java/java_map_field.cc @@ -92,7 +92,11 @@ void SetMessageVariables(const FieldDescriptor* descriptor, const JavaType valueJavaType = GetJavaType(value); (*variables)["key_type"] = TypeName(key, name_resolver, false); - (*variables)["boxed_key_type"] = TypeName(key, name_resolver, true); + string boxed_key_type = TypeName(key, name_resolver, true); + (*variables)["boxed_key_type"] = boxed_key_type; + // Used for calling the serialization function. + (*variables)["short_key_type"] = + boxed_key_type.substr(boxed_key_type.rfind('.') + 1); (*variables)["key_wire_type"] = WireType(key); (*variables)["key_default_value"] = DefaultValue(key, true, name_resolver); (*variables)["key_null_check"] = IsReferenceType(keyJavaType) ? @@ -147,6 +151,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, name_resolver->GetImmutableClassName(descriptor->file()) + ".internal_" + UniqueFileScopeIdentifier(descriptor->message_type()) + "_descriptor, "; + (*variables)["ver"] = GeneratedCodeVersionSuffix(); } } // namespace @@ -661,21 +666,23 @@ GenerateParsingCode(io::Printer* printer) const { variables_, "com.google.protobuf.ByteString bytes = input.readBytes();\n" "com.google.protobuf.MapEntry<$type_parameters$>\n" - "$name$ = $default_entry$.getParserForType().parseFrom(bytes);\n"); + "$name$__ = $default_entry$.getParserForType().parseFrom(bytes);\n"); printer->Print( variables_, - "if ($value_enum_type$.forNumber($name$.getValue()) == null) {\n" + "if ($value_enum_type$.forNumber($name$__.getValue()) == null) {\n" " unknownFields.mergeLengthDelimitedField($number$, bytes);\n" "} else {\n" - " $name$_.getMutableMap().put($name$.getKey(), $name$.getValue());\n" + " $name$_.getMutableMap().put(\n" + " $name$__.getKey(), $name$__.getValue());\n" "}\n"); } else { printer->Print( variables_, "com.google.protobuf.MapEntry<$type_parameters$>\n" - "$name$ = input.readMessage(\n" + "$name$__ = input.readMessage(\n" " $default_entry$.getParserForType(), extensionRegistry);\n" - "$name$_.getMutableMap().put($name$.getKey(), $name$.getValue());\n"); + "$name$_.getMutableMap().put(\n" + " $name$__.getKey(), $name$__.getValue());\n"); } } @@ -688,15 +695,12 @@ void ImmutableMapFieldGenerator:: GenerateSerializationCode(io::Printer* printer) const { printer->Print( variables_, - "for (java.util.Map.Entry<$type_parameters$> entry\n" - " : internalGet$capitalized_name$().getMap().entrySet()) {\n" - " com.google.protobuf.MapEntry<$type_parameters$>\n" - " $name$ = $default_entry$.newBuilderForType()\n" - " .setKey(entry.getKey())\n" - " .setValue(entry.getValue())\n" - " .build();\n" - " output.writeMessage($number$, $name$);\n" - "}\n"); + "com.google.protobuf.GeneratedMessage$ver$\n" + " .serialize$short_key_type$MapTo(\n" + " output,\n" + " internalGet$capitalized_name$(),\n" + " $default_entry$,\n" + " $number$);\n"); } void ImmutableMapFieldGenerator:: @@ -706,12 +710,12 @@ GenerateSerializedSizeCode(io::Printer* printer) const { "for (java.util.Map.Entry<$type_parameters$> entry\n" " : internalGet$capitalized_name$().getMap().entrySet()) {\n" " com.google.protobuf.MapEntry<$type_parameters$>\n" - " $name$ = $default_entry$.newBuilderForType()\n" + " $name$__ = $default_entry$.newBuilderForType()\n" " .setKey(entry.getKey())\n" " .setValue(entry.getValue())\n" " .build();\n" " size += com.google.protobuf.CodedOutputStream\n" - " .computeMessageSize($number$, $name$);\n" + " .computeMessageSize($number$, $name$__);\n" "}\n"); } diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.cc b/src/google/protobuf/compiler/java/java_map_field_lite.cc index 0d3bea17..5f102e07 100644 --- a/src/google/protobuf/compiler/java/java_map_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_map_field_lite.cc @@ -765,14 +765,14 @@ GenerateParsingCode(io::Printer* printer) const { printer->Print( variables_, "com.google.protobuf.ByteString bytes = input.readBytes();\n" - "java.util.Map.Entry<$type_parameters$> $name$ =\n" + "java.util.Map.Entry<$type_parameters$> $name$__ =\n" " $default_entry$.parseEntry(bytes, extensionRegistry);\n"); printer->Print( variables_, - "if ($value_enum_type$.forNumber($name$.getValue()) == null) {\n" + "if ($value_enum_type$.forNumber($name$__.getValue()) == null) {\n" " super.mergeLengthDelimitedField($number$, bytes);\n" "} else {\n" - " $name$_.put($name$);\n" + " $name$_.put($name$__);\n" "}\n"); } else { printer->Print( diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc index 6c80d070..68d28b05 100644 --- a/src/google/protobuf/compiler/java/java_message.cc +++ b/src/google/protobuf/compiler/java/java_message.cc @@ -928,7 +928,7 @@ void ImmutableMessageGenerator::GenerateIsInitialized( case FieldDescriptor::LABEL_REPEATED: if (IsMapEntry(field->message_type())) { printer->Print( - "for ($type$ item : get$name$().values()) {\n" + "for ($type$ item : get$name$Map().values()) {\n" " if (!item.isInitialized()) {\n" " memoizedIsInitialized = 0;\n" " return false;\n" diff --git a/src/google/protobuf/compiler/java/java_message_builder.cc b/src/google/protobuf/compiler/java/java_message_builder.cc index 42154694..cd82c51a 100644 --- a/src/google/protobuf/compiler/java/java_message_builder.cc +++ b/src/google/protobuf/compiler/java/java_message_builder.cc @@ -184,6 +184,11 @@ Generate(io::Printer* printer) { "}\n" "\n"); } else { + // Override methods declared in GeneratedMessage to return the concrete + // generated type so callsites won't depend on GeneratedMessage. This + // is needed to keep binary compatibility when we change generated code + // to subclass a different GeneratedMessage class (e.g., in v3.0.0 release + // we changed all generated code to subclass GeneratedMessageV3). printer->Print( "public final Builder setUnknownFields(\n" " final com.google.protobuf.UnknownFieldSet unknownFields) {\n" @@ -456,6 +461,11 @@ GenerateCommonBuilderMethods(io::Printer* printer) { "\n", "classname", name_resolver_->GetImmutableClassName(descriptor_)); + // Override methods declared in GeneratedMessage to return the concrete + // generated type so callsites won't depend on GeneratedMessage. This + // is needed to keep binary compatibility when we change generated code + // to subclass a different GeneratedMessage class (e.g., in v3.0.0 release + // we changed all generated code to subclass GeneratedMessageV3). printer->Print( "public Builder clone() {\n" " return (Builder) super.clone();\n" @@ -596,7 +606,6 @@ GenerateCommonBuilderMethods(io::Printer* printer) { " return this;\n" "}\n" "\n"); - } } @@ -690,7 +699,7 @@ void MessageBuilderGenerator::GenerateIsInitialized( case FieldDescriptor::LABEL_REPEATED: if (IsMapEntry(field->message_type())) { printer->Print( - "for ($type$ item : get$name$().values()) {\n" + "for ($type$ item : get$name$Map().values()) {\n" " if (!item.isInitialized()) {\n" " return false;\n" " }\n" diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.cc b/src/google/protobuf/compiler/java/java_message_field_lite.cc index 14281816..cba18360 100644 --- a/src/google/protobuf/compiler/java/java_message_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_field_lite.cc @@ -145,6 +145,7 @@ GenerateInterfaceMembers(io::Printer* printer) const { void ImmutableMessageFieldLiteGenerator:: GenerateMembers(io::Printer* printer) const { + printer->Print(variables_, "private $type$ $name$_;\n"); PrintExtraFieldInfo(variables_, printer); diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc index 7c8c4a03..0c5a1f8a 100644 --- a/src/google/protobuf/compiler/java/java_message_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_lite.cc @@ -179,6 +179,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { MaybePrintGeneratedAnnotation(context_, printer, descriptor_, /* immutable = */ true); + // The builder_type stores the super type name of the nested Builder class. string builder_type; if (descriptor_->extension_range_count() > 0) { @@ -203,7 +204,6 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { } printer->Indent(); - GenerateConstructor(printer); // Nested types @@ -748,7 +748,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodIsInitialized( case FieldDescriptor::LABEL_REPEATED: if (IsMapEntry(field->message_type())) { printer->Print( - "for ($type$ item : get$name$().values()) {\n" + "for ($type$ item : get$name$Map().values()) {\n" " if (!item.isInitialized()) {\n" " if (shouldMemoize) {\n" " memoizedIsInitialized = 0;\n" diff --git a/src/google/protobuf/compiler/java/java_service.cc b/src/google/protobuf/compiler/java/java_service.cc index 9f34f010..cfa8295d 100644 --- a/src/google/protobuf/compiler/java/java_service.cc +++ b/src/google/protobuf/compiler/java/java_service.cc @@ -184,6 +184,10 @@ void ImmutableServiceGenerator::GenerateAbstractMethods(io::Printer* printer) { } } +string ImmutableServiceGenerator::GetOutput(const MethodDescriptor* method) { + return name_resolver_->GetImmutableClassName(method->output_type()); +} + void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) { printer->Print( "\n" @@ -209,8 +213,7 @@ void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) { vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName( method->input_type()); - vars["output"] = name_resolver_->GetImmutableClassName( - method->output_type()); + vars["output"] = GetOutput(method); printer->Print(vars, "case $index$:\n" " this.$method$(controller, ($input$)request,\n" @@ -257,8 +260,7 @@ void ImmutableServiceGenerator::GenerateCallBlockingMethod( vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName( method->input_type()); - vars["output"] = name_resolver_->GetImmutableClassName( - method->output_type()); + vars["output"] = GetOutput(method); printer->Print(vars, "case $index$:\n" " return impl.$method$(controller, ($input$)request);\n"); @@ -353,8 +355,7 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) { map<string, string> vars; vars["index"] = SimpleItoa(i); - vars["output"] = name_resolver_->GetImmutableClassName( - method->output_type()); + vars["output"] = GetOutput(method); printer->Print(vars, "channel.callMethod(\n" " getDescriptor().getMethods().get($index$),\n" @@ -418,8 +419,7 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) { map<string, string> vars; vars["index"] = SimpleItoa(i); - vars["output"] = name_resolver_->GetImmutableClassName( - method->output_type()); + vars["output"] = GetOutput(method); printer->Print(vars, "return ($output$) channel.callBlockingMethod(\n" " getDescriptor().getMethods().get($index$),\n" @@ -443,7 +443,7 @@ void ImmutableServiceGenerator::GenerateMethodSignature(io::Printer* printer, map<string, string> vars; vars["name"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName(method->input_type()); - vars["output"] = name_resolver_->GetImmutableClassName(method->output_type()); + vars["output"] = GetOutput(method); vars["abstract"] = (is_abstract == IS_ABSTRACT) ? "abstract" : ""; printer->Print(vars, "public $abstract$ void $name$(\n" @@ -458,7 +458,7 @@ void ImmutableServiceGenerator::GenerateBlockingMethodSignature( map<string, string> vars; vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName(method->input_type()); - vars["output"] = name_resolver_->GetImmutableClassName(method->output_type()); + vars["output"] = GetOutput(method); printer->Print(vars, "\n" "public $output$ $method$(\n" diff --git a/src/google/protobuf/compiler/java/java_service.h b/src/google/protobuf/compiler/java/java_service.h index 5fc9e2f6..12b3f942 100644 --- a/src/google/protobuf/compiler/java/java_service.h +++ b/src/google/protobuf/compiler/java/java_service.h @@ -122,6 +122,9 @@ class ImmutableServiceGenerator : public ServiceGenerator { void GenerateBlockingMethodSignature(io::Printer* printer, const MethodDescriptor* method); + // Return the output type of the method. + string GetOutput(const MethodDescriptor* method); + Context* context_; ClassNameResolver* name_resolver_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableServiceGenerator); diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.cc b/src/google/protobuf/compiler/java/java_shared_code_generator.cc index 52893721..18bf1f51 100644 --- a/src/google/protobuf/compiler/java/java_shared_code_generator.cc +++ b/src/google/protobuf/compiler/java/java_shared_code_generator.cc @@ -119,7 +119,6 @@ void SharedCodeGenerator::Generate(GeneratorContext* context, } } - void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) { // Embed the descriptor. We simply serialize the entire FileDescriptorProto // and embed it as a string literal, which is parsed and built into real @@ -134,7 +133,6 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) { FileDescriptorProto file_proto; file_->CopyTo(&file_proto); - string file_data; file_proto.SerializeToString(&file_data); diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index 58c77d00..1a882057 100755 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -153,8 +153,8 @@ string StripProto(const string& filename) { // Given a filename like foo/bar/baz.proto, returns the corresponding JavaScript // file foo/bar/baz.js. -string GetJSFilename(const string& filename) { - return StripProto(filename) + "_pb.js"; +string GetJSFilename(const GeneratorOptions& options, const string& filename) { + return StripProto(filename) + options.GetFileNameExtension(); } // Given a filename like foo/bar/baz.proto, returns the root directory @@ -273,7 +273,7 @@ string GetPath(const GeneratorOptions& options, string MaybeCrossFileRef(const GeneratorOptions& options, const FileDescriptor* from_file, const Descriptor* to_message) { - if (options.import_style == GeneratorOptions::IMPORT_COMMONJS && + if (options.import_style == GeneratorOptions::kImportCommonJs && from_file != to_message->file()) { // Cross-file ref in CommonJS needs to use the module alias instead of // the global name. @@ -405,21 +405,24 @@ string ToFileName(const string& input) { // that top-level extensions should go in. string GetExtensionFileName(const GeneratorOptions& options, const FileDescriptor* file) { - return options.output_dir + "/" + ToFileName(GetPath(options, file)) + ".js"; + return options.output_dir + "/" + ToFileName(GetPath(options, file)) + + options.GetFileNameExtension(); } // When we're generating one output file per type name, this is the filename // that a top-level message should go in. string GetMessageFileName(const GeneratorOptions& options, const Descriptor* desc) { - return options.output_dir + "/" + ToFileName(desc->name()) + ".js"; + return options.output_dir + "/" + ToFileName(desc->name()) + + options.GetFileNameExtension(); } // When we're generating one output file per type name, this is the filename // that a top-level message should go in. string GetEnumFileName(const GeneratorOptions& options, const EnumDescriptor* desc) { - return options.output_dir + "/" + ToFileName(desc->name()) + ".js"; + return options.output_dir + "/" + ToFileName(desc->name()) + + options.GetFileNameExtension(); } // Returns the message/response ID, if set. @@ -444,9 +447,19 @@ bool IgnoreField(const FieldDescriptor* field) { } +// Used inside Google only -- do not remove. +bool ShouldTreatMapsAsRepeatedFields(const FileDescriptor& descriptor) { + return false; +} + // Do we ignore this message type? bool IgnoreMessage(const GeneratorOptions& options, const Descriptor* d) { - return d->options().map_entry(); + return d->options().map_entry() && + !ShouldTreatMapsAsRepeatedFields(*d->file()); +} + +bool IsMap(const GeneratorOptions& options, const FieldDescriptor* field) { + return field->is_map() && !ShouldTreatMapsAsRepeatedFields(*field->file()); } // Does JSPB ignore this entire oneof? True only if all fields are ignored. @@ -459,10 +472,8 @@ bool IgnoreOneof(const OneofDescriptor* oneof) { return true; } -string JSIdent(const GeneratorOptions& options, - const FieldDescriptor* field, - bool is_upper_camel, - bool is_map) { +string JSIdent(const GeneratorOptions& options, const FieldDescriptor* field, + bool is_upper_camel, bool is_map, bool drop_list) { string result; if (field->type() == FieldDescriptor::TYPE_GROUP) { result = is_upper_camel ? @@ -473,10 +484,10 @@ string JSIdent(const GeneratorOptions& options, ToUpperCamel(ParseLowerUnderscore(field->name())) : ToLowerCamel(ParseLowerUnderscore(field->name())); } - if (is_map || (field->is_map())) { + if (is_map || IsMap(options, field)) { // JSPB-style or proto3-style map. result += "Map"; - } else if (field->is_repeated()) { + } else if (!drop_list && field->is_repeated()) { // Repeated field. result += "List"; } @@ -485,11 +496,10 @@ string JSIdent(const GeneratorOptions& options, string JSObjectFieldName(const GeneratorOptions& options, const FieldDescriptor* field) { - string name = JSIdent( - options, - field, - /* is_upper_camel = */ false, - /* is_map = */ false); + string name = JSIdent(options, field, + /* is_upper_camel = */ false, + /* is_map = */ false, + /* drop_list = */ false); if (IsReserved(name)) { name = "pb_" + name; } @@ -514,10 +524,11 @@ string JSByteGetterSuffix(BytesMode bytes_mode) { // name, e.g. MyField for .getMyField(). string JSGetterName(const GeneratorOptions& options, const FieldDescriptor* field, - BytesMode bytes_mode = BYTES_DEFAULT) { + BytesMode bytes_mode = BYTES_DEFAULT, + bool drop_list = false) { string name = JSIdent(options, field, /* is_upper_camel = */ true, - /* is_map = */ false); + /* is_map = */ false, drop_list); if (field->type() == FieldDescriptor::TYPE_BYTES) { string suffix = JSByteGetterSuffix(bytes_mode); if (!suffix.empty()) { @@ -535,7 +546,8 @@ string JSMapGetterName(const GeneratorOptions& options, const FieldDescriptor* field) { return JSIdent(options, field, /* is_upper_camel = */ true, - /* is_map = */ true); + /* is_map = */ true, + /* drop_list = */ false); } @@ -768,6 +780,10 @@ string MaybeNumberString(const FieldDescriptor* field, const string& orig) { } string JSFieldDefault(const FieldDescriptor* field) { + if (field->is_repeated()) { + return "[]"; + } + switch (field->cpp_type()) { case FieldDescriptor::CPPTYPE_INT32: return MaybeNumberString( @@ -909,20 +925,91 @@ string JSTypeName(const GeneratorOptions& options, } } -bool HasFieldPresence(const FieldDescriptor* field); +bool UseBrokenPresenceSemantics(const GeneratorOptions& options, + const FieldDescriptor* field) { + if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) { + return options.broken_proto3_semantics; + } else if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO2) { + return false; + } else { + GOOGLE_LOG(FATAL) << "We can only handle syntax=proto2 and syntax=proto3."; + 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 string& type) { + return type == "undefined" || type == "string" || type == "number" || + type == "boolean"; +} string JSFieldTypeAnnotation(const GeneratorOptions& options, const FieldDescriptor* field, - bool force_optional, + bool is_setter_argument, bool force_present, bool singular_if_not_packed, BytesMode bytes_mode = BYTES_DEFAULT) { - bool is_primitive = - (field->cpp_type() != FieldDescriptor::CPPTYPE_ENUM && - field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE && - (field->type() != FieldDescriptor::TYPE_BYTES || - bytes_mode == BYTES_B64)); - + GOOGLE_CHECK(!(is_setter_argument && force_present)); string jstype = JSTypeName(options, field, bytes_mode); if (field->is_repeated() && @@ -931,27 +1018,35 @@ string JSFieldTypeAnnotation(const GeneratorOptions& options, bytes_mode == BYTES_DEFAULT) { jstype = "(Array<!Uint8Array>|Array<string>)"; } else { - if (!is_primitive) { + if (!IsPrimitive(jstype)) { jstype = "!" + jstype; } jstype = "Array.<" + jstype + ">"; } - if (!force_optional) { - jstype = "!" + jstype; - } } - if (field->is_optional() && is_primitive && - force_optional && !force_present) { - jstype += "?"; - } else if (field->is_required() && !is_primitive && !force_optional) { - jstype = "!" + jstype; - } + bool is_null_or_undefined = false; - if (force_optional && HasFieldPresence(field)) { - jstype += "|undefined"; + 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 (force_present && jstype[0] != '!' && !is_primitive) { + + if (!is_null_or_undefined && !IsPrimitive(jstype)) { jstype = "!" + jstype; } @@ -1007,9 +1102,10 @@ string JSReturnDoc(const GeneratorOptions& options, return ""; } -bool HasRepeatedFields(const Descriptor* desc) { +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()) { + if (desc->field(i)->is_repeated() && !IsMap(options, desc->field(i))) { return true; } } @@ -1020,8 +1116,9 @@ static const char* kRepeatedFieldArrayName = ".repeatedFields_"; string RepeatedFieldsArrayName(const GeneratorOptions& options, const Descriptor* desc) { - return HasRepeatedFields(desc) ? - (GetPath(options, desc) + kRepeatedFieldArrayName) : "null"; + return HasRepeatedFields(options, desc) + ? (GetPath(options, desc) + kRepeatedFieldArrayName) + : "null"; } bool HasOneofFields(const Descriptor* desc) { @@ -1041,10 +1138,11 @@ string OneofFieldsArrayName(const GeneratorOptions& options, (GetPath(options, desc) + kOneofGroupArrayName) : "null"; } -string RepeatedFieldNumberList(const Descriptor* desc) { +string RepeatedFieldNumberList(const GeneratorOptions& options, + const Descriptor* desc) { std::vector<string> numbers; for (int i = 0; i < desc->field_count(); i++) { - if (desc->field(i)->is_repeated() && !desc->field(i)->is_map()) { + if (desc->field(i)->is_repeated() && !IsMap(options, desc->field(i))) { numbers.push_back(JSFieldIndex(desc->field(i))); } } @@ -1108,7 +1206,7 @@ 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 IMPORT_COMMONJS case. + // TODO(haberman): fix this for the kImportCommonJs case. return "jspb.Message.messageSetExtensions"; } else { return MaybeCrossFileRef(options, from_file, desc) + ".extensions"; @@ -1130,7 +1228,7 @@ const FieldDescriptor* MapFieldValue(const FieldDescriptor* field) { string FieldDefinition(const GeneratorOptions& options, const FieldDescriptor* field) { - if (field->is_map()) { + if (IsMap(options, field)) { const FieldDescriptor* key_field = MapFieldKey(field); const FieldDescriptor* value_field = MapFieldValue(field); string key_type = ProtoTypeName(options, key_field); @@ -1254,47 +1352,24 @@ string GetPivot(const Descriptor* desc) { return SimpleItoa(pivot); } -// Returns true for fields that represent "null" as distinct from the default -// value. See http://go/proto3#heading=h.kozewqqcqhuz for more information. -bool HasFieldPresence(const FieldDescriptor* field) { - if (field->is_repeated()) { +// 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) { + if (field->is_repeated() || field->is_map()) { + // We say repeated fields and maps don't have presence, but we still do + // generate clearFoo() methods for them through a special case elsewhere. return false; } - return - (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) || - (field->containing_oneof() != NULL) || - (field->file()->syntax() != FileDescriptor::SYNTAX_PROTO3); -} - -// For proto3 fields without presence, returns a string representing the default -// value in JavaScript. See http://go/proto3#heading=h.kozewqqcqhuz for more -// information. -string Proto3PrimitiveFieldDefault(const FieldDescriptor* field) { - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_INT32: - case FieldDescriptor::CPPTYPE_INT64: - case FieldDescriptor::CPPTYPE_UINT32: - case FieldDescriptor::CPPTYPE_UINT64: { - return "0"; - } - - case FieldDescriptor::CPPTYPE_ENUM: - case FieldDescriptor::CPPTYPE_FLOAT: - case FieldDescriptor::CPPTYPE_DOUBLE: - return "0"; - - case FieldDescriptor::CPPTYPE_BOOL: - return "false"; - - case FieldDescriptor::CPPTYPE_STRING: // includes BYTES - return "\"\""; - - default: - // MESSAGE is handled separately. - assert(false); - return ""; + if (UseBrokenPresenceSemantics(options, field)) { + // Proto3 files with broken presence semantics have field presence. + return true; } + + return field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || + field->containing_oneof() != NULL || + field->file()->syntax() == FileDescriptor::SYNTAX_PROTO2; } // We use this to implement the semantics that same file can be generated @@ -1524,8 +1599,19 @@ void Generator::GenerateProvides(const GeneratorOptions& options, std::set<string>* provided) const { for (std::set<string>::iterator it = provided->begin(); it != provided->end(); ++it) { - printer->Print("goog.provide('$name$');\n", - "name", *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() { /* ... */ } + printer->Print("goog.exportSymbol('$name$', null, global);\n", "name", + *it); + } } } @@ -1548,7 +1634,7 @@ void Generator::GenerateRequiresForLibrary( const GeneratorOptions& options, io::Printer* printer, const vector<const FileDescriptor*>& files, std::set<string>* provided) const { - GOOGLE_CHECK_EQ(options.import_style, GeneratorOptions::IMPORT_CLOSURE); + GOOGLE_CHECK_EQ(options.import_style, GeneratorOptions::kImportClosure); // For Closure imports we need to import every message type individually. std::set<string> required; std::set<string> forwards; @@ -1623,6 +1709,10 @@ void Generator::GenerateRequiresImpl(const GeneratorOptions& options, } } if (require_extension) { + if (options.binary) { + printer->Print( + "goog.require('jspb.ExtensionFieldBinaryInfo');\n"); + } printer->Print( "goog.require('jspb.ExtensionFieldInfo');\n"); } @@ -1755,14 +1845,13 @@ void Generator::GenerateClass(const GeneratorOptions& options, GenerateClassDeserializeBinary(options, printer, desc); GenerateClassSerializeBinary(options, printer, desc); } - GenerateClassClone(options, printer, desc); GenerateClassRegistration(options, printer, desc); GenerateClassFields(options, printer, desc); if (IsExtendable(desc) && desc->full_name() != "google.protobuf.bridge.MessageSet") { GenerateClassExtensionFieldInfo(options, printer, desc); } - if (options.import_style != GeneratorOptions:: IMPORT_CLOSURE) { + if (options.import_style != GeneratorOptions::kImportClosure) { for (int i = 0; i < desc->extension_count(); i++) { GenerateExtension(options, printer, desc->extension(i)); } @@ -1820,7 +1909,7 @@ void Generator::GenerateClassConstructor(const GeneratorOptions& options, void Generator::GenerateClassFieldInfo(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc) const { - if (HasRepeatedFields(desc)) { + if (HasRepeatedFields(options, desc)) { printer->Print( "/**\n" " * List of repeated fields within this message type.\n" @@ -1831,7 +1920,7 @@ void Generator::GenerateClassFieldInfo(const GeneratorOptions& options, "\n", "classname", GetPath(options, desc), "rptfieldarray", kRepeatedFieldArrayName, - "rptfields", RepeatedFieldNumberList(desc)); + "rptfields", RepeatedFieldNumberList(options, desc)); } if (HasOneofFields(desc)) { @@ -2000,14 +2089,59 @@ void Generator::GenerateClassToObject(const GeneratorOptions& options, "classname", GetPath(options, desc)); } +void Generator::GenerateFieldValueExpression(io::Printer* printer, + const char *obj_reference, + const FieldDescriptor* field, + bool use_default) const { + bool is_float_or_double = + field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT || + field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE; + if (use_default) { + if (is_float_or_double) { + // Coerce "Nan" and "Infinity" to actual float values. + // + // This will change null to 0, but that doesn't matter since we're getting + // with a default. + printer->Print("+"); + } + + printer->Print( + "jspb.Message.getFieldWithDefault($obj$, $index$, $default$)", + "obj", obj_reference, + "index", JSFieldIndex(field), + "default", JSFieldDefault(field)); + } else { + if (is_float_or_double) { + if (field->is_required()) { + // Use "+" to convert all fields to numeric (including null). + printer->Print( + "+jspb.Message.getField($obj$, $index$)", + "index", JSFieldIndex(field), + "obj", obj_reference); + } else { + // Converts "NaN" and "Infinity" while preserving null. + printer->Print( + "jspb.Message.get$cardinality$FloatingPointField($obj$, $index$)", + "cardinality", field->is_repeated() ? "Repeated" : "Optional", + "index", JSFieldIndex(field), + "obj", obj_reference); + } + } else { + printer->Print("jspb.Message.getField($obj$, $index$)", + "index", JSFieldIndex(field), + "obj", obj_reference); + } + } +} + void Generator::GenerateClassFieldToObject(const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field) const { printer->Print("$fieldname$: ", "fieldname", JSObjectFieldName(options, field)); - if (field->is_map()) { - printer->Print("(f = msg.get$name$(true)) ? f.toArray() : []", + if (IsMap(options, field)) { + printer->Print("(f = msg.get$name$()) ? f.toArray() : []", "name", JSGetterName(options, field)); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { // Message field. @@ -2024,40 +2158,29 @@ void Generator::GenerateClassFieldToObject(const GeneratorOptions& options, "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 { - // Simple field (singular or repeated). - if ((!HasFieldPresence(field) && !field->is_repeated()) || - field->type() == FieldDescriptor::TYPE_BYTES) { - // Delegate to the generated get<field>() method in order not to duplicate - // the proto3-field-default-value or byte-coercion logic here. - printer->Print("msg.get$getter$()", - "getter", JSGetterName(options, field, BYTES_B64)); - } else { - if (field->has_default_value()) { - printer->Print("!msg.has$name$() ? $defaultValue$ : ", - "name", JSGetterName(options, field), - "defaultValue", JSFieldDefault(field)); - } - if (field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT || - field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE) { - if (field->is_repeated()) { - printer->Print("jspb.Message.getRepeatedFloatingPointField(" - "msg, $index$)", - "index", JSFieldIndex(field)); - } else if (field->is_optional() && !field->has_default_value()) { - printer->Print("jspb.Message.getOptionalFloatingPointField(" - "msg, $index$)", - "index", JSFieldIndex(field)); - } else { - // Convert "NaN" to NaN. - printer->Print("+jspb.Message.getField(msg, $index$)", - "index", JSFieldIndex(field)); - } - } else { - printer->Print("jspb.Message.getField(msg, $index$)", - "index", JSFieldIndex(field)); - } + 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() && !UseBrokenPresenceSemantics(options, field)) { + // 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. + GenerateFieldValueExpression(printer, "msg", field, use_default); } } @@ -2091,8 +2214,7 @@ void Generator::GenerateClassFieldFromObject( const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field) const { - - if (field->is_map()) { + if (IsMap(options, field)) { // `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. @@ -2133,21 +2255,6 @@ void Generator::GenerateClassFieldFromObject( } } -void Generator::GenerateClassClone(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - printer->Print( - "/**\n" - " * Creates a deep clone of this proto. No data is shared with the " - "original.\n" - " * @return {!$name$} The clone.\n" - " */\n" - "$name$.prototype.cloneMessage = function() {\n" - " return /** @type {!$name$} */ (jspb.Message.cloneMessage(this));\n" - "};\n\n\n", - "name", GetPath(options, desc)); -} - void Generator::GenerateClassRegistration(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc) const { @@ -2175,12 +2282,11 @@ void GenerateBytesWrapper(const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field, BytesMode bytes_mode) { - string type = - JSFieldTypeAnnotation(options, field, - /* force_optional = */ false, - /* force_present = */ !HasFieldPresence(field), - /* singular_if_not_packed = */ false, - bytes_mode); + string type = JSFieldTypeAnnotation( + options, field, + /* is_setter_argument = */ false, + /* force_present = */ false, + /* singular_if_not_packed = */ false, bytes_mode); printer->Print( "/**\n" " * $fielddef$\n" @@ -2208,20 +2314,20 @@ void GenerateBytesWrapper(const GeneratorOptions& options, void Generator::GenerateClassField(const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field) const { - if (field->is_map()) { + if (IsMap(options, field)) { const FieldDescriptor* key_field = MapFieldKey(field); const FieldDescriptor* value_field = MapFieldValue(field); // Map field: special handling to instantiate the map object on demand. string key_type = JSFieldTypeAnnotation( options, key_field, - /* force_optional = */ false, + /* is_setter_argument = */ false, /* force_present = */ true, /* singular_if_not_packed = */ false); string value_type = JSFieldTypeAnnotation( options, value_field, - /* force_optional = */ false, + /* is_setter_argument = */ false, /* force_present = */ true, /* singular_if_not_packed = */ false); @@ -2275,7 +2381,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options, "fielddef", FieldDefinition(options, field), "comment", FieldComments(field, BYTES_DEFAULT), "type", JSFieldTypeAnnotation(options, field, - /* force_optional = */ false, + /* is_setter_argument = */ false, /* force_present = */ false, /* singular_if_not_packed = */ false)); printer->Print( @@ -2289,7 +2395,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options, "class", GetPath(options, field->containing_type()), "name", JSGetterName(options, field), "type", JSFieldTypeAnnotation(options, field, - /* force_optional = */ false, + /* is_setter_argument = */ false, /* force_present = */ false, /* singular_if_not_packed = */ false), "rpt", (field->is_repeated() ? "Repeated" : ""), @@ -2298,12 +2404,12 @@ void Generator::GenerateClassField(const GeneratorOptions& options, "required", (field->label() == FieldDescriptor::LABEL_REQUIRED ? ", 1" : "")); printer->Print( - "/** @param {$optionaltype$} value $returndoc$ */\n" + "/** @param {$optionaltype$} value$returndoc$ */\n" "$class$.prototype.set$name$ = function(value) {\n" " jspb.Message.set$oneoftag$$repeatedtag$WrapperField(", "optionaltype", JSFieldTypeAnnotation(options, field, - /* force_optional = */ true, + /* is_setter_argument = */ true, /* force_present = */ false, /* singular_if_not_packed = */ false), "returndoc", JSReturnDoc(options, field), @@ -2322,16 +2428,9 @@ void Generator::GenerateClassField(const GeneratorOptions& options, (", " + JSOneofArray(options, field)) : ""), "returnvalue", JSReturnClause(field)); - printer->Print( - "$class$.prototype.clear$name$ = function() {\n" - " this.set$name$($clearedvalue$);$returnvalue$\n" - "};\n" - "\n" - "\n", - "class", GetPath(options, field->containing_type()), - "name", JSGetterName(options, field), - "clearedvalue", (field->is_repeated() ? "[]" : "undefined"), - "returnvalue", JSReturnClause(field)); + if (field->is_repeated()) { + GenerateRepeatedMessageHelperMethods(options, printer, field); + } } else { bool untyped = @@ -2345,12 +2444,12 @@ void Generator::GenerateClassField(const GeneratorOptions& options, BytesMode bytes_mode = field->type() == FieldDescriptor::TYPE_BYTES && !options.binary ? BYTES_B64 : BYTES_DEFAULT; - string typed_annotation = - JSFieldTypeAnnotation(options, field, - /* force_optional = */ false, - /* force_present = */ !HasFieldPresence(field), - /* singular_if_not_packed = */ false, - /* bytes_mode = */ bytes_mode); + 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" @@ -2382,36 +2481,21 @@ void Generator::GenerateClassField(const GeneratorOptions& options, "type", typed_annotation); } - // For proto3 fields without presence, use special getters that will return - // defaults when the field is unset, possibly constructing a value if - // required. - if (!HasFieldPresence(field) && !field->is_repeated()) { - printer->Print("jspb.Message.getFieldProto3(this, $index$, $default$)", - "index", JSFieldIndex(field), - "default", Proto3PrimitiveFieldDefault(field)); - } else { - if (!field->is_repeated()) { - printer->Print("!this.has$name$() ? $defaultValue$ : ", - "name", JSGetterName(options, field), - "defaultValue", JSFieldDefault(field)); - } - if (field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT || - field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE) { - if (field->is_repeated()) { - printer->Print("jspb.Message.getRepeatedFloatingPointField(" - "this, $index$)", - "index", JSFieldIndex(field)); - } else { - // Convert "NaN" to NaN. - printer->Print("+jspb.Message.getField(this, $index$)", - "index", JSFieldIndex(field)); - } - } else { - printer->Print("jspb.Message.getField(this, $index$)", - "index", JSFieldIndex(field)); - } + 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" @@ -2434,17 +2518,17 @@ void Generator::GenerateClassField(const GeneratorOptions& options, if (untyped) { printer->Print( "/**\n" - " * @param {*} value $returndoc$\n" + " * @param {*} value$returndoc$\n" " */\n", "returndoc", JSReturnDoc(options, field)); } else { printer->Print( - "/** @param {$optionaltype$} value $returndoc$ */\n", - "optionaltype", - JSFieldTypeAnnotation(options, field, - /* force_optional = */ true, - /* force_present = */ !HasFieldPresence(field), - /* singular_if_not_packed = */ false), + "/** @param {$optionaltype$} value$returndoc$ */\n", "optionaltype", + JSFieldTypeAnnotation( + options, field, + /* is_setter_argument = */ true, + /* force_present = */ false, + /* singular_if_not_packed = */ false), "returndoc", JSReturnDoc(options, field)); } printer->Print( @@ -2471,36 +2555,70 @@ void Generator::GenerateClassField(const GeneratorOptions& options, if (untyped) { printer->Print( "/**\n" - " * Clears the value. $returndoc$\n" + " * Clears the value.$returndoc$\n" " */\n", "returndoc", JSReturnDoc(options, field)); } - if (HasFieldPresence(field) || field->is_repeated()) { - printer->Print( - "$class$.prototype.clear$name$ = function() {\n" - " jspb.Message.set$oneoftag$Field(this, $index$$oneofgroup$, ", - "class", GetPath(options, field->containing_type()), - "name", JSGetterName(options, field), - "oneoftag", (field->containing_oneof() ? "Oneof" : ""), - "oneofgroup", (field->containing_oneof() ? - (", " + JSOneofArray(options, field)) : ""), - "index", JSFieldIndex(field)); - printer->Print( - "$clearedvalue$);$returnvalue$\n" - "};\n" - "\n" - "\n", - "clearedvalue", (field->is_repeated() ? "[]" : "undefined"), - "returnvalue", JSReturnClause(field)); + + if (field->is_repeated()) { + GenerateRepeatedPrimitiveHelperMethods(options, printer, field, untyped); } } - if (HasFieldPresence(field)) { + // Generate clearFoo() method for map fields, repeated fields, and other + // fields with presence. + if (IsMap(options, field)) { + printer->Print( + "$class$.prototype.clear$name$ = function() {\n" + " this.get$name$().clear();$returnvalue$\n" + "};\n" + "\n" + "\n", + "class", GetPath(options, field->containing_type()), + "name", JSGetterName(options, field), + "returnvalue", JSReturnClause(field)); + } else if (field->is_repeated() || + (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + !field->is_required())) { + // Fields where we can delegate to the regular setter. + printer->Print( + "$class$.prototype.clear$name$ = function() {\n" + " this.set$name$($clearedvalue$);$returnvalue$\n" + "};\n" + "\n" + "\n", + "class", GetPath(options, field->containing_type()), + "name", JSGetterName(options, field), + "clearedvalue", (field->is_repeated() ? "[]" : "undefined"), + "returnvalue", JSReturnClause(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. + printer->Print( + "$class$.prototype.clear$name$ = function() {\n" + " jspb.Message.set$maybeoneof$Field(this, " + "$index$$maybeoneofgroup$, ", + "class", GetPath(options, field->containing_type()), + "name", JSGetterName(options, field), + "maybeoneof", (field->containing_oneof() ? "Oneof" : ""), + "maybeoneofgroup", (field->containing_oneof() ? + (", " + JSOneofArray(options, field)) : ""), + "index", JSFieldIndex(field)); + printer->Print( + "$clearedvalue$);$returnvalue$\n" + "};\n" + "\n" + "\n", + "clearedvalue", (field->is_repeated() ? "[]" : "undefined"), + "returnvalue", JSReturnClause(field)); + } + + if (HasFieldPresence(options, field)) { printer->Print( "/**\n" " * Returns whether this field is set.\n" - " * @return{!boolean}\n" + " * @return {!boolean}\n" " */\n" "$class$.prototype.has$name$ = function() {\n" " return jspb.Message.getField(this, $index$) != null;\n" @@ -2513,6 +2631,59 @@ void Generator::GenerateClassField(const GeneratorOptions& options, } } +void Generator::GenerateRepeatedPrimitiveHelperMethods( + const GeneratorOptions& options, io::Printer* printer, + const FieldDescriptor* field, bool untyped) const { + printer->Print( + "/**\n" + " * @param {!$optionaltype$} value\n" + " * @param {number=} opt_index\n" + " */\n" + "$class$.prototype.add$name$ = function(value, opt_index) {\n" + " jspb.Message.addToRepeatedField(this, $index$", + "class", GetPath(options, field->containing_type()), "name", + JSGetterName(options, field, BYTES_DEFAULT, + /* drop_list = */ true), + "optionaltype", JSTypeName(options, field, BYTES_DEFAULT), "index", + JSFieldIndex(field)); + printer->Print( + "$oneofgroup$, $type$value$rptvalueinit$$typeclose$, opt_index);\n" + "};\n" + "\n" + "\n", + "type", untyped ? "/** @type{string|number|boolean|!Uint8Array} */(" : "", + "typeclose", untyped ? ")" : "", "oneofgroup", + (field->containing_oneof() ? (", " + JSOneofArray(options, field)) : ""), + "rptvalueinit", ""); +} + +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.add$name$ = function(opt_value, opt_index) {\n" + " return jspb.Message.addTo$repeatedtag$WrapperField(", + "optionaltype", JSTypeName(options, field, BYTES_DEFAULT), "class", + GetPath(options, field->containing_type()), "name", + JSGetterName(options, field, BYTES_DEFAULT, + /* drop_list = */ true), + "repeatedtag", (field->is_repeated() ? "Repeated" : "")); + + printer->Print( + "this, $index$$oneofgroup$, opt_value, $ctor$, opt_index);\n" + "};\n" + "\n" + "\n", + "index", JSFieldIndex(field), "oneofgroup", + (field->containing_oneof() ? (", " + JSOneofArray(options, field)) : ""), + "ctor", GetPath(options, field->message_type())); +} + void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc) const { @@ -2554,7 +2725,7 @@ void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options, "so that it\n" " * works in OPTIMIZED mode.\n" " *\n" - " * @type {!Object.<number, jspb.ExtensionFieldInfo>}\n" + " * @type {!Object.<number, jspb.ExtensionFieldBinaryInfo>}\n" " */\n" "$class$.extensionsBinary = {};\n" "\n", @@ -2636,7 +2807,7 @@ void Generator::GenerateClassDeserializeBinaryField( printer->Print(" case $num$:\n", "num", SimpleItoa(field->number())); - if (field->is_map()) { + if (IsMap(options, field)) { const FieldDescriptor* key_field = MapFieldKey(field); const FieldDescriptor* value_field = MapFieldValue(field); printer->Print( @@ -2757,11 +2928,18 @@ void Generator::GenerateClassSerializeBinaryField( const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field) const { - if (HasFieldPresence(field) && + if (HasFieldPresence(options, field) && field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) { + 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 = jspb.Message.getField(this, $index$);\n", - "index", JSFieldIndex(field)); + " f = /** @type {$type$} */ (jspb.Message.getField(this, $index$));\n", + "index", JSFieldIndex(field), + "type", typed_annotation); } else { printer->Print( " f = this.get$name$($nolazy$);\n", @@ -2770,17 +2948,16 @@ void Generator::GenerateClassSerializeBinaryField( "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()) { + if (IsMap(options, field)) { printer->Print( " if (f && f.getLength() > 0) {\n"); } else if (field->is_repeated()) { printer->Print( " if (f.length > 0) {\n"); } else { - if (HasFieldPresence(field)) { + if (HasFieldPresence(options, field)) { printer->Print( " if (f != null) {\n"); } else { @@ -2820,7 +2997,7 @@ void Generator::GenerateClassSerializeBinaryField( } // Write the field on the wire. - if (field->is_map()) { + if (IsMap(options, field)) { const FieldDescriptor* key_field = MapFieldKey(field); const FieldDescriptor* value_field = MapFieldValue(field); printer->Print( @@ -2845,7 +3022,7 @@ void Generator::GenerateClassSerializeBinaryField( "index", SimpleItoa(field->number())); if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - !(field->is_map())) { + !IsMap(options, field)) { printer->Print( ",\n" " $submsg$.serializeBinaryToWriter\n", @@ -2907,7 +3084,7 @@ void Generator::GenerateExtension(const GeneratorOptions& options, "class", extension_scope, "extensionType", JSFieldTypeAnnotation( options, field, - /* force_optional = */ false, + /* is_setter_argument = */ false, /* force_present = */ true, /* singular_if_not_packed = */ false)); printer->Print( @@ -2946,11 +3123,11 @@ void Generator::GenerateExtension(const GeneratorOptions& options, "binaryMessageSerializeFn", (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ? (SubmessageTypeRef(options, field) + - ".serializeBinaryToWriter") : "null", + ".serializeBinaryToWriter") : "undefined", "binaryMessageDeserializeFn", (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ? (SubmessageTypeRef(options, field) + - ".deserializeBinaryFromReader") : "null"); + ".deserializeBinaryFromReader") : "undefined"); printer->Print( " $isPacked$);\n", @@ -3005,17 +3182,31 @@ bool GeneratorOptions::ParseFromOptions( library = options[i].second; } else if (options[i].first == "import_style") { if (options[i].second == "closure") { - import_style = IMPORT_CLOSURE; + import_style = kImportClosure; } else if (options[i].second == "commonjs") { - import_style = IMPORT_COMMONJS; + import_style = kImportCommonJs; } else if (options[i].second == "browser") { - import_style = IMPORT_BROWSER; + import_style = kImportBrowser; } else if (options[i].second == "es6") { - import_style = IMPORT_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 == "broken_proto3_semantics") { + if (!options[i].second.empty()) { + *error = "Unexpected option value for broken_proto3_semantics"; + return false; + } + broken_proto3_semantics = true; } else { // Assume any other option is an output directory, as long as it is a bare // `key` rather than a `key=value` option. @@ -3027,14 +3218,37 @@ bool GeneratorOptions::ParseFromOptions( } } - if (!library.empty() && import_style != IMPORT_CLOSURE) { - *error = "The library option should only be used for " - "import_style=closure"; + if (import_style != kImportClosure && + (add_require_for_enums || testonly || !library.empty() || + error_on_name_conflict || broken_proto3_semantics || + extension != ".js" || one_output_file_per_input_file)) { + *error = + "The add_require_for_enums, testonly, library, error_on_name_conflict, " + "broken_proto3_semantics, 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 type. + return kOneOutputFilePerType; +} + void Generator::GenerateFilesInDepOrder( const GeneratorOptions& options, io::Printer* printer, @@ -3081,7 +3295,7 @@ void Generator::GenerateFile(const GeneratorOptions& options, GenerateHeader(options, printer); // Generate "require" statements. - if (options.import_style == GeneratorOptions::IMPORT_COMMONJS) { + if (options.import_style == GeneratorOptions::kImportCommonJs) { printer->Print("var jspb = require('google-protobuf');\n"); printer->Print("var goog = jspb;\n"); printer->Print("var global = Function('return this')();\n\n"); @@ -3091,42 +3305,43 @@ void Generator::GenerateFile(const GeneratorOptions& options, printer->Print( "var $alias$ = require('$file$');\n", "alias", ModuleAlias(name), - "file", GetRootPath(file->name(), name) + GetJSFilename(name)); + "file", GetRootPath(file->name(), name) + GetJSFilename(options, name)); } } - // 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() { /* ... */ } set<string> provided; - - // Cover the case where this file declares extensions but no messages. - // This will ensure that the file-level object will be declared to hold - // the extensions. + set<const FieldDescriptor*> extensions; for (int i = 0; i < file->extension_count(); i++) { - provided.insert(file->extension(i)->full_name()); + // 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(GetPath(options, file) + "." + + JSObjectFieldName(options, file->extension(i))); + extensions.insert(file->extension(i)); } FindProvidesForFile(options, printer, file, &provided); - for (std::set<string>::iterator it = provided.begin(); - it != provided.end(); ++it) { - printer->Print("goog.exportSymbol('$name$', null, global);\n", - "name", *it); + GenerateProvides(options, printer, &provided); + vector<const FileDescriptor*> files; + files.push_back(file); + if (options.import_style == GeneratorOptions::kImportClosure) { + GenerateRequiresForLibrary(options, printer, files, &provided); } GenerateClassesAndEnums(options, printer, file); - // Extensions nested inside messages are emitted inside - // GenerateClassesAndEnums(). - for (int i = 0; i < file->extension_count(); i++) { - GenerateExtension(options, printer, file->extension(i)); + // Generate code for top-level extensions. Extensions nested inside messages + // are emitted inside GenerateClassesAndEnums(). + for (set<const FieldDescriptor*>::const_iterator it = extensions.begin(); + it != extensions.end(); ++it) { + GenerateExtension(options, printer, *it); } - if (options.import_style == GeneratorOptions::IMPORT_COMMONJS) { + if (options.import_style == GeneratorOptions::kImportCommonJs) { printer->Print("goog.object.extend(exports, $package$);\n", "package", GetPath(options, file)); } @@ -3144,15 +3359,10 @@ bool Generator::GenerateAll(const vector<const FileDescriptor*>& files, } - // There are three schemes for where output files go: - // - // - import_style = IMPORT_CLOSURE, library non-empty: all output in one file - // - import_style = IMPORT_CLOSURE, library empty: one output file per type - // - import_style != IMPORT_CLOSURE: one output file per .proto file - if (options.import_style == GeneratorOptions::IMPORT_CLOSURE && - options.library != "") { + if (options.output_mode() == GeneratorOptions::kEverythingInOneFile) { // All output should go in a single file. - string filename = options.output_dir + "/" + options.library + ".js"; + string filename = options.output_dir + "/" + options.library + + options.GetFileNameExtension(); google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(context->Open(filename)); GOOGLE_CHECK(output.get()); io::Printer printer(output.get(), '$'); @@ -3187,7 +3397,7 @@ bool Generator::GenerateAll(const vector<const FileDescriptor*>& files, if (printer.failed()) { return false; } - } else if (options.import_style == GeneratorOptions::IMPORT_CLOSURE) { + } else if (options.output_mode() == GeneratorOptions::kOneOutputFilePerType) { set<const void*> allowed_set; if (!GenerateJspbAllowedSet(options, files, &allowed_set, error)) { return false; @@ -3279,13 +3489,14 @@ bool Generator::GenerateAll(const vector<const FileDescriptor*>& files, } } } - } else { + } else /* options.output_mode() == kOneOutputFilePerInputFile */ { // Generate one output file per input (.proto) file. for (int i = 0; i < files.size(); i++) { const google::protobuf::FileDescriptor* file = files[i]; - string filename = options.output_dir + "/" + GetJSFilename(file->name()); + string filename = + options.output_dir + "/" + GetJSFilename(options, file->name()); google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(context->Open(filename)); GOOGLE_CHECK(output.get()); io::Printer printer(output.get(), '$'); diff --git a/src/google/protobuf/compiler/js/js_generator.h b/src/google/protobuf/compiler/js/js_generator.h index 056c9897..4ca3493c 100755 --- a/src/google/protobuf/compiler/js/js_generator.h +++ b/src/google/protobuf/compiler/js/js_generator.h @@ -36,6 +36,8 @@ #include <string> #include <set> +#include <google/protobuf/stubs/logging.h> +#include <google/protobuf/stubs/common.h> #include <google/protobuf/compiler/code_generator.h> namespace google { @@ -53,43 +55,74 @@ namespace compiler { namespace js { struct GeneratorOptions { - // 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; // Output path. string output_dir; // Namespace prefix. string namespace_prefix; - // Create a library with name <name>_lib.js rather than a separate .js file - // per type? - string library; - // Error if there are two types that would generate the same output file? - bool error_on_name_conflict; // Enable binary-format support? bool binary; // What style of imports should be used. enum ImportStyle { - IMPORT_CLOSURE, // goog.require() - IMPORT_COMMONJS, // require() - IMPORT_BROWSER, // no import statements - IMPORT_ES6, // import { member } from '' + kImportClosure, // goog.require() + kImportCommonJs, // require() + kImportBrowser, // no import statements + kImportEs6, // import { member } from '' } import_style; GeneratorOptions() - : add_require_for_enums(false), - testonly(false), - output_dir("."), + : output_dir("."), namespace_prefix(""), + binary(false), + import_style(kImportClosure), + add_require_for_enums(false), + testonly(false), library(""), error_on_name_conflict(false), - binary(false), - import_style(IMPORT_CLOSURE) {} + broken_proto3_semantics(false), + extension(".js"), + one_output_file_per_input_file(false) {} bool ParseFromOptions( const vector< pair< string, string > >& options, string* error); + + // Returns the file name extension to use for generated code. + 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. + kOneOutputFilePerType, + // 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? + string library; + // Error if there are two types that would generate the same output file? + bool error_on_name_conflict; + // Preserve the broken proto3 semantics from the old codegen? This amounts + // to using proto2 field presence semantics even for proto3 files. DO NOT + // USE except for migrating legacy code. + bool broken_proto3_semantics; + // The extension to use for output file names. + string extension; + // Create a separate output file for each input file? + bool one_output_file_per_input_file; }; // CodeGenerator implementation which generates a JavaScript source file and @@ -207,6 +240,11 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { 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, @@ -276,6 +314,17 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { 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); }; diff --git a/src/google/protobuf/compiler/main.cc b/src/google/protobuf/compiler/main.cc index b83b8f32..aca2a5b9 100644 --- a/src/google/protobuf/compiler/main.cc +++ b/src/google/protobuf/compiler/main.cc @@ -32,14 +32,20 @@ #include <google/protobuf/compiler/command_line_interface.h> #include <google/protobuf/compiler/cpp/cpp_generator.h> + +#ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP #include <google/protobuf/compiler/python/python_generator.h> #include <google/protobuf/compiler/java/java_generator.h> +#endif // ! OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP + +#ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP #include <google/protobuf/compiler/javanano/javanano_generator.h> #include <google/protobuf/compiler/php/php_generator.h> #include <google/protobuf/compiler/ruby/ruby_generator.h> #include <google/protobuf/compiler/csharp/csharp_generator.h> #include <google/protobuf/compiler/objectivec/objectivec_generator.h> #include <google/protobuf/compiler/js/js_generator.h> +#endif // ! OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP int main(int argc, char* argv[]) { @@ -51,12 +57,15 @@ int main(int argc, char* argv[]) { cli.RegisterGenerator("--cpp_out", "--cpp_opt", &cpp_generator, "Generate C++ header and source."); +#ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP // Proto2 Java google::protobuf::compiler::java::JavaGenerator java_generator; cli.RegisterGenerator("--java_out", &java_generator, "Generate Java source file."); +#endif // !OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP +#ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP // Proto2 Python google::protobuf::compiler::python::Generator py_generator; cli.RegisterGenerator("--python_out", &py_generator, @@ -91,6 +100,7 @@ int main(int argc, char* argv[]) { google::protobuf::compiler::js::Generator js_generator; cli.RegisterGenerator("--js_out", &js_generator, "Generate JavaScript source."); +#endif // !OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP return cli.Run(argc, argv); } diff --git a/src/google/protobuf/compiler/plugin.cc b/src/google/protobuf/compiler/plugin.cc index 2ff50f61..e1087601 100644 --- a/src/google/protobuf/compiler/plugin.cc +++ b/src/google/protobuf/compiler/plugin.cc @@ -118,35 +118,16 @@ bool GenerateCode(const CodeGeneratorRequest& request, GeneratorResponseContext context(response, parsed_files); - if (generator.HasGenerateAll()) { - string error; - bool succeeded = generator.GenerateAll( - parsed_files, request.parameter(), &context, &error); - - if (!succeeded && error.empty()) { - error = "Code generator returned false but provided no error " - "description."; - } - if (!error.empty()) { - response->set_error(error); - } - } else { - for (int i = 0; i < parsed_files.size(); i++) { - const FileDescriptor* file = parsed_files[i]; - - string error; - bool succeeded = generator.Generate( - file, request.parameter(), &context, &error); - - if (!succeeded && error.empty()) { - error = "Code generator returned false but provided no error " - "description."; - } - if (!error.empty()) { - response->set_error(file->name() + ": " + error); - break; - } - } + string error; + bool succeeded = generator.GenerateAll( + parsed_files, request.parameter(), &context, &error); + + if (!succeeded && error.empty()) { + error = "Code generator returned false but provided no error " + "description."; + } + if (!error.empty()) { + response->set_error(error); } return true; diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index 5247f9a2..1c19d46a 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -52,14 +52,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { CodeGeneratorRequest_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( CodeGeneratorRequest_descriptor_, - CodeGeneratorRequest::default_instance_, + CodeGeneratorRequest::internal_default_instance(), CodeGeneratorRequest_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_), -1, -1, sizeof(CodeGeneratorRequest), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_)); CodeGeneratorResponse_descriptor_ = file->message_type(1); static const int CodeGeneratorResponse_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_), @@ -68,14 +67,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { CodeGeneratorResponse_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( CodeGeneratorResponse_descriptor_, - CodeGeneratorResponse::default_instance_, + CodeGeneratorResponse::internal_default_instance(), CodeGeneratorResponse_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_), -1, -1, sizeof(CodeGeneratorResponse), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_)); CodeGeneratorResponse_File_descriptor_ = CodeGeneratorResponse_descriptor_->nested_type(0); static const int CodeGeneratorResponse_File_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, name_), @@ -85,20 +83,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { CodeGeneratorResponse_File_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( CodeGeneratorResponse_File_descriptor_, - CodeGeneratorResponse_File::default_instance_, + CodeGeneratorResponse_File::internal_default_instance(), CodeGeneratorResponse_File_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_), -1, -1, sizeof(CodeGeneratorResponse_File), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _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_2fcompiler_2fplugin_2eproto); } @@ -107,32 +104,45 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorRequest_descriptor_, &CodeGeneratorRequest::default_instance()); + CodeGeneratorRequest_descriptor_, CodeGeneratorRequest::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorResponse_descriptor_, &CodeGeneratorResponse::default_instance()); + CodeGeneratorResponse_descriptor_, CodeGeneratorResponse::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorResponse_File_descriptor_, &CodeGeneratorResponse_File::default_instance()); + CodeGeneratorResponse_File_descriptor_, CodeGeneratorResponse_File::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - delete CodeGeneratorRequest::default_instance_; delete CodeGeneratorRequest_reflection_; - delete CodeGeneratorResponse::default_instance_; delete CodeGeneratorResponse_reflection_; - delete CodeGeneratorResponse_File::default_instance_; delete CodeGeneratorResponse_File_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + ::google::protobuf::internal::GetEmptyString(); + CodeGeneratorRequest::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + CodeGeneratorResponse::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + CodeGeneratorResponse_File::default_instance_.DefaultConstruct(); + CodeGeneratorRequest::default_instance_.get_mutable()->InitAsDefaultInstance(); + CodeGeneratorResponse::default_instance_.get_mutable()->InitAsDefaultInstance(); + CodeGeneratorResponse_File::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n%google/protobuf/compiler/plugin.proto\022" "\030google.protobuf.compiler\032 google/protob" @@ -148,15 +158,15 @@ void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { "rotosZ\tplugin_go", 456); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/compiler/plugin.proto", &protobuf_RegisterTypes); - CodeGeneratorRequest::default_instance_ = new CodeGeneratorRequest(); - CodeGeneratorResponse::default_instance_ = new CodeGeneratorResponse(); - CodeGeneratorResponse_File::default_instance_ = new CodeGeneratorResponse_File(); - CodeGeneratorRequest::default_instance_->InitAsDefaultInstance(); - CodeGeneratorResponse::default_instance_->InitAsDefaultInstance(); - CodeGeneratorResponse_File::default_instance_->InitAsDefaultInstance(); + ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { @@ -164,6 +174,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto } } static_descriptor_initializer_google_2fprotobuf_2fcompiler_2fplugin_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 @@ -174,6 +194,7 @@ const int CodeGeneratorRequest::kProtoFileFieldNumber; CodeGeneratorRequest::CodeGeneratorRequest() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorRequest) } @@ -185,15 +206,13 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorRequest) } void CodeGeneratorRequest::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; parameter_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } CodeGeneratorRequest::~CodeGeneratorRequest() { @@ -203,8 +222,6 @@ CodeGeneratorRequest::~CodeGeneratorRequest() { void CodeGeneratorRequest::SharedDtor() { parameter_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void CodeGeneratorRequest::SetCachedSize(int size) const { @@ -218,11 +235,11 @@ const ::google::protobuf::Descriptor* CodeGeneratorRequest::descriptor() { } const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + return *internal_default_instance(); } -CodeGeneratorRequest* CodeGeneratorRequest::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> CodeGeneratorRequest::default_instance_; CodeGeneratorRequest* CodeGeneratorRequest::New(::google::protobuf::Arena* arena) const { CodeGeneratorRequest* n = new CodeGeneratorRequest; @@ -239,7 +256,7 @@ void CodeGeneratorRequest::Clear() { } file_to_generate_.Clear(); proto_file_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -406,9 +423,9 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( return target; } -int CodeGeneratorRequest::ByteSize() const { +size_t CodeGeneratorRequest::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorRequest) - int total_size = 0; + size_t total_size = 0; // optional string parameter = 2; if (has_parameter()) { @@ -418,18 +435,22 @@ int CodeGeneratorRequest::ByteSize() const { } // repeated string file_to_generate = 1; - total_size += 1 * this->file_to_generate_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->file_to_generate_size()); for (int i = 0; i < this->file_to_generate_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->file_to_generate(i)); } // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - total_size += 1 * this->proto_file_size(); - for (int i = 0; i < this->proto_file_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->proto_file(i)); + { + unsigned int count = this->proto_file_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->proto_file(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -437,18 +458,17 @@ int CodeGeneratorRequest::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 CodeGeneratorRequest::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const CodeGeneratorRequest* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const CodeGeneratorRequest* source = ::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorRequest>( &from); if (source == NULL) { @@ -456,16 +476,22 @@ void CodeGeneratorRequest::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorRequest) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } - file_to_generate_.MergeFrom(from.file_to_generate_); +} + +void CodeGeneratorRequest::UnsafeMergeFrom(const CodeGeneratorRequest& from) { + GOOGLE_DCHECK(&from != this); + file_to_generate_.UnsafeMergeFrom(from.file_to_generate_); proto_file_.MergeFrom(from.proto_file_); if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) { if (from.has_parameter()) { @@ -474,7 +500,8 @@ void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -489,7 +516,7 @@ void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorRequest) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool CodeGeneratorRequest::IsInitialized() const { @@ -529,49 +556,49 @@ int CodeGeneratorRequest::file_to_generate_size() const { void CodeGeneratorRequest::clear_file_to_generate() { file_to_generate_.Clear(); } - const ::std::string& CodeGeneratorRequest::file_to_generate(int index) const { +const ::std::string& CodeGeneratorRequest::file_to_generate(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) return file_to_generate_.Get(index); } - ::std::string* CodeGeneratorRequest::mutable_file_to_generate(int index) { +::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); } - void CodeGeneratorRequest::set_file_to_generate(int index, const ::std::string& value) { +void CodeGeneratorRequest::set_file_to_generate(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) file_to_generate_.Mutable(index)->assign(value); } - void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { +void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { file_to_generate_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } - void CodeGeneratorRequest::set_file_to_generate(int index, const char* value, size_t size) { +void CodeGeneratorRequest::set_file_to_generate(int index, const char* value, size_t size) { 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) } - ::std::string* CodeGeneratorRequest::add_file_to_generate() { +::std::string* CodeGeneratorRequest::add_file_to_generate() { // @@protoc_insertion_point(field_add_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) return file_to_generate_.Add(); } - void CodeGeneratorRequest::add_file_to_generate(const ::std::string& value) { +void CodeGeneratorRequest::add_file_to_generate(const ::std::string& value) { file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } - void CodeGeneratorRequest::add_file_to_generate(const char* value) { +void CodeGeneratorRequest::add_file_to_generate(const char* value) { file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } - void CodeGeneratorRequest::add_file_to_generate(const char* value, size_t size) { +void CodeGeneratorRequest::add_file_to_generate(const char* value, size_t size) { file_to_generate_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } - const ::google::protobuf::RepeatedPtrField< ::std::string>& +const ::google::protobuf::RepeatedPtrField< ::std::string>& CodeGeneratorRequest::file_to_generate() const { // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) return file_to_generate_; } - ::google::protobuf::RepeatedPtrField< ::std::string>* +::google::protobuf::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_; @@ -591,37 +618,37 @@ void CodeGeneratorRequest::clear_parameter() { parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_parameter(); } - const ::std::string& CodeGeneratorRequest::parameter() const { +const ::std::string& CodeGeneratorRequest::parameter() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter) return parameter_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorRequest::set_parameter(const ::std::string& value) { +void CodeGeneratorRequest::set_parameter(const ::std::string& value) { set_has_parameter(); parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter) } - void CodeGeneratorRequest::set_parameter(const char* value) { +void CodeGeneratorRequest::set_parameter(const char* value) { set_has_parameter(); parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.parameter) } - void CodeGeneratorRequest::set_parameter(const char* value, size_t size) { +void CodeGeneratorRequest::set_parameter(const char* value, size_t size) { set_has_parameter(); parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.parameter) } - ::std::string* CodeGeneratorRequest::mutable_parameter() { +::std::string* CodeGeneratorRequest::mutable_parameter() { set_has_parameter(); // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.parameter) return parameter_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* CodeGeneratorRequest::release_parameter() { +::std::string* CodeGeneratorRequest::release_parameter() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter) clear_has_parameter(); return parameter_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorRequest::set_allocated_parameter(::std::string* parameter) { +void CodeGeneratorRequest::set_allocated_parameter(::std::string* parameter) { if (parameter != NULL) { set_has_parameter(); } else { @@ -673,6 +700,7 @@ const int CodeGeneratorResponse_File::kContentFieldNumber; CodeGeneratorResponse_File::CodeGeneratorResponse_File() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse.File) } @@ -684,17 +712,15 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File) } void CodeGeneratorResponse_File::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); insertion_point_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); content_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } CodeGeneratorResponse_File::~CodeGeneratorResponse_File() { @@ -706,8 +732,6 @@ void CodeGeneratorResponse_File::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); insertion_point_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); content_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void CodeGeneratorResponse_File::SetCachedSize(int size) const { @@ -721,11 +745,11 @@ const ::google::protobuf::Descriptor* CodeGeneratorResponse_File::descriptor() { } const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + return *internal_default_instance(); } -CodeGeneratorResponse_File* CodeGeneratorResponse_File::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> CodeGeneratorResponse_File::default_instance_; CodeGeneratorResponse_File* CodeGeneratorResponse_File::New(::google::protobuf::Arena* arena) const { CodeGeneratorResponse_File* n = new CodeGeneratorResponse_File; @@ -748,7 +772,7 @@ void CodeGeneratorResponse_File::Clear() { content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -921,9 +945,9 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes( return target; } -int CodeGeneratorResponse_File::ByteSize() const { +size_t CodeGeneratorResponse_File::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse.File) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 7u) { // optional string name = 1; @@ -953,18 +977,17 @@ int CodeGeneratorResponse_File::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 CodeGeneratorResponse_File::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const CodeGeneratorResponse_File* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const CodeGeneratorResponse_File* source = ::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorResponse_File>( &from); if (source == NULL) { @@ -972,15 +995,21 @@ void CodeGeneratorResponse_File::MergeFrom(const ::google::protobuf::Message& fr ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorResponse.File) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void CodeGeneratorResponse_File::UnsafeMergeFrom(const CodeGeneratorResponse_File& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { set_has_name(); @@ -996,7 +1025,8 @@ void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& fro } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -1011,7 +1041,7 @@ void CodeGeneratorResponse_File::CopyFrom(const CodeGeneratorResponse_File& from // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool CodeGeneratorResponse_File::IsInitialized() const { @@ -1050,6 +1080,7 @@ const int CodeGeneratorResponse::kFileFieldNumber; CodeGeneratorResponse::CodeGeneratorResponse() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse) } @@ -1061,15 +1092,13 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse) } void CodeGeneratorResponse::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; error_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } CodeGeneratorResponse::~CodeGeneratorResponse() { @@ -1079,8 +1108,6 @@ CodeGeneratorResponse::~CodeGeneratorResponse() { void CodeGeneratorResponse::SharedDtor() { error_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void CodeGeneratorResponse::SetCachedSize(int size) const { @@ -1094,11 +1121,11 @@ const ::google::protobuf::Descriptor* CodeGeneratorResponse::descriptor() { } const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + return *internal_default_instance(); } -CodeGeneratorResponse* CodeGeneratorResponse::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> CodeGeneratorResponse::default_instance_; CodeGeneratorResponse* CodeGeneratorResponse::New(::google::protobuf::Arena* arena) const { CodeGeneratorResponse* n = new CodeGeneratorResponse; @@ -1114,7 +1141,7 @@ void CodeGeneratorResponse::Clear() { error_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } file_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -1241,9 +1268,9 @@ void CodeGeneratorResponse::SerializeWithCachedSizes( return target; } -int CodeGeneratorResponse::ByteSize() const { +size_t CodeGeneratorResponse::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse) - int total_size = 0; + size_t total_size = 0; // optional string error = 1; if (has_error()) { @@ -1253,11 +1280,14 @@ int CodeGeneratorResponse::ByteSize() const { } // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - total_size += 1 * this->file_size(); - for (int i = 0; i < this->file_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->file(i)); + { + unsigned int count = this->file_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->file(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -1265,18 +1295,17 @@ int CodeGeneratorResponse::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 CodeGeneratorResponse::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const CodeGeneratorResponse* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const CodeGeneratorResponse* source = ::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorResponse>( &from); if (source == NULL) { @@ -1284,15 +1313,21 @@ void CodeGeneratorResponse::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorResponse) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void CodeGeneratorResponse::UnsafeMergeFrom(const CodeGeneratorResponse& from) { + GOOGLE_DCHECK(&from != this); file_.MergeFrom(from.file_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_error()) { @@ -1301,7 +1336,8 @@ void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -1316,7 +1352,7 @@ void CodeGeneratorResponse::CopyFrom(const CodeGeneratorResponse& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool CodeGeneratorResponse::IsInitialized() const { @@ -1361,37 +1397,37 @@ void CodeGeneratorResponse_File::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& CodeGeneratorResponse_File::name() const { +const ::std::string& CodeGeneratorResponse_File::name() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse_File::set_name(const ::std::string& value) { +void CodeGeneratorResponse_File::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) } - void CodeGeneratorResponse_File::set_name(const char* value) { +void CodeGeneratorResponse_File::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name) } - void CodeGeneratorResponse_File::set_name(const char* value, size_t size) { +void CodeGeneratorResponse_File::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.name) } - ::std::string* CodeGeneratorResponse_File::mutable_name() { +::std::string* CodeGeneratorResponse_File::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* CodeGeneratorResponse_File::release_name() { +::std::string* CodeGeneratorResponse_File::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) { +void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -1415,37 +1451,37 @@ void CodeGeneratorResponse_File::clear_insertion_point() { insertion_point_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_insertion_point(); } - const ::std::string& CodeGeneratorResponse_File::insertion_point() const { +const ::std::string& CodeGeneratorResponse_File::insertion_point() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) return insertion_point_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) { +void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) { set_has_insertion_point(); insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } - void CodeGeneratorResponse_File::set_insertion_point(const char* value) { +void CodeGeneratorResponse_File::set_insertion_point(const char* value) { set_has_insertion_point(); insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } - void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) { +void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) { set_has_insertion_point(); insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } - ::std::string* CodeGeneratorResponse_File::mutable_insertion_point() { +::std::string* CodeGeneratorResponse_File::mutable_insertion_point() { set_has_insertion_point(); // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) return insertion_point_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* CodeGeneratorResponse_File::release_insertion_point() { +::std::string* CodeGeneratorResponse_File::release_insertion_point() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) clear_has_insertion_point(); return insertion_point_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) { +void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) { if (insertion_point != NULL) { set_has_insertion_point(); } else { @@ -1469,37 +1505,37 @@ void CodeGeneratorResponse_File::clear_content() { content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_content(); } - const ::std::string& CodeGeneratorResponse_File::content() const { +const ::std::string& CodeGeneratorResponse_File::content() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content) return content_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse_File::set_content(const ::std::string& value) { +void CodeGeneratorResponse_File::set_content(const ::std::string& value) { set_has_content(); content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) } - void CodeGeneratorResponse_File::set_content(const char* value) { +void CodeGeneratorResponse_File::set_content(const char* value) { set_has_content(); content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content) } - void CodeGeneratorResponse_File::set_content(const char* value, size_t size) { +void CodeGeneratorResponse_File::set_content(const char* value, size_t size) { set_has_content(); content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.content) } - ::std::string* CodeGeneratorResponse_File::mutable_content() { +::std::string* CodeGeneratorResponse_File::mutable_content() { set_has_content(); // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.content) return content_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* CodeGeneratorResponse_File::release_content() { +::std::string* CodeGeneratorResponse_File::release_content() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content) clear_has_content(); return content_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) { +void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) { if (content != NULL) { set_has_content(); } else { @@ -1527,37 +1563,37 @@ void CodeGeneratorResponse::clear_error() { error_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_error(); } - const ::std::string& CodeGeneratorResponse::error() const { +const ::std::string& CodeGeneratorResponse::error() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error) return error_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse::set_error(const ::std::string& value) { +void CodeGeneratorResponse::set_error(const ::std::string& value) { set_has_error(); error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error) } - void CodeGeneratorResponse::set_error(const char* value) { +void CodeGeneratorResponse::set_error(const char* value) { set_has_error(); error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.error) } - void CodeGeneratorResponse::set_error(const char* value, size_t size) { +void CodeGeneratorResponse::set_error(const char* value, size_t size) { set_has_error(); error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.error) } - ::std::string* CodeGeneratorResponse::mutable_error() { +::std::string* CodeGeneratorResponse::mutable_error() { set_has_error(); // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.error) return error_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* CodeGeneratorResponse::release_error() { +::std::string* CodeGeneratorResponse::release_error() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error) clear_has_error(); return error_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse::set_allocated_error(::std::string* error) { +void CodeGeneratorResponse::set_allocated_error(::std::string* error) { if (error != NULL) { set_has_error(); } else { diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 13eeb69f..12ad1297 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -36,6 +36,7 @@ namespace compiler { // Internal implementation detail -- do not call these. void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); +void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); @@ -68,6 +69,10 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorRequest& default_instance(); + static inline const CodeGeneratorRequest* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(CodeGeneratorRequest* other); // implements Message ---------------------------------------------- @@ -82,7 +87,7 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -98,6 +103,7 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(CodeGeneratorRequest* other); + void UnsafeMergeFrom(const CodeGeneratorRequest& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -159,17 +165,18 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message inline void clear_has_parameter(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::std::string> file_to_generate_; - ::google::protobuf::internal::ArenaStringPtr parameter_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > proto_file_; - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + ::google::protobuf::internal::ArenaStringPtr parameter_; + friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); + friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); void InitAsDefaultInstance(); - static CodeGeneratorRequest* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> default_instance_; }; // ------------------------------------------------------------------- @@ -196,6 +203,10 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorResponse_File& default_instance(); + static inline const CodeGeneratorResponse_File* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(CodeGeneratorResponse_File* other); // implements Message ---------------------------------------------- @@ -210,7 +221,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -226,6 +237,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(CodeGeneratorResponse_File* other); + void UnsafeMergeFrom(const CodeGeneratorResponse_File& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -287,17 +299,18 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M inline void clear_has_content(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr insertion_point_; ::google::protobuf::internal::ArenaStringPtr content_; - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); + friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); void InitAsDefaultInstance(); - static CodeGeneratorResponse_File* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> default_instance_; }; // ------------------------------------------------------------------- @@ -324,6 +337,10 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorResponse& default_instance(); + static inline const CodeGeneratorResponse* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(CodeGeneratorResponse* other); // implements Message ---------------------------------------------- @@ -338,7 +355,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -354,6 +371,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(CodeGeneratorResponse* other); + void UnsafeMergeFrom(const CodeGeneratorResponse& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -401,16 +419,17 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag inline void clear_has_error(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::internal::ArenaStringPtr error_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File > file_; - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + ::google::protobuf::internal::ArenaStringPtr error_; + friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); + friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); void InitAsDefaultInstance(); - static CodeGeneratorResponse* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc index d5468a0c..3b1b0d1d 100644 --- a/src/google/protobuf/compiler/python/python_generator.cc +++ b/src/google/protobuf/compiler/python/python_generator.cc @@ -88,8 +88,8 @@ string StripProto(const string& filename) { // Returns the Python module name expected for a given .proto filename. string ModuleName(const string& filename) { string basename = StripProto(filename); - StripString(&basename, "-", '_'); - StripString(&basename, "/", '.'); + ReplaceCharacters(&basename, "-", '_'); + ReplaceCharacters(&basename, "/", '.'); return basename + "_pb2"; } @@ -320,7 +320,7 @@ bool Generator::Generate(const FileDescriptor* file, file_ = file; string module_name = ModuleName(file->name()); string filename = module_name; - StripString(&filename, ".", '/'); + ReplaceCharacters(&filename, ".", '/'); filename += ".py"; FileDescriptorProto fdp; @@ -430,6 +430,15 @@ void Generator::PrintFileDescriptor() const { } printer_->Print("]"); } + if (file_->public_dependency_count() > 0) { + printer_->Print(",\npublic_dependencies=["); + for (int i = 0; i < file_->public_dependency_count(); ++i) { + string module_alias = ModuleAlias(file_->public_dependency(i)->name()); + printer_->Print("$module_alias$.DESCRIPTOR,", "module_alias", + module_alias); + } + printer_->Print("]"); + } // TODO(falk): Also print options and fix the message_type, enum_type, // service and extension later in the generation. @@ -1094,6 +1103,8 @@ void Generator::PrintFieldDescriptor( m["default_value"] = StringifyDefaultValue(field); m["is_extension"] = is_extension ? "True" : "False"; m["options"] = OptionsValue("FieldOptions", options_string); + m["json_name"] = field.has_json_name() ? + ", json_name='" + field.json_name() + "'": ""; // We always set message_type and enum_type to None at this point, and then // these fields in correctly after all referenced descriptors have been // defined and/or imported (see FixForeignFieldsInDescriptors()). @@ -1104,7 +1115,7 @@ void Generator::PrintFieldDescriptor( " has_default_value=$has_default_value$, default_value=$default_value$,\n" " message_type=None, enum_type=None, containing_type=None,\n" " is_extension=$is_extension$, extension_scope=None,\n" - " options=$options$)"; + " options=$options$$json_name$)"; printer_->Print(m, field_descriptor_decl); } diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 9b20946c..4dccb585 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -69,6 +69,7 @@ #undef PACKAGE // autoheader #defines this. :( namespace google { + namespace protobuf { const FieldDescriptor::CppType @@ -164,6 +165,15 @@ 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; +} + string ToCamelCase(const string& input, bool lower_first) { bool capitalize_next = !lower_first; string result; @@ -173,12 +183,7 @@ string ToCamelCase(const string& input, bool lower_first) { if (input[i] == '_') { capitalize_next = true; } else if (capitalize_next) { - // Note: I distrust ctype.h due to locales. - if ('a' <= input[i] && input[i] <= 'z') { - result.push_back(input[i] - 'a' + 'A'); - } else { - result.push_back(input[i]); - } + result.push_back(ToUpper(input[i])); capitalize_next = false; } else { result.push_back(input[i]); @@ -186,13 +191,116 @@ string ToCamelCase(const string& input, bool lower_first) { } // Lower-case the first letter. - if (lower_first && !result.empty() && 'A' <= result[0] && result[0] <= 'Z') { - result[0] = result[0] - 'A' + 'a'; + if (lower_first && !result.empty()) { + result[0] = ToLower(result[0]); } return result; } +string ToJsonName(const string& input) { + bool capitalize_next = false; + string result; + result.reserve(input.size()); + + for (int i = 0; i < input.size(); i++) { + if (input[i] == '_') { + capitalize_next = true; + } else if (capitalize_next) { + result.push_back(ToUpper(input[i])); + capitalize_next = false; + } else { + result.push_back(input[i]); + } + } + + return result; +} + +string EnumValueToPascalCase(const string& input) { + bool next_upper = true; + string result; + result.reserve(input.size()); + + for (int i = 0; i < input.size(); i++) { + if (input[i] == '_') { + next_upper = true; + } else { + if (next_upper) { + result.push_back(ToUpper(input[i])); + } else { + result.push_back(ToLower(input[i])); + } + next_upper = false; + } + } + + return result; +} + +// Class to remove an enum prefix from enum values. +class PrefixRemover { + public: + PrefixRemover(StringPiece prefix) { + // Strip underscores and lower-case the prefix. + for (int i = 0; i < prefix.size(); i++) { + if (prefix[i] != '_') { + prefix_ += ascii_tolower(prefix[i]); + } + } + } + + // Tries to remove the enum prefix from this enum value. + // If this is not possible, returns the input verbatim. + string MaybeRemove(StringPiece str) { + // We can't just lowercase and strip str and look for a prefix. + // We need to properly recognize the difference between: + // + // enum Foo { + // FOO_BAR_BAZ = 0; + // FOO_BARBAZ = 1; + // } + // + // This is acceptable (though perhaps not advisable) because even when + // we PascalCase, these two will still be distinct (BarBaz vs. Barbaz). + size_t i, j; + + // Skip past prefix_ in str if we can. + for (i = 0, j = 0; i < str.size() && j < prefix_.size(); i++) { + if (str[i] == '_') { + continue; + } + + if (ascii_tolower(str[i]) != prefix_[j++]) { + return str.as_string(); + } + } + + // If we didn't make it through the prefix, we've failed to strip the + // prefix. + if (j < prefix_.size()) { + return str.as_string(); + } + + // Skip underscores between prefix and further characters. + while (i < str.size() && str[i] == '_') { + i++; + } + + // Enum label can't be the empty string. + if (i == str.size()) { + return str.as_string(); + } + + // We successfully stripped the prefix. + str.remove_prefix(i); + return str.as_string(); + } + + private: + string prefix_; +}; + // A DescriptorPool contains a bunch of hash_maps to implement the // various Find*By*() methods. Since hashtable lookups are O(1), it's // most efficient to construct a fixed set of large hash_maps used by @@ -2390,6 +2498,17 @@ void FieldDescriptor::DebugString(int depth, strings::SubstituteAndAppend(contents, " [default = $0", DefaultValueAsString(true)); } + if (has_json_name_) { + if (!bracketed) { + bracketed = true; + contents->append("["); + } else { + contents->append(", "); + } + contents->append("json_name = \""); + contents->append(CEscape(json_name())); + contents->append("\""); + } string formatted_options; if (FormatBracketedOptions(depth, options(), &formatted_options)) { @@ -2980,6 +3099,8 @@ class DescriptorBuilder { void BuildOneof(const OneofDescriptorProto& proto, Descriptor* parent, OneofDescriptor* result); + void CheckEnumValueUniqueness(const EnumDescriptorProto& proto, + const EnumDescriptor* result); void BuildEnum(const EnumDescriptorProto& proto, const Descriptor* parent, EnumDescriptor* result); @@ -4232,7 +4353,7 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, result->json_name_ = tables_->AllocateString(proto.json_name()); } else { result->has_json_name_ = false; - result->json_name_ = result->camelcase_name_; + result->json_name_ = tables_->AllocateString(ToJsonName(proto.name())); } // Some compilers do not allow static_cast directly between two enum types, @@ -4540,6 +4661,61 @@ void DescriptorBuilder::BuildOneof(const OneofDescriptorProto& proto, proto, Symbol(result)); } +void DescriptorBuilder::CheckEnumValueUniqueness( + const EnumDescriptorProto& proto, const EnumDescriptor* result) { + + // Check that enum labels are still unique when we remove the enum prefix from + // values that have it. + // + // This will fail for something like: + // + // enum MyEnum { + // MY_ENUM_FOO = 0; + // FOO = 1; + // } + // + // By enforcing this reasonable constraint, we allow code generators to strip + // the prefix and/or PascalCase it without creating conflicts. This can lead + // to much nicer language-specific enums like: + // + // enum NameType { + // FirstName = 1, + // LastName = 2, + // } + // + // Instead of: + // + // enum NameType { + // NAME_TYPE_FIRST_NAME = 1, + // NAME_TYPE_LAST_NAME = 2, + // } + PrefixRemover remover(result->name()); + map<string, const google::protobuf::EnumValueDescriptor*> values; + for (int i = 0; i < result->value_count(); i++) { + const google::protobuf::EnumValueDescriptor* value = result->value(i); + string stripped = + EnumValueToPascalCase(remover.MaybeRemove(value->name())); + std::pair<map<string, const google::protobuf::EnumValueDescriptor*>::iterator, bool> + insert_result = values.insert(std::make_pair(stripped, value)); + bool inserted = insert_result.second; + + // We don't throw the error if the two conflicting symbols are identical, or + // if they map to the same number. In the former case, the normal symbol + // duplication error will fire so we don't need to (and its error message + // will make more sense). We allow the latter case so users can create + // aliases which add or remove the prefix (code generators that do prefix + // stripping should de-dup the labels in this case). + if (!inserted && insert_result.first->second->name() != value->name() && + insert_result.first->second->number() != value->number()) { + AddError(value->full_name(), proto.value(i), + DescriptorPool::ErrorCollector::NAME, + "When enum name is stripped and label is PascalCased (" + + stripped + "), this value label conflicts with " + + values[stripped]->name()); + } + } +} + void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, const Descriptor* parent, EnumDescriptor* result) { @@ -4568,6 +4744,8 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, BUILD_ARRAY(proto, result, value, BuildEnumValue, result); + CheckEnumValueUniqueness(proto, result); + // Copy options. if (!proto.has_options()) { result->options_ = NULL; // Will set to default_instance later. @@ -5254,7 +5432,6 @@ void DescriptorBuilder::ValidateProto3Enum( } } - void DescriptorBuilder::ValidateMessageOptions(Descriptor* message, const DescriptorProto& proto) { VALIDATE_OPTIONS_FROM_ARRAY(message, field, Field); @@ -5275,7 +5452,6 @@ void DescriptorBuilder::ValidateMessageOptions(Descriptor* message, max_extension_range)); } } - } void DescriptorBuilder::ValidateFieldOptions(FieldDescriptor* field, diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index b040b62c..0151e1d9 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -143,7 +143,7 @@ struct SourceLocation { // See the comments in SourceCodeInfo.Location (descriptor.proto) for details. string leading_comments; string trailing_comments; - vector<string> leading_detached_comments; + std::vector<string> leading_detached_comments; }; // Options when generating machine-parsable output from a descriptor with @@ -558,6 +558,10 @@ class LIBPROTOBUF_EXPORT FieldDescriptor { // Does this field have an explicitly-declared default value? bool has_default_value() const; + // Whether the user has specified the json_name field option in the .proto + // file. + bool has_json_name() const; + // Get the field default value if cpp_type() == CPPTYPE_INT32. If no // explicit default was defined, the default is 0. int32 default_value_int32() const; @@ -683,7 +687,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptor { // file. bool has_json_name_; // If has_json_name_ is true, it's the value specified by the user. - // Otherwise, it has the same value as lowercase_name_. + // Otherwise, it has the same value as camelcase_name_. const string* json_name_; const FileDescriptor* file_; int number_; @@ -1699,6 +1703,7 @@ PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, message_type, const Descriptor*) PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, enum_type, const EnumDescriptor*) PROTOBUF_DEFINE_OPTIONS_ACCESSOR(FieldDescriptor, FieldOptions) PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, has_default_value, bool) +PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, has_json_name, bool) PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_int32 , int32 ) PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_int64 , int64 ) PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_uint32, uint32) diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 56c3b7fb..3f310801 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -120,14 +120,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { FileDescriptorSet_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FileDescriptorSet_descriptor_, - FileDescriptorSet::default_instance_, + FileDescriptorSet::internal_default_instance(), FileDescriptorSet_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_), -1, -1, sizeof(FileDescriptorSet), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _internal_metadata_)); FileDescriptorProto_descriptor_ = file->message_type(1); static const int FileDescriptorProto_offsets_[12] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, name_), @@ -146,14 +145,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { FileDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FileDescriptorProto_descriptor_, - FileDescriptorProto::default_instance_, + FileDescriptorProto::internal_default_instance(), FileDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_), -1, -1, sizeof(FileDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _internal_metadata_)); DescriptorProto_descriptor_ = file->message_type(2); static const int DescriptorProto_offsets_[10] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, name_), @@ -170,14 +168,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { DescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( DescriptorProto_descriptor_, - DescriptorProto::default_instance_, + DescriptorProto::internal_default_instance(), DescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_), -1, -1, sizeof(DescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _internal_metadata_)); DescriptorProto_ExtensionRange_descriptor_ = DescriptorProto_descriptor_->nested_type(0); static const int DescriptorProto_ExtensionRange_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, start_), @@ -186,14 +183,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { DescriptorProto_ExtensionRange_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( DescriptorProto_ExtensionRange_descriptor_, - DescriptorProto_ExtensionRange::default_instance_, + DescriptorProto_ExtensionRange::internal_default_instance(), DescriptorProto_ExtensionRange_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _has_bits_), -1, -1, sizeof(DescriptorProto_ExtensionRange), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _internal_metadata_)); DescriptorProto_ReservedRange_descriptor_ = DescriptorProto_descriptor_->nested_type(1); static const int DescriptorProto_ReservedRange_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, start_), @@ -202,14 +198,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { DescriptorProto_ReservedRange_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( DescriptorProto_ReservedRange_descriptor_, - DescriptorProto_ReservedRange::default_instance_, + DescriptorProto_ReservedRange::internal_default_instance(), DescriptorProto_ReservedRange_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _has_bits_), -1, -1, sizeof(DescriptorProto_ReservedRange), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _internal_metadata_)); FieldDescriptorProto_descriptor_ = file->message_type(3); static const int FieldDescriptorProto_offsets_[10] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, name_), @@ -226,14 +221,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { FieldDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FieldDescriptorProto_descriptor_, - FieldDescriptorProto::default_instance_, + FieldDescriptorProto::internal_default_instance(), FieldDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_), -1, -1, sizeof(FieldDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _internal_metadata_)); FieldDescriptorProto_Type_descriptor_ = FieldDescriptorProto_descriptor_->enum_type(0); FieldDescriptorProto_Label_descriptor_ = FieldDescriptorProto_descriptor_->enum_type(1); OneofDescriptorProto_descriptor_ = file->message_type(4); @@ -244,14 +238,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { OneofDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( OneofDescriptorProto_descriptor_, - OneofDescriptorProto::default_instance_, + OneofDescriptorProto::internal_default_instance(), OneofDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _has_bits_), -1, -1, sizeof(OneofDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _internal_metadata_)); EnumDescriptorProto_descriptor_ = file->message_type(5); static const int EnumDescriptorProto_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, name_), @@ -261,14 +254,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { EnumDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( EnumDescriptorProto_descriptor_, - EnumDescriptorProto::default_instance_, + EnumDescriptorProto::internal_default_instance(), EnumDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_), -1, -1, sizeof(EnumDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _internal_metadata_)); EnumValueDescriptorProto_descriptor_ = file->message_type(6); static const int EnumValueDescriptorProto_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, name_), @@ -278,14 +270,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { EnumValueDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( EnumValueDescriptorProto_descriptor_, - EnumValueDescriptorProto::default_instance_, + EnumValueDescriptorProto::internal_default_instance(), EnumValueDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_), -1, -1, sizeof(EnumValueDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _internal_metadata_)); ServiceDescriptorProto_descriptor_ = file->message_type(7); static const int ServiceDescriptorProto_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, name_), @@ -295,14 +286,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { ServiceDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ServiceDescriptorProto_descriptor_, - ServiceDescriptorProto::default_instance_, + ServiceDescriptorProto::internal_default_instance(), ServiceDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_), -1, -1, sizeof(ServiceDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _internal_metadata_)); MethodDescriptorProto_descriptor_ = file->message_type(8); static const int MethodDescriptorProto_offsets_[6] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, name_), @@ -315,20 +305,18 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { MethodDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( MethodDescriptorProto_descriptor_, - MethodDescriptorProto::default_instance_, + MethodDescriptorProto::internal_default_instance(), MethodDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_), -1, -1, sizeof(MethodDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_)); FileOptions_descriptor_ = file->message_type(9); - static const int FileOptions_offsets_[15] = { + static const int FileOptions_offsets_[14] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generate_equals_and_hash_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_string_check_utf8_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, optimize_for_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, go_package_), @@ -344,14 +332,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { FileOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FileOptions_descriptor_, - FileOptions::default_instance_, + FileOptions::internal_default_instance(), FileOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _extensions_), sizeof(FileOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _internal_metadata_)); FileOptions_OptimizeMode_descriptor_ = FileOptions_descriptor_->enum_type(0); MessageOptions_descriptor_ = file->message_type(10); static const int MessageOptions_offsets_[5] = { @@ -364,14 +351,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { MessageOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( MessageOptions_descriptor_, - MessageOptions::default_instance_, + MessageOptions::internal_default_instance(), MessageOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _extensions_), sizeof(MessageOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_)); FieldOptions_descriptor_ = file->message_type(11); static const int FieldOptions_offsets_[7] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, ctype_), @@ -385,14 +371,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { FieldOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FieldOptions_descriptor_, - FieldOptions::default_instance_, + FieldOptions::internal_default_instance(), FieldOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _extensions_), sizeof(FieldOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _internal_metadata_)); FieldOptions_CType_descriptor_ = FieldOptions_descriptor_->enum_type(0); FieldOptions_JSType_descriptor_ = FieldOptions_descriptor_->enum_type(1); OneofOptions_descriptor_ = file->message_type(12); @@ -402,14 +387,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { OneofOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( OneofOptions_descriptor_, - OneofOptions::default_instance_, + OneofOptions::internal_default_instance(), OneofOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _extensions_), sizeof(OneofOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _internal_metadata_)); EnumOptions_descriptor_ = file->message_type(13); static const int EnumOptions_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, allow_alias_), @@ -419,14 +403,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { EnumOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( EnumOptions_descriptor_, - EnumOptions::default_instance_, + EnumOptions::internal_default_instance(), EnumOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _extensions_), sizeof(EnumOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _internal_metadata_)); EnumValueOptions_descriptor_ = file->message_type(14); static const int EnumValueOptions_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, deprecated_), @@ -435,14 +418,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { EnumValueOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( EnumValueOptions_descriptor_, - EnumValueOptions::default_instance_, + EnumValueOptions::internal_default_instance(), EnumValueOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _extensions_), sizeof(EnumValueOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _internal_metadata_)); ServiceOptions_descriptor_ = file->message_type(15); static const int ServiceOptions_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, deprecated_), @@ -451,14 +433,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { ServiceOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ServiceOptions_descriptor_, - ServiceOptions::default_instance_, + ServiceOptions::internal_default_instance(), ServiceOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _extensions_), sizeof(ServiceOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _internal_metadata_)); MethodOptions_descriptor_ = file->message_type(16); static const int MethodOptions_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, deprecated_), @@ -467,14 +448,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { MethodOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( MethodOptions_descriptor_, - MethodOptions::default_instance_, + MethodOptions::internal_default_instance(), MethodOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _extensions_), sizeof(MethodOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _internal_metadata_)); UninterpretedOption_descriptor_ = file->message_type(17); static const int UninterpretedOption_offsets_[7] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, name_), @@ -488,14 +468,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { UninterpretedOption_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( UninterpretedOption_descriptor_, - UninterpretedOption::default_instance_, + UninterpretedOption::internal_default_instance(), UninterpretedOption_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_), -1, -1, sizeof(UninterpretedOption), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _internal_metadata_)); UninterpretedOption_NamePart_descriptor_ = UninterpretedOption_descriptor_->nested_type(0); static const int UninterpretedOption_NamePart_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, name_part_), @@ -504,14 +483,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { UninterpretedOption_NamePart_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( UninterpretedOption_NamePart_descriptor_, - UninterpretedOption_NamePart::default_instance_, + UninterpretedOption_NamePart::internal_default_instance(), UninterpretedOption_NamePart_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _has_bits_), -1, -1, sizeof(UninterpretedOption_NamePart), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _internal_metadata_)); SourceCodeInfo_descriptor_ = file->message_type(18); static const int SourceCodeInfo_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, location_), @@ -519,14 +497,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { SourceCodeInfo_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( SourceCodeInfo_descriptor_, - SourceCodeInfo::default_instance_, + SourceCodeInfo::internal_default_instance(), SourceCodeInfo_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_), -1, -1, sizeof(SourceCodeInfo), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _internal_metadata_)); SourceCodeInfo_Location_descriptor_ = SourceCodeInfo_descriptor_->nested_type(0); static const int SourceCodeInfo_Location_offsets_[5] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, path_), @@ -538,14 +515,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { SourceCodeInfo_Location_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( SourceCodeInfo_Location_descriptor_, - SourceCodeInfo_Location::default_instance_, + SourceCodeInfo_Location::internal_default_instance(), SourceCodeInfo_Location_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _has_bits_), -1, -1, sizeof(SourceCodeInfo_Location), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _internal_metadata_)); GeneratedCodeInfo_descriptor_ = file->message_type(19); static const int GeneratedCodeInfo_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, annotation_), @@ -553,14 +529,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GeneratedCodeInfo_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( GeneratedCodeInfo_descriptor_, - GeneratedCodeInfo::default_instance_, + GeneratedCodeInfo::internal_default_instance(), GeneratedCodeInfo_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _has_bits_), -1, -1, sizeof(GeneratedCodeInfo), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _internal_metadata_)); GeneratedCodeInfo_Annotation_descriptor_ = GeneratedCodeInfo_descriptor_->nested_type(0); static const int GeneratedCodeInfo_Annotation_offsets_[4] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, path_), @@ -571,20 +546,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GeneratedCodeInfo_Annotation_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( GeneratedCodeInfo_Annotation_descriptor_, - GeneratedCodeInfo_Annotation::default_instance_, + GeneratedCodeInfo_Annotation::internal_default_instance(), GeneratedCodeInfo_Annotation_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _has_bits_), -1, -1, sizeof(GeneratedCodeInfo_Annotation), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _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_2fdescriptor_2eproto); } @@ -593,119 +567,164 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileDescriptorSet_descriptor_, &FileDescriptorSet::default_instance()); + FileDescriptorSet_descriptor_, FileDescriptorSet::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileDescriptorProto_descriptor_, &FileDescriptorProto::default_instance()); + FileDescriptorProto_descriptor_, FileDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_descriptor_, &DescriptorProto::default_instance()); + DescriptorProto_descriptor_, DescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_ExtensionRange_descriptor_, &DescriptorProto_ExtensionRange::default_instance()); + DescriptorProto_ExtensionRange_descriptor_, DescriptorProto_ExtensionRange::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_ReservedRange_descriptor_, &DescriptorProto_ReservedRange::default_instance()); + DescriptorProto_ReservedRange_descriptor_, DescriptorProto_ReservedRange::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldDescriptorProto_descriptor_, &FieldDescriptorProto::default_instance()); + FieldDescriptorProto_descriptor_, FieldDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - OneofDescriptorProto_descriptor_, &OneofDescriptorProto::default_instance()); + OneofDescriptorProto_descriptor_, OneofDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumDescriptorProto_descriptor_, &EnumDescriptorProto::default_instance()); + EnumDescriptorProto_descriptor_, EnumDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValueDescriptorProto_descriptor_, &EnumValueDescriptorProto::default_instance()); + EnumValueDescriptorProto_descriptor_, EnumValueDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ServiceDescriptorProto_descriptor_, &ServiceDescriptorProto::default_instance()); + ServiceDescriptorProto_descriptor_, ServiceDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MethodDescriptorProto_descriptor_, &MethodDescriptorProto::default_instance()); + MethodDescriptorProto_descriptor_, MethodDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileOptions_descriptor_, &FileOptions::default_instance()); + FileOptions_descriptor_, FileOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MessageOptions_descriptor_, &MessageOptions::default_instance()); + MessageOptions_descriptor_, MessageOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldOptions_descriptor_, &FieldOptions::default_instance()); + FieldOptions_descriptor_, FieldOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - OneofOptions_descriptor_, &OneofOptions::default_instance()); + OneofOptions_descriptor_, OneofOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumOptions_descriptor_, &EnumOptions::default_instance()); + EnumOptions_descriptor_, EnumOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValueOptions_descriptor_, &EnumValueOptions::default_instance()); + EnumValueOptions_descriptor_, EnumValueOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ServiceOptions_descriptor_, &ServiceOptions::default_instance()); + ServiceOptions_descriptor_, ServiceOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MethodOptions_descriptor_, &MethodOptions::default_instance()); + MethodOptions_descriptor_, MethodOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UninterpretedOption_descriptor_, &UninterpretedOption::default_instance()); + UninterpretedOption_descriptor_, UninterpretedOption::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UninterpretedOption_NamePart_descriptor_, &UninterpretedOption_NamePart::default_instance()); + UninterpretedOption_NamePart_descriptor_, UninterpretedOption_NamePart::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceCodeInfo_descriptor_, &SourceCodeInfo::default_instance()); + SourceCodeInfo_descriptor_, SourceCodeInfo::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceCodeInfo_Location_descriptor_, &SourceCodeInfo_Location::default_instance()); + SourceCodeInfo_Location_descriptor_, SourceCodeInfo_Location::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - GeneratedCodeInfo_descriptor_, &GeneratedCodeInfo::default_instance()); + GeneratedCodeInfo_descriptor_, GeneratedCodeInfo::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - GeneratedCodeInfo_Annotation_descriptor_, &GeneratedCodeInfo_Annotation::default_instance()); + GeneratedCodeInfo_Annotation_descriptor_, GeneratedCodeInfo_Annotation::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto() { - delete FileDescriptorSet::default_instance_; delete FileDescriptorSet_reflection_; - delete FileDescriptorProto::default_instance_; delete FileDescriptorProto_reflection_; - delete DescriptorProto::default_instance_; delete DescriptorProto_reflection_; - delete DescriptorProto_ExtensionRange::default_instance_; delete DescriptorProto_ExtensionRange_reflection_; - delete DescriptorProto_ReservedRange::default_instance_; delete DescriptorProto_ReservedRange_reflection_; - delete FieldDescriptorProto::default_instance_; delete FieldDescriptorProto_reflection_; - delete OneofDescriptorProto::default_instance_; delete OneofDescriptorProto_reflection_; - delete EnumDescriptorProto::default_instance_; delete EnumDescriptorProto_reflection_; - delete EnumValueDescriptorProto::default_instance_; delete EnumValueDescriptorProto_reflection_; - delete ServiceDescriptorProto::default_instance_; delete ServiceDescriptorProto_reflection_; - delete MethodDescriptorProto::default_instance_; delete MethodDescriptorProto_reflection_; - delete FileOptions::default_instance_; delete FileOptions_reflection_; - delete MessageOptions::default_instance_; delete MessageOptions_reflection_; - delete FieldOptions::default_instance_; delete FieldOptions_reflection_; - delete OneofOptions::default_instance_; delete OneofOptions_reflection_; - delete EnumOptions::default_instance_; delete EnumOptions_reflection_; - delete EnumValueOptions::default_instance_; delete EnumValueOptions_reflection_; - delete ServiceOptions::default_instance_; delete ServiceOptions_reflection_; - delete MethodOptions::default_instance_; delete MethodOptions_reflection_; - delete UninterpretedOption::default_instance_; delete UninterpretedOption_reflection_; - delete UninterpretedOption_NamePart::default_instance_; delete UninterpretedOption_NamePart_reflection_; - delete SourceCodeInfo::default_instance_; delete SourceCodeInfo_reflection_; - delete SourceCodeInfo_Location::default_instance_; delete SourceCodeInfo_Location_reflection_; - delete GeneratedCodeInfo::default_instance_; delete GeneratedCodeInfo_reflection_; - delete GeneratedCodeInfo_Annotation::default_instance_; delete GeneratedCodeInfo_Annotation_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + FileDescriptorSet::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + FileDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + DescriptorProto::default_instance_.DefaultConstruct(); + DescriptorProto_ExtensionRange::default_instance_.DefaultConstruct(); + DescriptorProto_ReservedRange::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + FieldDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + OneofDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + EnumDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + EnumValueDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + ServiceDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + MethodDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + FileOptions::default_instance_.DefaultConstruct(); + MessageOptions::default_instance_.DefaultConstruct(); + FieldOptions::default_instance_.DefaultConstruct(); + OneofOptions::default_instance_.DefaultConstruct(); + EnumOptions::default_instance_.DefaultConstruct(); + EnumValueOptions::default_instance_.DefaultConstruct(); + ServiceOptions::default_instance_.DefaultConstruct(); + MethodOptions::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + UninterpretedOption::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + UninterpretedOption_NamePart::default_instance_.DefaultConstruct(); + SourceCodeInfo::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + SourceCodeInfo_Location::default_instance_.DefaultConstruct(); + GeneratedCodeInfo::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + GeneratedCodeInfo_Annotation::default_instance_.DefaultConstruct(); + FileDescriptorSet::default_instance_.get_mutable()->InitAsDefaultInstance(); + FileDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + DescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + DescriptorProto_ExtensionRange::default_instance_.get_mutable()->InitAsDefaultInstance(); + DescriptorProto_ReservedRange::default_instance_.get_mutable()->InitAsDefaultInstance(); + FieldDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + OneofDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + EnumDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + EnumValueDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + ServiceDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + MethodDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + FileOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + MessageOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + FieldOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + OneofOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + EnumOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + EnumValueOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + ServiceOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + MethodOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + UninterpretedOption::default_instance_.get_mutable()->InitAsDefaultInstance(); + UninterpretedOption_NamePart::default_instance_.get_mutable()->InitAsDefaultInstance(); + SourceCodeInfo::default_instance_.get_mutable()->InitAsDefaultInstance(); + SourceCodeInfo_Location::default_instance_.get_mutable()->InitAsDefaultInstance(); + GeneratedCodeInfo::default_instance_.get_mutable()->InitAsDefaultInstance(); + GeneratedCodeInfo_Annotation::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n google/protobuf/descriptor.proto\022\017goog" "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file" @@ -772,29 +791,28 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "\n\013output_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.g" "oogle.protobuf.MethodOptions\022\037\n\020client_s" "treaming\030\005 \001(\010:\005false\022\037\n\020server_streamin" - "g\030\006 \001(\010:\005false\"\207\005\n\013FileOptions\022\024\n\014java_p" + "g\030\006 \001(\010:\005false\"\331\004\n\013FileOptions\022\024\n\014java_p" "ackage\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001" - "(\t\022\"\n\023java_multiple_files\030\n \001(\010:\005false\022," - "\n\035java_generate_equals_and_hash\030\024 \001(\010:\005f" - "alse\022%\n\026java_string_check_utf8\030\033 \001(\010:\005fa" - "lse\022F\n\014optimize_for\030\t \001(\0162).google.proto" - "buf.FileOptions.OptimizeMode:\005SPEED\022\022\n\ng" - "o_package\030\013 \001(\t\022\"\n\023cc_generic_services\030\020" - " \001(\010:\005false\022$\n\025java_generic_services\030\021 \001" - "(\010:\005false\022\"\n\023py_generic_services\030\022 \001(\010:\005" - "false\022\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_e" - "nable_arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_" - "prefix\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022C" - "\n\024uninterpreted_option\030\347\007 \003(\0132$.google.p" - "rotobuf.UninterpretedOption\":\n\014OptimizeM" - "ode\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RU" - "NTIME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\346\001\n\016MessageOpti" - "ons\022&\n\027message_set_wire_format\030\001 \001(\010:\005fa" - "lse\022.\n\037no_standard_descriptor_accessor\030\002" - " \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021" - "\n\tmap_entry\030\007 \001(\010\022C\n\024uninterpreted_optio" - "n\030\347\007 \003(\0132$.google.protobuf.Uninterpreted" - "Option*\t\010\350\007\020\200\200\200\200\002\"\230\003\n\014FieldOptions\022:\n\005ct" + "(\t\022\"\n\023java_multiple_files\030\n \001(\010:\005false\022%" + "\n\026java_string_check_utf8\030\033 \001(\010:\005false\022F\n" + "\014optimize_for\030\t \001(\0162).google.protobuf.Fi" + "leOptions.OptimizeMode:\005SPEED\022\022\n\ngo_pack" + "age\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(\010:\005" + "false\022$\n\025java_generic_services\030\021 \001(\010:\005fa" + "lse\022\"\n\023py_generic_services\030\022 \001(\010:\005false\022" + "\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enable_" + "arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_prefix" + "\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022C\n\024unin" + "terpreted_option\030\347\007 \003(\0132$.google.protobu" + "f.UninterpretedOption\":\n\014OptimizeMode\022\t\n" + "\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020" + "\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\354\001\n\016MessageOptions\022&\n" + "\027message_set_wire_format\030\001 \001(\010:\005false\022.\n" + "\037no_standard_descriptor_accessor\030\002 \001(\010:\005" + "false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tmap_" + "entry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347\007 \003" + "(\0132$.google.protobuf.UninterpretedOption" + "*\t\010\350\007\020\200\200\200\200\002J\004\010\010\020\t\"\236\003\n\014FieldOptions\022:\n\005ct" "ype\030\001 \001(\0162#.google.protobuf.FieldOptions" ".CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jstype" "\030\006 \001(\0162$.google.protobuf.FieldOptions.JS" @@ -804,97 +822,52 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "ogle.protobuf.UninterpretedOption\"/\n\005CTy" "pe\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\002\"^\n\014OneofOpt" - "ions\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.go" - "ogle.protobuf.UninterpretedOption*\t\010\350\007\020\200" - "\200\200\200\002\"\215\001\n\013EnumOptions\022\023\n\013allow_alias\030\002 \001(" - "\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n\024uninterp" - "reted_option\030\347\007 \003(\0132$.google.protobuf.Un" - "interpretedOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020EnumValu" - "eOptions\022\031\n\ndeprecated\030\001 \001(\010:\005false\022C\n\024u" - "ninterpreted_option\030\347\007 \003(\0132$.google.prot" - "obuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016S" - "erviceOptions\022\031\n\ndeprecated\030! \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" - "\"z\n\rMethodOptions\022\031\n\ndeprecated\030! \001(\010:\005f" - "alse\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.go" - "ogle.protobuf.UninterpretedOption*\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\022p" - "ositive_int_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\014str" - "ing_value\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t" - "\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_ex" - "tension\030\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010loca" - "tion\030\001 \003(\0132(.google.protobuf.SourceCodeI" - "nfo.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_comment" - "s\030\003 \001(\t\022\031\n\021trailing_comments\030\004 \001(\t\022!\n\031le" - "ading_detached_comments\030\006 \003(\t\"\247\001\n\021Genera" - "tedCodeInfo\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\020DescriptorProtos" - "H\001Z\ndescriptor\240\001\001\242\002\003GPB\252\002\032Google.Protobu" - "f.Reflection", 5292); + "\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\014On" + "eofOptions\022C\n\024uninterpreted_option\030\347\007 \003(" + "\0132$.google.protobuf.UninterpretedOption*" + "\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013EnumOptions\022\023\n\013allow_alia" + "s\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n\024un" + "interpreted_option\030\347\007 \003(\0132$.google.proto" + "buf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020En" + "umValueOptions\022\031\n\ndeprecated\030\001 \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" + "\002\"{\n\016ServiceOptions\022\031\n\ndeprecated\030! \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\"z\n\rMethodOptions\022\031\n\ndeprecated\030! " + "\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\"\236\002\n\023UninterpretedOption\022;\n\004na" + "me\030\002 \003(\0132-.google.protobuf.Uninterpreted" + "Option.NamePart\022\030\n\020identifier_value\030\003 \001(" + "\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022negativ" + "e_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\010NamePart\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.Sourc" + "eCodeInfo.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_c" + "omments\030\003 \001(\t\022\031\n\021trailing_comments\030\004 \001(\t" + "\022!\n\031leading_detached_comments\030\006 \003(\t\"\247\001\n\021" + "GeneratedCodeInfo\022A\n\nannotation\030\001 \003(\0132-." + "google.protobuf.GeneratedCodeInfo.Annota" + "tion\032O\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013" + "source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030" + "\004 \001(\005BX\n\023com.google.protobufB\020Descriptor" + "ProtosH\001Z\ndescriptor\242\002\003GPB\252\002\032Google.Prot" + "obuf.Reflection", 5255); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); - FileDescriptorSet::default_instance_ = new FileDescriptorSet(); - FileDescriptorProto::default_instance_ = new FileDescriptorProto(); - DescriptorProto::default_instance_ = new DescriptorProto(); - DescriptorProto_ExtensionRange::default_instance_ = new DescriptorProto_ExtensionRange(); - DescriptorProto_ReservedRange::default_instance_ = new DescriptorProto_ReservedRange(); - FieldDescriptorProto::default_instance_ = new FieldDescriptorProto(); - OneofDescriptorProto::default_instance_ = new OneofDescriptorProto(); - EnumDescriptorProto::default_instance_ = new EnumDescriptorProto(); - EnumValueDescriptorProto::default_instance_ = new EnumValueDescriptorProto(); - ServiceDescriptorProto::default_instance_ = new ServiceDescriptorProto(); - MethodDescriptorProto::default_instance_ = new MethodDescriptorProto(); - FileOptions::default_instance_ = new FileOptions(); - MessageOptions::default_instance_ = new MessageOptions(); - FieldOptions::default_instance_ = new FieldOptions(); - OneofOptions::default_instance_ = new OneofOptions(); - EnumOptions::default_instance_ = new EnumOptions(); - EnumValueOptions::default_instance_ = new EnumValueOptions(); - ServiceOptions::default_instance_ = new ServiceOptions(); - MethodOptions::default_instance_ = new MethodOptions(); - UninterpretedOption::default_instance_ = new UninterpretedOption(); - UninterpretedOption_NamePart::default_instance_ = new UninterpretedOption_NamePart(); - SourceCodeInfo::default_instance_ = new SourceCodeInfo(); - SourceCodeInfo_Location::default_instance_ = new SourceCodeInfo_Location(); - GeneratedCodeInfo::default_instance_ = new GeneratedCodeInfo(); - GeneratedCodeInfo_Annotation::default_instance_ = new GeneratedCodeInfo_Annotation(); - FileDescriptorSet::default_instance_->InitAsDefaultInstance(); - FileDescriptorProto::default_instance_->InitAsDefaultInstance(); - DescriptorProto::default_instance_->InitAsDefaultInstance(); - DescriptorProto_ExtensionRange::default_instance_->InitAsDefaultInstance(); - DescriptorProto_ReservedRange::default_instance_->InitAsDefaultInstance(); - FieldDescriptorProto::default_instance_->InitAsDefaultInstance(); - OneofDescriptorProto::default_instance_->InitAsDefaultInstance(); - EnumDescriptorProto::default_instance_->InitAsDefaultInstance(); - EnumValueDescriptorProto::default_instance_->InitAsDefaultInstance(); - ServiceDescriptorProto::default_instance_->InitAsDefaultInstance(); - MethodDescriptorProto::default_instance_->InitAsDefaultInstance(); - FileOptions::default_instance_->InitAsDefaultInstance(); - MessageOptions::default_instance_->InitAsDefaultInstance(); - FieldOptions::default_instance_->InitAsDefaultInstance(); - OneofOptions::default_instance_->InitAsDefaultInstance(); - EnumOptions::default_instance_->InitAsDefaultInstance(); - EnumValueOptions::default_instance_->InitAsDefaultInstance(); - ServiceOptions::default_instance_->InitAsDefaultInstance(); - MethodOptions::default_instance_->InitAsDefaultInstance(); - UninterpretedOption::default_instance_->InitAsDefaultInstance(); - UninterpretedOption_NamePart::default_instance_->InitAsDefaultInstance(); - SourceCodeInfo::default_instance_->InitAsDefaultInstance(); - SourceCodeInfo_Location::default_instance_->InitAsDefaultInstance(); - GeneratedCodeInfo::default_instance_->InitAsDefaultInstance(); - GeneratedCodeInfo_Annotation::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto() { @@ -902,6 +875,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fdescriptor_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 @@ -910,6 +893,7 @@ const int FileDescriptorSet::kFileFieldNumber; FileDescriptorSet::FileDescriptorSet() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorSet) } @@ -921,13 +905,12 @@ FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorSet) } void FileDescriptorSet::SharedCtor() { _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } FileDescriptorSet::~FileDescriptorSet() { @@ -936,8 +919,6 @@ FileDescriptorSet::~FileDescriptorSet() { } void FileDescriptorSet::SharedDtor() { - if (this != default_instance_) { - } } void FileDescriptorSet::SetCachedSize(int size) const { @@ -951,11 +932,11 @@ const ::google::protobuf::Descriptor* FileDescriptorSet::descriptor() { } const FileDescriptorSet& FileDescriptorSet::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -FileDescriptorSet* FileDescriptorSet::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> FileDescriptorSet::default_instance_; FileDescriptorSet* FileDescriptorSet::New(::google::protobuf::Arena* arena) const { FileDescriptorSet* n = new FileDescriptorSet; @@ -968,7 +949,7 @@ FileDescriptorSet* FileDescriptorSet::New(::google::protobuf::Arena* arena) cons void FileDescriptorSet::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorSet) file_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -1057,16 +1038,19 @@ void FileDescriptorSet::SerializeWithCachedSizes( return target; } -int FileDescriptorSet::ByteSize() const { +size_t FileDescriptorSet::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorSet) - int total_size = 0; + size_t total_size = 0; // repeated .google.protobuf.FileDescriptorProto file = 1; - total_size += 1 * this->file_size(); - for (int i = 0; i < this->file_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->file(i)); + { + unsigned int count = this->file_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->file(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -1074,18 +1058,17 @@ int FileDescriptorSet::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 FileDescriptorSet::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorSet) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const FileDescriptorSet* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FileDescriptorSet* source = ::google::protobuf::internal::DynamicCastToGenerated<const FileDescriptorSet>( &from); if (source == NULL) { @@ -1093,18 +1076,25 @@ void FileDescriptorSet::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileDescriptorSet) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void FileDescriptorSet::MergeFrom(const FileDescriptorSet& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void FileDescriptorSet::UnsafeMergeFrom(const FileDescriptorSet& from) { + GOOGLE_DCHECK(&from != this); file_.MergeFrom(from.file_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -1119,7 +1109,7 @@ void FileDescriptorSet::CopyFrom(const FileDescriptorSet& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorSet) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FileDescriptorSet::IsInitialized() const { @@ -1201,32 +1191,33 @@ const int FileDescriptorProto::kSyntaxFieldNumber; FileDescriptorProto::FileDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorProto) } void FileDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::FileOptions*>(&::google::protobuf::FileOptions::default_instance()); - source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>(&::google::protobuf::SourceCodeInfo::default_instance()); + options_ = const_cast< ::google::protobuf::FileOptions*>( + ::google::protobuf::FileOptions::internal_default_instance()); + source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>( + ::google::protobuf::SourceCodeInfo::internal_default_instance()); } FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorProto) } void FileDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; source_code_info_ = NULL; - syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } FileDescriptorProto::~FileDescriptorProto() { @@ -1238,10 +1229,8 @@ void FileDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); syntax_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - delete source_code_info_; - } + delete options_; + delete source_code_info_; } void FileDescriptorProto::SetCachedSize(int size) const { @@ -1255,11 +1244,11 @@ const ::google::protobuf::Descriptor* FileDescriptorProto::descriptor() { } const FileDescriptorProto& FileDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -FileDescriptorProto* FileDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> FileDescriptorProto::default_instance_; FileDescriptorProto* FileDescriptorProto::New(::google::protobuf::Arena* arena) const { FileDescriptorProto* n = new FileDescriptorProto; @@ -1297,7 +1286,7 @@ void FileDescriptorProto::Clear() { enum_type_.Clear(); service_.Clear(); extension_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -1740,9 +1729,9 @@ void FileDescriptorProto::SerializeWithCachedSizes( return target; } -int FileDescriptorProto::ByteSize() const { +size_t FileDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 3u) { // optional string name = 1; @@ -1784,7 +1773,8 @@ int FileDescriptorProto::ByteSize() const { } // repeated string dependency = 3; - total_size += 1 * this->dependency_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->dependency_size()); for (int i = 0; i < this->dependency_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->dependency(i)); @@ -1792,54 +1782,72 @@ int FileDescriptorProto::ByteSize() const { // repeated int32 public_dependency = 10; { - int data_size = 0; - for (int i = 0; i < this->public_dependency_size(); i++) { + size_t data_size = 0; + unsigned int count = this->public_dependency_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int32Size(this->public_dependency(i)); } - total_size += 1 * this->public_dependency_size() + data_size; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->public_dependency_size()); + total_size += data_size; } // repeated int32 weak_dependency = 11; { - int data_size = 0; - for (int i = 0; i < this->weak_dependency_size(); i++) { + size_t data_size = 0; + unsigned int count = this->weak_dependency_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int32Size(this->weak_dependency(i)); } - total_size += 1 * this->weak_dependency_size() + data_size; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->weak_dependency_size()); + total_size += data_size; } // repeated .google.protobuf.DescriptorProto message_type = 4; - total_size += 1 * this->message_type_size(); - for (int i = 0; i < this->message_type_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->message_type(i)); + { + unsigned int count = this->message_type_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->message_type(i)); + } } // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - total_size += 1 * this->enum_type_size(); - for (int i = 0; i < this->enum_type_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->enum_type(i)); + { + unsigned int count = this->enum_type_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->enum_type(i)); + } } // repeated .google.protobuf.ServiceDescriptorProto service = 6; - total_size += 1 * this->service_size(); - for (int i = 0; i < this->service_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->service(i)); + { + unsigned int count = this->service_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->service(i)); + } } // repeated .google.protobuf.FieldDescriptorProto extension = 7; - total_size += 1 * this->extension_size(); - for (int i = 0; i < this->extension_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->extension(i)); + { + unsigned int count = this->extension_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->extension(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -1847,18 +1855,17 @@ int FileDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 FileDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const FileDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FileDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const FileDescriptorProto>( &from); if (source == NULL) { @@ -1866,18 +1873,24 @@ void FileDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } - dependency_.MergeFrom(from.dependency_); - public_dependency_.MergeFrom(from.public_dependency_); - weak_dependency_.MergeFrom(from.weak_dependency_); +} + +void FileDescriptorProto::UnsafeMergeFrom(const FileDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); + dependency_.UnsafeMergeFrom(from.dependency_); + public_dependency_.UnsafeMergeFrom(from.public_dependency_); + weak_dependency_.UnsafeMergeFrom(from.weak_dependency_); message_type_.MergeFrom(from.message_type_); enum_type_.MergeFrom(from.enum_type_); service_.MergeFrom(from.service_); @@ -1905,7 +1918,8 @@ void FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -1920,7 +1934,7 @@ void FileDescriptorProto::CopyFrom(const FileDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FileDescriptorProto::IsInitialized() const { @@ -1982,37 +1996,37 @@ void FileDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& FileDescriptorProto::name() const { +const ::std::string& FileDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileDescriptorProto::set_name(const ::std::string& value) { +void FileDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name) } - void FileDescriptorProto::set_name(const char* value) { +void FileDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.name) } - void FileDescriptorProto::set_name(const char* value, size_t size) { +void FileDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.name) } - ::std::string* FileDescriptorProto::mutable_name() { +::std::string* FileDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileDescriptorProto::release_name() { +::std::string* FileDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileDescriptorProto::set_allocated_name(::std::string* name) { +void FileDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -2036,37 +2050,37 @@ void FileDescriptorProto::clear_package() { package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_package(); } - const ::std::string& FileDescriptorProto::package() const { +const ::std::string& FileDescriptorProto::package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package) return package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileDescriptorProto::set_package(const ::std::string& value) { +void FileDescriptorProto::set_package(const ::std::string& value) { set_has_package(); package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package) } - void FileDescriptorProto::set_package(const char* value) { +void FileDescriptorProto::set_package(const char* value) { set_has_package(); package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.package) } - void FileDescriptorProto::set_package(const char* value, size_t size) { +void FileDescriptorProto::set_package(const char* value, size_t size) { set_has_package(); package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.package) } - ::std::string* FileDescriptorProto::mutable_package() { +::std::string* FileDescriptorProto::mutable_package() { set_has_package(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.package) return package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileDescriptorProto::release_package() { +::std::string* FileDescriptorProto::release_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.package) clear_has_package(); return package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileDescriptorProto::set_allocated_package(::std::string* package) { +void FileDescriptorProto::set_allocated_package(::std::string* package) { if (package != NULL) { set_has_package(); } else { @@ -2083,49 +2097,49 @@ int FileDescriptorProto::dependency_size() const { void FileDescriptorProto::clear_dependency() { dependency_.Clear(); } - const ::std::string& FileDescriptorProto::dependency(int index) const { +const ::std::string& FileDescriptorProto::dependency(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.dependency) return dependency_.Get(index); } - ::std::string* FileDescriptorProto::mutable_dependency(int index) { +::std::string* FileDescriptorProto::mutable_dependency(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.dependency) return dependency_.Mutable(index); } - void FileDescriptorProto::set_dependency(int index, const ::std::string& value) { +void FileDescriptorProto::set_dependency(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) dependency_.Mutable(index)->assign(value); } - void FileDescriptorProto::set_dependency(int index, const char* value) { +void FileDescriptorProto::set_dependency(int index, const char* value) { dependency_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency) } - void FileDescriptorProto::set_dependency(int index, const char* value, size_t size) { +void FileDescriptorProto::set_dependency(int index, const char* value, size_t size) { dependency_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.dependency) } - ::std::string* FileDescriptorProto::add_dependency() { +::std::string* FileDescriptorProto::add_dependency() { // @@protoc_insertion_point(field_add_mutable:google.protobuf.FileDescriptorProto.dependency) return dependency_.Add(); } - void FileDescriptorProto::add_dependency(const ::std::string& value) { +void FileDescriptorProto::add_dependency(const ::std::string& value) { dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) } - void FileDescriptorProto::add_dependency(const char* value) { +void FileDescriptorProto::add_dependency(const char* value) { dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency) } - void FileDescriptorProto::add_dependency(const char* value, size_t size) { +void FileDescriptorProto::add_dependency(const char* value, size_t size) { dependency_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.FileDescriptorProto.dependency) } - const ::google::protobuf::RepeatedPtrField< ::std::string>& +const ::google::protobuf::RepeatedPtrField< ::std::string>& FileDescriptorProto::dependency() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.dependency) return dependency_; } - ::google::protobuf::RepeatedPtrField< ::std::string>* +::google::protobuf::RepeatedPtrField< ::std::string>* FileDescriptorProto::mutable_dependency() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.dependency) return &dependency_; @@ -2138,24 +2152,24 @@ int FileDescriptorProto::public_dependency_size() const { void FileDescriptorProto::clear_public_dependency() { public_dependency_.Clear(); } - ::google::protobuf::int32 FileDescriptorProto::public_dependency(int index) const { +::google::protobuf::int32 FileDescriptorProto::public_dependency(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.public_dependency) return public_dependency_.Get(index); } - void FileDescriptorProto::set_public_dependency(int index, ::google::protobuf::int32 value) { +void FileDescriptorProto::set_public_dependency(int index, ::google::protobuf::int32 value) { public_dependency_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.public_dependency) } - void FileDescriptorProto::add_public_dependency(::google::protobuf::int32 value) { +void FileDescriptorProto::add_public_dependency(::google::protobuf::int32 value) { public_dependency_.Add(value); // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.public_dependency) } - const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& FileDescriptorProto::public_dependency() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.public_dependency) return public_dependency_; } - ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* FileDescriptorProto::mutable_public_dependency() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.public_dependency) return &public_dependency_; @@ -2168,24 +2182,24 @@ int FileDescriptorProto::weak_dependency_size() const { void FileDescriptorProto::clear_weak_dependency() { weak_dependency_.Clear(); } - ::google::protobuf::int32 FileDescriptorProto::weak_dependency(int index) const { +::google::protobuf::int32 FileDescriptorProto::weak_dependency(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.weak_dependency) return weak_dependency_.Get(index); } - void FileDescriptorProto::set_weak_dependency(int index, ::google::protobuf::int32 value) { +void FileDescriptorProto::set_weak_dependency(int index, ::google::protobuf::int32 value) { weak_dependency_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.weak_dependency) } - void FileDescriptorProto::add_weak_dependency(::google::protobuf::int32 value) { +void FileDescriptorProto::add_weak_dependency(::google::protobuf::int32 value) { weak_dependency_.Add(value); // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.weak_dependency) } - const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& FileDescriptorProto::weak_dependency() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.weak_dependency) return weak_dependency_; } - ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* FileDescriptorProto::mutable_weak_dependency() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.weak_dependency) return &weak_dependency_; @@ -2327,7 +2341,8 @@ void FileDescriptorProto::clear_options() { } const ::google::protobuf::FileOptions& FileDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::FileOptions::internal_default_instance(); } ::google::protobuf::FileOptions* FileDescriptorProto::mutable_options() { set_has_options(); @@ -2371,7 +2386,8 @@ void FileDescriptorProto::clear_source_code_info() { } const ::google::protobuf::SourceCodeInfo& FileDescriptorProto::source_code_info() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.source_code_info) - return source_code_info_ != NULL ? *source_code_info_ : *default_instance_->source_code_info_; + return source_code_info_ != NULL ? *source_code_info_ + : *::google::protobuf::SourceCodeInfo::internal_default_instance(); } ::google::protobuf::SourceCodeInfo* FileDescriptorProto::mutable_source_code_info() { set_has_source_code_info(); @@ -2413,37 +2429,37 @@ void FileDescriptorProto::clear_syntax() { syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_syntax(); } - const ::std::string& FileDescriptorProto::syntax() const { +const ::std::string& FileDescriptorProto::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax) return syntax_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileDescriptorProto::set_syntax(const ::std::string& value) { +void FileDescriptorProto::set_syntax(const ::std::string& value) { set_has_syntax(); syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax) } - void FileDescriptorProto::set_syntax(const char* value) { +void FileDescriptorProto::set_syntax(const char* value) { set_has_syntax(); syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.syntax) } - void FileDescriptorProto::set_syntax(const char* value, size_t size) { +void FileDescriptorProto::set_syntax(const char* value, size_t size) { set_has_syntax(); syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.syntax) } - ::std::string* FileDescriptorProto::mutable_syntax() { +::std::string* FileDescriptorProto::mutable_syntax() { set_has_syntax(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.syntax) return syntax_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileDescriptorProto::release_syntax() { +::std::string* FileDescriptorProto::release_syntax() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.syntax) clear_has_syntax(); return syntax_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) { +void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) { if (syntax != NULL) { set_has_syntax(); } else { @@ -2464,6 +2480,7 @@ const int DescriptorProto_ExtensionRange::kEndFieldNumber; DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ExtensionRange) } @@ -2475,15 +2492,14 @@ DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorP : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ExtensionRange) } void DescriptorProto_ExtensionRange::SharedCtor() { _cached_size_ = 0; - start_ = 0; - end_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&start_, 0, reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_) + sizeof(end_)); } DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() { @@ -2492,8 +2508,6 @@ DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() { } void DescriptorProto_ExtensionRange::SharedDtor() { - if (this != default_instance_) { - } } void DescriptorProto_ExtensionRange::SetCachedSize(int size) const { @@ -2507,11 +2521,11 @@ const ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange::descriptor } const DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> DescriptorProto_ExtensionRange::default_instance_; DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::New(::google::protobuf::Arena* arena) const { DescriptorProto_ExtensionRange* n = new DescriptorProto_ExtensionRange; @@ -2544,7 +2558,7 @@ void DescriptorProto_ExtensionRange::Clear() { #undef ZR_HELPER_ #undef ZR_ - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -2563,10 +2577,10 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( // optional int32 start = 1; case 1: { if (tag == 8) { + set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &start_))); - set_has_start(); } else { goto handle_unusual; } @@ -2578,10 +2592,10 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_end: + set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &end_))); - set_has_end(); } else { goto handle_unusual; } @@ -2653,9 +2667,9 @@ void DescriptorProto_ExtensionRange::SerializeWithCachedSizes( return target; } -int DescriptorProto_ExtensionRange::ByteSize() const { +size_t DescriptorProto_ExtensionRange::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ExtensionRange) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 3u) { // optional int32 start = 1; @@ -2678,18 +2692,17 @@ int DescriptorProto_ExtensionRange::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 DescriptorProto_ExtensionRange::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const DescriptorProto_ExtensionRange* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const DescriptorProto_ExtensionRange* source = ::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto_ExtensionRange>( &from); if (source == NULL) { @@ -2697,15 +2710,21 @@ void DescriptorProto_ExtensionRange::MergeFrom(const ::google::protobuf::Message ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto.ExtensionRange) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void DescriptorProto_ExtensionRange::MergeFrom(const DescriptorProto_ExtensionRange& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void DescriptorProto_ExtensionRange::UnsafeMergeFrom(const DescriptorProto_ExtensionRange& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_start()) { set_start(from.start()); @@ -2715,7 +2734,8 @@ void DescriptorProto_ExtensionRange::MergeFrom(const DescriptorProto_ExtensionRa } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -2730,7 +2750,7 @@ void DescriptorProto_ExtensionRange::CopyFrom(const DescriptorProto_ExtensionRan // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ExtensionRange) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool DescriptorProto_ExtensionRange::IsInitialized() const { @@ -2768,6 +2788,7 @@ const int DescriptorProto_ReservedRange::kEndFieldNumber; DescriptorProto_ReservedRange::DescriptorProto_ReservedRange() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ReservedRange) } @@ -2779,15 +2800,14 @@ DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorPro : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ReservedRange) } void DescriptorProto_ReservedRange::SharedCtor() { _cached_size_ = 0; - start_ = 0; - end_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&start_, 0, reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_) + sizeof(end_)); } DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() { @@ -2796,8 +2816,6 @@ DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() { } void DescriptorProto_ReservedRange::SharedDtor() { - if (this != default_instance_) { - } } void DescriptorProto_ReservedRange::SetCachedSize(int size) const { @@ -2811,11 +2829,11 @@ const ::google::protobuf::Descriptor* DescriptorProto_ReservedRange::descriptor( } const DescriptorProto_ReservedRange& DescriptorProto_ReservedRange::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> DescriptorProto_ReservedRange::default_instance_; DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::New(::google::protobuf::Arena* arena) const { DescriptorProto_ReservedRange* n = new DescriptorProto_ReservedRange; @@ -2848,7 +2866,7 @@ void DescriptorProto_ReservedRange::Clear() { #undef ZR_HELPER_ #undef ZR_ - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -2867,10 +2885,10 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( // optional int32 start = 1; case 1: { if (tag == 8) { + set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &start_))); - set_has_start(); } else { goto handle_unusual; } @@ -2882,10 +2900,10 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_end: + set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &end_))); - set_has_end(); } else { goto handle_unusual; } @@ -2957,9 +2975,9 @@ void DescriptorProto_ReservedRange::SerializeWithCachedSizes( return target; } -int DescriptorProto_ReservedRange::ByteSize() const { +size_t DescriptorProto_ReservedRange::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ReservedRange) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 3u) { // optional int32 start = 1; @@ -2982,18 +3000,17 @@ int DescriptorProto_ReservedRange::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 DescriptorProto_ReservedRange::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto.ReservedRange) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const DescriptorProto_ReservedRange* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const DescriptorProto_ReservedRange* source = ::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto_ReservedRange>( &from); if (source == NULL) { @@ -3001,15 +3018,21 @@ void DescriptorProto_ReservedRange::MergeFrom(const ::google::protobuf::Message& ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto.ReservedRange) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void DescriptorProto_ReservedRange::MergeFrom(const DescriptorProto_ReservedRange& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void DescriptorProto_ReservedRange::UnsafeMergeFrom(const DescriptorProto_ReservedRange& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_start()) { set_start(from.start()); @@ -3019,7 +3042,8 @@ void DescriptorProto_ReservedRange::MergeFrom(const DescriptorProto_ReservedRang } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -3034,7 +3058,7 @@ void DescriptorProto_ReservedRange::CopyFrom(const DescriptorProto_ReservedRange // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ReservedRange) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool DescriptorProto_ReservedRange::IsInitialized() const { @@ -3080,28 +3104,28 @@ const int DescriptorProto::kReservedNameFieldNumber; DescriptorProto::DescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto) } void DescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::MessageOptions*>(&::google::protobuf::MessageOptions::default_instance()); + options_ = const_cast< ::google::protobuf::MessageOptions*>( + ::google::protobuf::MessageOptions::internal_default_instance()); } DescriptorProto::DescriptorProto(const DescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto) } void DescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } DescriptorProto::~DescriptorProto() { @@ -3111,9 +3135,7 @@ DescriptorProto::~DescriptorProto() { void DescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void DescriptorProto::SetCachedSize(int size) const { @@ -3127,11 +3149,11 @@ const ::google::protobuf::Descriptor* DescriptorProto::descriptor() { } const DescriptorProto& DescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -DescriptorProto* DescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> DescriptorProto::default_instance_; DescriptorProto* DescriptorProto::New(::google::protobuf::Arena* arena) const { DescriptorProto* n = new DescriptorProto; @@ -3159,7 +3181,7 @@ void DescriptorProto::Clear() { oneof_decl_.Clear(); reserved_range_.Clear(); reserved_name_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -3526,9 +3548,9 @@ void DescriptorProto::SerializeWithCachedSizes( return target; } -int DescriptorProto::ByteSize() const { +size_t DescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 129u) { // optional string name = 1; @@ -3547,63 +3569,85 @@ int DescriptorProto::ByteSize() const { } // repeated .google.protobuf.FieldDescriptorProto field = 2; - total_size += 1 * this->field_size(); - for (int i = 0; i < this->field_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->field(i)); + { + unsigned int count = this->field_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->field(i)); + } } // repeated .google.protobuf.FieldDescriptorProto extension = 6; - total_size += 1 * this->extension_size(); - for (int i = 0; i < this->extension_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->extension(i)); + { + unsigned int count = this->extension_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->extension(i)); + } } // repeated .google.protobuf.DescriptorProto nested_type = 3; - total_size += 1 * this->nested_type_size(); - for (int i = 0; i < this->nested_type_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->nested_type(i)); + { + unsigned int count = this->nested_type_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->nested_type(i)); + } } // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - total_size += 1 * this->enum_type_size(); - for (int i = 0; i < this->enum_type_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->enum_type(i)); + { + unsigned int count = this->enum_type_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->enum_type(i)); + } } // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - total_size += 1 * this->extension_range_size(); - for (int i = 0; i < this->extension_range_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->extension_range(i)); + { + unsigned int count = this->extension_range_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->extension_range(i)); + } } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; - total_size += 1 * this->oneof_decl_size(); - for (int i = 0; i < this->oneof_decl_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->oneof_decl(i)); + { + unsigned int count = this->oneof_decl_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->oneof_decl(i)); + } } // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; - total_size += 1 * this->reserved_range_size(); - for (int i = 0; i < this->reserved_range_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->reserved_range(i)); + { + unsigned int count = this->reserved_range_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->reserved_range(i)); + } } // repeated string reserved_name = 10; - total_size += 1 * this->reserved_name_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->reserved_name_size()); for (int i = 0; i < this->reserved_name_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->reserved_name(i)); @@ -3614,18 +3658,17 @@ int DescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 DescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const DescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const DescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto>( &from); if (source == NULL) { @@ -3633,15 +3676,21 @@ void DescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void DescriptorProto::MergeFrom(const DescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void DescriptorProto::UnsafeMergeFrom(const DescriptorProto& from) { + GOOGLE_DCHECK(&from != this); field_.MergeFrom(from.field_); extension_.MergeFrom(from.extension_); nested_type_.MergeFrom(from.nested_type_); @@ -3649,7 +3698,7 @@ void DescriptorProto::MergeFrom(const DescriptorProto& from) { extension_range_.MergeFrom(from.extension_range_); oneof_decl_.MergeFrom(from.oneof_decl_); reserved_range_.MergeFrom(from.reserved_range_); - reserved_name_.MergeFrom(from.reserved_name_); + reserved_name_.UnsafeMergeFrom(from.reserved_name_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { set_has_name(); @@ -3660,7 +3709,8 @@ void DescriptorProto::MergeFrom(const DescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -3675,7 +3725,7 @@ void DescriptorProto::CopyFrom(const DescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool DescriptorProto::IsInitialized() const { @@ -3736,11 +3786,11 @@ void DescriptorProto_ExtensionRange::clear_start() { start_ = 0; clear_has_start(); } - ::google::protobuf::int32 DescriptorProto_ExtensionRange::start() const { +::google::protobuf::int32 DescriptorProto_ExtensionRange::start() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.start) return start_; } - void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 value) { +void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 value) { set_has_start(); start_ = value; // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.start) @@ -3760,11 +3810,11 @@ void DescriptorProto_ExtensionRange::clear_end() { end_ = 0; clear_has_end(); } - ::google::protobuf::int32 DescriptorProto_ExtensionRange::end() const { +::google::protobuf::int32 DescriptorProto_ExtensionRange::end() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.end) return end_; } - void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 value) { +void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 value) { set_has_end(); end_ = value; // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end) @@ -3788,11 +3838,11 @@ void DescriptorProto_ReservedRange::clear_start() { start_ = 0; clear_has_start(); } - ::google::protobuf::int32 DescriptorProto_ReservedRange::start() const { +::google::protobuf::int32 DescriptorProto_ReservedRange::start() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.start) return start_; } - void DescriptorProto_ReservedRange::set_start(::google::protobuf::int32 value) { +void DescriptorProto_ReservedRange::set_start(::google::protobuf::int32 value) { set_has_start(); start_ = value; // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.start) @@ -3812,11 +3862,11 @@ void DescriptorProto_ReservedRange::clear_end() { end_ = 0; clear_has_end(); } - ::google::protobuf::int32 DescriptorProto_ReservedRange::end() const { +::google::protobuf::int32 DescriptorProto_ReservedRange::end() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.end) return end_; } - void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 value) { +void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 value) { set_has_end(); end_ = value; // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end) @@ -3840,37 +3890,37 @@ void DescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& DescriptorProto::name() const { +const ::std::string& DescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void DescriptorProto::set_name(const ::std::string& value) { +void DescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name) } - void DescriptorProto::set_name(const char* value) { +void DescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.name) } - void DescriptorProto::set_name(const char* value, size_t size) { +void DescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.name) } - ::std::string* DescriptorProto::mutable_name() { +::std::string* DescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* DescriptorProto::release_name() { +::std::string* DescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void DescriptorProto::set_allocated_name(::std::string* name) { +void DescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -4076,7 +4126,8 @@ void DescriptorProto::clear_options() { } const ::google::protobuf::MessageOptions& DescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::MessageOptions::internal_default_instance(); } ::google::protobuf::MessageOptions* DescriptorProto::mutable_options() { set_has_options(); @@ -4141,49 +4192,49 @@ int DescriptorProto::reserved_name_size() const { void DescriptorProto::clear_reserved_name() { reserved_name_.Clear(); } - const ::std::string& DescriptorProto::reserved_name(int index) const { +const ::std::string& DescriptorProto::reserved_name(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_name) return reserved_name_.Get(index); } - ::std::string* DescriptorProto::mutable_reserved_name(int index) { +::std::string* DescriptorProto::mutable_reserved_name(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.reserved_name) return reserved_name_.Mutable(index); } - void DescriptorProto::set_reserved_name(int index, const ::std::string& value) { +void DescriptorProto::set_reserved_name(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) reserved_name_.Mutable(index)->assign(value); } - void DescriptorProto::set_reserved_name(int index, const char* value) { +void DescriptorProto::set_reserved_name(int index, const char* value) { reserved_name_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name) } - void DescriptorProto::set_reserved_name(int index, const char* value, size_t size) { +void DescriptorProto::set_reserved_name(int index, const char* value, size_t size) { reserved_name_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.reserved_name) } - ::std::string* DescriptorProto::add_reserved_name() { +::std::string* DescriptorProto::add_reserved_name() { // @@protoc_insertion_point(field_add_mutable:google.protobuf.DescriptorProto.reserved_name) return reserved_name_.Add(); } - void DescriptorProto::add_reserved_name(const ::std::string& value) { +void DescriptorProto::add_reserved_name(const ::std::string& value) { reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) } - void DescriptorProto::add_reserved_name(const char* value) { +void DescriptorProto::add_reserved_name(const char* value) { reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name) } - void DescriptorProto::add_reserved_name(const char* value, size_t size) { +void DescriptorProto::add_reserved_name(const char* value, size_t size) { reserved_name_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.DescriptorProto.reserved_name) } - const ::google::protobuf::RepeatedPtrField< ::std::string>& +const ::google::protobuf::RepeatedPtrField< ::std::string>& DescriptorProto::reserved_name() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_name) return reserved_name_; } - ::google::protobuf::RepeatedPtrField< ::std::string>* +::google::protobuf::RepeatedPtrField< ::std::string>* DescriptorProto::mutable_reserved_name() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_name) return &reserved_name_; @@ -4198,7 +4249,7 @@ const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor() return FieldDescriptorProto_Type_descriptor_; } bool FieldDescriptorProto_Type_IsValid(int value) { - switch(value) { + switch (value) { case 1: case 2: case 3: @@ -4251,7 +4302,7 @@ const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor( return FieldDescriptorProto_Label_descriptor_; } bool FieldDescriptorProto_Label_IsValid(int value) { - switch(value) { + switch (value) { case 1: case 2: case 3: @@ -4284,36 +4335,36 @@ const int FieldDescriptorProto::kOptionsFieldNumber; FieldDescriptorProto::FieldDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldDescriptorProto) } void FieldDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::FieldOptions*>(&::google::protobuf::FieldOptions::default_instance()); + options_ = const_cast< ::google::protobuf::FieldOptions*>( + ::google::protobuf::FieldOptions::internal_default_instance()); } FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldDescriptorProto) } void FieldDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - number_ = 0; - label_ = 1; - type_ = 1; type_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); extendee_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - oneof_index_ = 0; json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&number_, 0, reinterpret_cast<char*>(&oneof_index_) - + reinterpret_cast<char*>(&number_) + sizeof(oneof_index_)); + label_ = 1; + type_ = 1; } FieldDescriptorProto::~FieldDescriptorProto() { @@ -4327,9 +4378,7 @@ void FieldDescriptorProto::SharedDtor() { extendee_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); default_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); json_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void FieldDescriptorProto::SetCachedSize(int size) const { @@ -4343,11 +4392,11 @@ const ::google::protobuf::Descriptor* FieldDescriptorProto::descriptor() { } const FieldDescriptorProto& FieldDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -FieldDescriptorProto* FieldDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> FieldDescriptorProto::default_instance_; FieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena) const { FieldDescriptorProto* n = new FieldDescriptorProto; @@ -4359,11 +4408,27 @@ FieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena void FieldDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldDescriptorProto) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(FieldDescriptorProto, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast<char*>(\ + &reinterpret_cast<FieldDescriptorProto*>(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + if (_has_bits_[0 / 32] & 255u) { + ZR_(number_, oneof_index_); if (has_name()) { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - number_ = 0; label_ = 1; type_ = 1; if (has_type_name()) { @@ -4375,7 +4440,6 @@ void FieldDescriptorProto::Clear() { if (has_default_value()) { default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - oneof_index_ = 0; } if (_has_bits_[8 / 32] & 768u) { if (has_json_name()) { @@ -4385,7 +4449,11 @@ void FieldDescriptorProto::Clear() { if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear(); } } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -4438,10 +4506,10 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_number: + set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &number_))); - set_has_number(); } else { goto handle_unusual; } @@ -4540,10 +4608,10 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( case 9: { if (tag == 72) { parse_oneof_index: + set_has_oneof_index(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &oneof_index_))); - set_has_oneof_index(); } else { goto handle_unusual; } @@ -4774,9 +4842,9 @@ void FieldDescriptorProto::SerializeWithCachedSizes( return target; } -int FieldDescriptorProto::ByteSize() const { +size_t FieldDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 255u) { // optional string name = 1; @@ -4855,18 +4923,17 @@ int FieldDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 FieldDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const FieldDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FieldDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const FieldDescriptorProto>( &from); if (source == NULL) { @@ -4874,15 +4941,21 @@ void FieldDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void FieldDescriptorProto::UnsafeMergeFrom(const FieldDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { set_has_name(); @@ -4923,7 +4996,8 @@ void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -4938,7 +5012,7 @@ void FieldDescriptorProto::CopyFrom(const FieldDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FieldDescriptorProto::IsInitialized() const { @@ -4994,37 +5068,37 @@ void FieldDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& FieldDescriptorProto::name() const { +const ::std::string& FieldDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_name(const ::std::string& value) { +void FieldDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name) } - void FieldDescriptorProto::set_name(const char* value) { +void FieldDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.name) } - void FieldDescriptorProto::set_name(const char* value, size_t size) { +void FieldDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.name) } - ::std::string* FieldDescriptorProto::mutable_name() { +::std::string* FieldDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FieldDescriptorProto::release_name() { +::std::string* FieldDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_allocated_name(::std::string* name) { +void FieldDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -5048,11 +5122,11 @@ void FieldDescriptorProto::clear_number() { number_ = 0; clear_has_number(); } - ::google::protobuf::int32 FieldDescriptorProto::number() const { +::google::protobuf::int32 FieldDescriptorProto::number() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.number) return number_; } - void FieldDescriptorProto::set_number(::google::protobuf::int32 value) { +void FieldDescriptorProto::set_number(::google::protobuf::int32 value) { set_has_number(); number_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.number) @@ -5072,11 +5146,11 @@ void FieldDescriptorProto::clear_label() { label_ = 1; clear_has_label(); } - ::google::protobuf::FieldDescriptorProto_Label FieldDescriptorProto::label() const { +::google::protobuf::FieldDescriptorProto_Label FieldDescriptorProto::label() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.label) return static_cast< ::google::protobuf::FieldDescriptorProto_Label >(label_); } - void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorProto_Label value) { +void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorProto_Label value) { assert(::google::protobuf::FieldDescriptorProto_Label_IsValid(value)); set_has_label(); label_ = value; @@ -5097,11 +5171,11 @@ void FieldDescriptorProto::clear_type() { type_ = 1; clear_has_type(); } - ::google::protobuf::FieldDescriptorProto_Type FieldDescriptorProto::type() const { +::google::protobuf::FieldDescriptorProto_Type FieldDescriptorProto::type() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type) return static_cast< ::google::protobuf::FieldDescriptorProto_Type >(type_); } - void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorProto_Type value) { +void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorProto_Type value) { assert(::google::protobuf::FieldDescriptorProto_Type_IsValid(value)); set_has_type(); type_ = value; @@ -5122,37 +5196,37 @@ void FieldDescriptorProto::clear_type_name() { type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_type_name(); } - const ::std::string& FieldDescriptorProto::type_name() const { +const ::std::string& FieldDescriptorProto::type_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name) return type_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_type_name(const ::std::string& value) { +void FieldDescriptorProto::set_type_name(const ::std::string& value) { set_has_type_name(); type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name) } - void FieldDescriptorProto::set_type_name(const char* value) { +void FieldDescriptorProto::set_type_name(const char* value) { set_has_type_name(); type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.type_name) } - void FieldDescriptorProto::set_type_name(const char* value, size_t size) { +void FieldDescriptorProto::set_type_name(const char* value, size_t size) { set_has_type_name(); type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.type_name) } - ::std::string* FieldDescriptorProto::mutable_type_name() { +::std::string* FieldDescriptorProto::mutable_type_name() { set_has_type_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.type_name) return type_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FieldDescriptorProto::release_type_name() { +::std::string* FieldDescriptorProto::release_type_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.type_name) clear_has_type_name(); return type_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_allocated_type_name(::std::string* type_name) { +void FieldDescriptorProto::set_allocated_type_name(::std::string* type_name) { if (type_name != NULL) { set_has_type_name(); } else { @@ -5176,37 +5250,37 @@ void FieldDescriptorProto::clear_extendee() { extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_extendee(); } - const ::std::string& FieldDescriptorProto::extendee() const { +const ::std::string& FieldDescriptorProto::extendee() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee) return extendee_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_extendee(const ::std::string& value) { +void FieldDescriptorProto::set_extendee(const ::std::string& value) { set_has_extendee(); extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee) } - void FieldDescriptorProto::set_extendee(const char* value) { +void FieldDescriptorProto::set_extendee(const char* value) { set_has_extendee(); extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.extendee) } - void FieldDescriptorProto::set_extendee(const char* value, size_t size) { +void FieldDescriptorProto::set_extendee(const char* value, size_t size) { set_has_extendee(); extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.extendee) } - ::std::string* FieldDescriptorProto::mutable_extendee() { +::std::string* FieldDescriptorProto::mutable_extendee() { set_has_extendee(); // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.extendee) return extendee_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FieldDescriptorProto::release_extendee() { +::std::string* FieldDescriptorProto::release_extendee() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.extendee) clear_has_extendee(); return extendee_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee) { +void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee) { if (extendee != NULL) { set_has_extendee(); } else { @@ -5230,37 +5304,37 @@ void FieldDescriptorProto::clear_default_value() { default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_default_value(); } - const ::std::string& FieldDescriptorProto::default_value() const { +const ::std::string& FieldDescriptorProto::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value) return default_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_default_value(const ::std::string& value) { +void FieldDescriptorProto::set_default_value(const ::std::string& value) { set_has_default_value(); default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value) } - void FieldDescriptorProto::set_default_value(const char* value) { +void FieldDescriptorProto::set_default_value(const char* value) { set_has_default_value(); default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.default_value) } - void FieldDescriptorProto::set_default_value(const char* value, size_t size) { +void FieldDescriptorProto::set_default_value(const char* value, size_t size) { set_has_default_value(); default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.default_value) } - ::std::string* FieldDescriptorProto::mutable_default_value() { +::std::string* FieldDescriptorProto::mutable_default_value() { set_has_default_value(); // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.default_value) return default_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FieldDescriptorProto::release_default_value() { +::std::string* FieldDescriptorProto::release_default_value() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.default_value) clear_has_default_value(); return default_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_allocated_default_value(::std::string* default_value) { +void FieldDescriptorProto::set_allocated_default_value(::std::string* default_value) { if (default_value != NULL) { set_has_default_value(); } else { @@ -5284,11 +5358,11 @@ void FieldDescriptorProto::clear_oneof_index() { oneof_index_ = 0; clear_has_oneof_index(); } - ::google::protobuf::int32 FieldDescriptorProto::oneof_index() const { +::google::protobuf::int32 FieldDescriptorProto::oneof_index() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.oneof_index) return oneof_index_; } - void FieldDescriptorProto::set_oneof_index(::google::protobuf::int32 value) { +void FieldDescriptorProto::set_oneof_index(::google::protobuf::int32 value) { set_has_oneof_index(); oneof_index_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.oneof_index) @@ -5308,37 +5382,37 @@ void FieldDescriptorProto::clear_json_name() { json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_json_name(); } - const ::std::string& FieldDescriptorProto::json_name() const { +const ::std::string& FieldDescriptorProto::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name) return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_json_name(const ::std::string& value) { +void FieldDescriptorProto::set_json_name(const ::std::string& value) { set_has_json_name(); json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name) } - void FieldDescriptorProto::set_json_name(const char* value) { +void FieldDescriptorProto::set_json_name(const char* value) { set_has_json_name(); json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.json_name) } - void FieldDescriptorProto::set_json_name(const char* value, size_t size) { +void FieldDescriptorProto::set_json_name(const char* value, size_t size) { set_has_json_name(); json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.json_name) } - ::std::string* FieldDescriptorProto::mutable_json_name() { +::std::string* FieldDescriptorProto::mutable_json_name() { set_has_json_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.json_name) return json_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FieldDescriptorProto::release_json_name() { +::std::string* FieldDescriptorProto::release_json_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.json_name) clear_has_json_name(); return json_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_allocated_json_name(::std::string* json_name) { +void FieldDescriptorProto::set_allocated_json_name(::std::string* json_name) { if (json_name != NULL) { set_has_json_name(); } else { @@ -5364,7 +5438,8 @@ void FieldDescriptorProto::clear_options() { } const ::google::protobuf::FieldOptions& FieldDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::FieldOptions::internal_default_instance(); } ::google::protobuf::FieldOptions* FieldDescriptorProto::mutable_options() { set_has_options(); @@ -5403,28 +5478,28 @@ const int OneofDescriptorProto::kOptionsFieldNumber; OneofDescriptorProto::OneofDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.OneofDescriptorProto) } void OneofDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::OneofOptions*>(&::google::protobuf::OneofOptions::default_instance()); + options_ = const_cast< ::google::protobuf::OneofOptions*>( + ::google::protobuf::OneofOptions::internal_default_instance()); } OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.OneofDescriptorProto) } void OneofDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } OneofDescriptorProto::~OneofDescriptorProto() { @@ -5434,9 +5509,7 @@ OneofDescriptorProto::~OneofDescriptorProto() { void OneofDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void OneofDescriptorProto::SetCachedSize(int size) const { @@ -5450,11 +5523,11 @@ const ::google::protobuf::Descriptor* OneofDescriptorProto::descriptor() { } const OneofDescriptorProto& OneofDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -OneofDescriptorProto* OneofDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> OneofDescriptorProto::default_instance_; OneofDescriptorProto* OneofDescriptorProto::New(::google::protobuf::Arena* arena) const { OneofDescriptorProto* n = new OneofDescriptorProto; @@ -5474,7 +5547,7 @@ void OneofDescriptorProto::Clear() { if (options_ != NULL) options_->::google::protobuf::OneofOptions::Clear(); } } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -5597,9 +5670,9 @@ void OneofDescriptorProto::SerializeWithCachedSizes( return target; } -int OneofDescriptorProto::ByteSize() const { +size_t OneofDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 3u) { // optional string name = 1; @@ -5622,18 +5695,17 @@ int OneofDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 OneofDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const OneofDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const OneofDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const OneofDescriptorProto>( &from); if (source == NULL) { @@ -5641,15 +5713,21 @@ void OneofDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.OneofDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void OneofDescriptorProto::MergeFrom(const OneofDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void OneofDescriptorProto::UnsafeMergeFrom(const OneofDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { set_has_name(); @@ -5660,7 +5738,8 @@ void OneofDescriptorProto::MergeFrom(const OneofDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -5675,7 +5754,7 @@ void OneofDescriptorProto::CopyFrom(const OneofDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool OneofDescriptorProto::IsInitialized() const { @@ -5723,37 +5802,37 @@ void OneofDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& OneofDescriptorProto::name() const { +const ::std::string& OneofDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void OneofDescriptorProto::set_name(const ::std::string& value) { +void OneofDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name) } - void OneofDescriptorProto::set_name(const char* value) { +void OneofDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.OneofDescriptorProto.name) } - void OneofDescriptorProto::set_name(const char* value, size_t size) { +void OneofDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.OneofDescriptorProto.name) } - ::std::string* OneofDescriptorProto::mutable_name() { +::std::string* OneofDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* OneofDescriptorProto::release_name() { +::std::string* OneofDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void OneofDescriptorProto::set_allocated_name(::std::string* name) { +void OneofDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -5779,7 +5858,8 @@ void OneofDescriptorProto::clear_options() { } const ::google::protobuf::OneofOptions& OneofDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::OneofOptions::internal_default_instance(); } ::google::protobuf::OneofOptions* OneofDescriptorProto::mutable_options() { set_has_options(); @@ -5819,28 +5899,28 @@ const int EnumDescriptorProto::kOptionsFieldNumber; EnumDescriptorProto::EnumDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumDescriptorProto) } void EnumDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::EnumOptions*>(&::google::protobuf::EnumOptions::default_instance()); + options_ = const_cast< ::google::protobuf::EnumOptions*>( + ::google::protobuf::EnumOptions::internal_default_instance()); } EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumDescriptorProto) } void EnumDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } EnumDescriptorProto::~EnumDescriptorProto() { @@ -5850,9 +5930,7 @@ EnumDescriptorProto::~EnumDescriptorProto() { void EnumDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void EnumDescriptorProto::SetCachedSize(int size) const { @@ -5866,11 +5944,11 @@ const ::google::protobuf::Descriptor* EnumDescriptorProto::descriptor() { } const EnumDescriptorProto& EnumDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -EnumDescriptorProto* EnumDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> EnumDescriptorProto::default_instance_; EnumDescriptorProto* EnumDescriptorProto::New(::google::protobuf::Arena* arena) const { EnumDescriptorProto* n = new EnumDescriptorProto; @@ -5891,7 +5969,7 @@ void EnumDescriptorProto::Clear() { } } value_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -6044,9 +6122,9 @@ void EnumDescriptorProto::SerializeWithCachedSizes( return target; } -int EnumDescriptorProto::ByteSize() const { +size_t EnumDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 5u) { // optional string name = 1; @@ -6065,11 +6143,14 @@ int EnumDescriptorProto::ByteSize() const { } // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - total_size += 1 * this->value_size(); - for (int i = 0; i < this->value_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->value(i)); + { + unsigned int count = this->value_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->value(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -6077,18 +6158,17 @@ int EnumDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 EnumDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const EnumDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const EnumDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumDescriptorProto>( &from); if (source == NULL) { @@ -6096,15 +6176,21 @@ void EnumDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void EnumDescriptorProto::UnsafeMergeFrom(const EnumDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); value_.MergeFrom(from.value_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { @@ -6116,7 +6202,8 @@ void EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -6131,7 +6218,7 @@ void EnumDescriptorProto::CopyFrom(const EnumDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool EnumDescriptorProto::IsInitialized() const { @@ -6181,37 +6268,37 @@ void EnumDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& EnumDescriptorProto::name() const { +const ::std::string& EnumDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void EnumDescriptorProto::set_name(const ::std::string& value) { +void EnumDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name) } - void EnumDescriptorProto::set_name(const char* value) { +void EnumDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.EnumDescriptorProto.name) } - void EnumDescriptorProto::set_name(const char* value, size_t size) { +void EnumDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.name) } - ::std::string* EnumDescriptorProto::mutable_name() { +::std::string* EnumDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* EnumDescriptorProto::release_name() { +::std::string* EnumDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void EnumDescriptorProto::set_allocated_name(::std::string* name) { +void EnumDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -6267,7 +6354,8 @@ void EnumDescriptorProto::clear_options() { } const ::google::protobuf::EnumOptions& EnumDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::EnumOptions::internal_default_instance(); } ::google::protobuf::EnumOptions* EnumDescriptorProto::mutable_options() { set_has_options(); @@ -6307,29 +6395,29 @@ const int EnumValueDescriptorProto::kOptionsFieldNumber; EnumValueDescriptorProto::EnumValueDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValueDescriptorProto) } void EnumValueDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::EnumValueOptions*>(&::google::protobuf::EnumValueOptions::default_instance()); + options_ = const_cast< ::google::protobuf::EnumValueOptions*>( + ::google::protobuf::EnumValueOptions::internal_default_instance()); } EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueDescriptorProto) } void EnumValueDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - number_ = 0; options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + number_ = 0; } EnumValueDescriptorProto::~EnumValueDescriptorProto() { @@ -6339,9 +6427,7 @@ EnumValueDescriptorProto::~EnumValueDescriptorProto() { void EnumValueDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void EnumValueDescriptorProto::SetCachedSize(int size) const { @@ -6355,11 +6441,11 @@ const ::google::protobuf::Descriptor* EnumValueDescriptorProto::descriptor() { } const EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -EnumValueDescriptorProto* EnumValueDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> EnumValueDescriptorProto::default_instance_; EnumValueDescriptorProto* EnumValueDescriptorProto::New(::google::protobuf::Arena* arena) const { EnumValueDescriptorProto* n = new EnumValueDescriptorProto; @@ -6380,7 +6466,7 @@ void EnumValueDescriptorProto::Clear() { if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear(); } } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -6416,10 +6502,10 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_number: + set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &number_))); - set_has_number(); } else { goto handle_unusual; } @@ -6528,9 +6614,9 @@ void EnumValueDescriptorProto::SerializeWithCachedSizes( return target; } -int EnumValueDescriptorProto::ByteSize() const { +size_t EnumValueDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 7u) { // optional string name = 1; @@ -6560,18 +6646,17 @@ int EnumValueDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 EnumValueDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const EnumValueDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const EnumValueDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumValueDescriptorProto>( &from); if (source == NULL) { @@ -6579,15 +6664,21 @@ void EnumValueDescriptorProto::MergeFrom(const ::google::protobuf::Message& from ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValueDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void EnumValueDescriptorProto::UnsafeMergeFrom(const EnumValueDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { set_has_name(); @@ -6601,7 +6692,8 @@ void EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -6616,7 +6708,7 @@ void EnumValueDescriptorProto::CopyFrom(const EnumValueDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool EnumValueDescriptorProto::IsInitialized() const { @@ -6665,37 +6757,37 @@ void EnumValueDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& EnumValueDescriptorProto::name() const { +const ::std::string& EnumValueDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void EnumValueDescriptorProto::set_name(const ::std::string& value) { +void EnumValueDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name) } - void EnumValueDescriptorProto::set_name(const char* value) { +void EnumValueDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValueDescriptorProto.name) } - void EnumValueDescriptorProto::set_name(const char* value, size_t size) { +void EnumValueDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValueDescriptorProto.name) } - ::std::string* EnumValueDescriptorProto::mutable_name() { +::std::string* EnumValueDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* EnumValueDescriptorProto::release_name() { +::std::string* EnumValueDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void EnumValueDescriptorProto::set_allocated_name(::std::string* name) { +void EnumValueDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -6719,11 +6811,11 @@ void EnumValueDescriptorProto::clear_number() { number_ = 0; clear_has_number(); } - ::google::protobuf::int32 EnumValueDescriptorProto::number() const { +::google::protobuf::int32 EnumValueDescriptorProto::number() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.number) return number_; } - void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value) { +void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value) { set_has_number(); number_ = value; // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.number) @@ -6745,7 +6837,8 @@ void EnumValueDescriptorProto::clear_options() { } const ::google::protobuf::EnumValueOptions& EnumValueDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::EnumValueOptions::internal_default_instance(); } ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::mutable_options() { set_has_options(); @@ -6785,28 +6878,28 @@ const int ServiceDescriptorProto::kOptionsFieldNumber; ServiceDescriptorProto::ServiceDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ServiceDescriptorProto) } void ServiceDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::ServiceOptions*>(&::google::protobuf::ServiceOptions::default_instance()); + options_ = const_cast< ::google::protobuf::ServiceOptions*>( + ::google::protobuf::ServiceOptions::internal_default_instance()); } ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceDescriptorProto) } void ServiceDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } ServiceDescriptorProto::~ServiceDescriptorProto() { @@ -6816,9 +6909,7 @@ ServiceDescriptorProto::~ServiceDescriptorProto() { void ServiceDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void ServiceDescriptorProto::SetCachedSize(int size) const { @@ -6832,11 +6923,11 @@ const ::google::protobuf::Descriptor* ServiceDescriptorProto::descriptor() { } const ServiceDescriptorProto& ServiceDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -ServiceDescriptorProto* ServiceDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> ServiceDescriptorProto::default_instance_; ServiceDescriptorProto* ServiceDescriptorProto::New(::google::protobuf::Arena* arena) const { ServiceDescriptorProto* n = new ServiceDescriptorProto; @@ -6857,7 +6948,7 @@ void ServiceDescriptorProto::Clear() { } } method_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -7010,9 +7101,9 @@ void ServiceDescriptorProto::SerializeWithCachedSizes( return target; } -int ServiceDescriptorProto::ByteSize() const { +size_t ServiceDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 5u) { // optional string name = 1; @@ -7031,11 +7122,14 @@ int ServiceDescriptorProto::ByteSize() const { } // repeated .google.protobuf.MethodDescriptorProto method = 2; - total_size += 1 * this->method_size(); - for (int i = 0; i < this->method_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->method(i)); + { + unsigned int count = this->method_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->method(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -7043,18 +7137,17 @@ int ServiceDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 ServiceDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const ServiceDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ServiceDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const ServiceDescriptorProto>( &from); if (source == NULL) { @@ -7062,15 +7155,21 @@ void ServiceDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ServiceDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void ServiceDescriptorProto::UnsafeMergeFrom(const ServiceDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); method_.MergeFrom(from.method_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { @@ -7082,7 +7181,8 @@ void ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -7097,7 +7197,7 @@ void ServiceDescriptorProto::CopyFrom(const ServiceDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ServiceDescriptorProto::IsInitialized() const { @@ -7147,37 +7247,37 @@ void ServiceDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& ServiceDescriptorProto::name() const { +const ::std::string& ServiceDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void ServiceDescriptorProto::set_name(const ::std::string& value) { +void ServiceDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name) } - void ServiceDescriptorProto::set_name(const char* value) { +void ServiceDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.ServiceDescriptorProto.name) } - void ServiceDescriptorProto::set_name(const char* value, size_t size) { +void ServiceDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.ServiceDescriptorProto.name) } - ::std::string* ServiceDescriptorProto::mutable_name() { +::std::string* ServiceDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* ServiceDescriptorProto::release_name() { +::std::string* ServiceDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void ServiceDescriptorProto::set_allocated_name(::std::string* name) { +void ServiceDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -7233,7 +7333,8 @@ void ServiceDescriptorProto::clear_options() { } const ::google::protobuf::ServiceOptions& ServiceDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::ServiceOptions::internal_default_instance(); } ::google::protobuf::ServiceOptions* ServiceDescriptorProto::mutable_options() { set_has_options(); @@ -7276,32 +7377,32 @@ const int MethodDescriptorProto::kServerStreamingFieldNumber; MethodDescriptorProto::MethodDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MethodDescriptorProto) } void MethodDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::MethodOptions*>(&::google::protobuf::MethodOptions::default_instance()); + options_ = const_cast< ::google::protobuf::MethodOptions*>( + ::google::protobuf::MethodOptions::internal_default_instance()); } MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodDescriptorProto) } void MethodDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); input_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); output_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; - client_streaming_ = false; - server_streaming_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&client_streaming_, 0, reinterpret_cast<char*>(&server_streaming_) - + reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_)); } MethodDescriptorProto::~MethodDescriptorProto() { @@ -7313,9 +7414,7 @@ void MethodDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); input_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); output_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void MethodDescriptorProto::SetCachedSize(int size) const { @@ -7329,11 +7428,11 @@ const ::google::protobuf::Descriptor* MethodDescriptorProto::descriptor() { } const MethodDescriptorProto& MethodDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -MethodDescriptorProto* MethodDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> MethodDescriptorProto::default_instance_; MethodDescriptorProto* MethodDescriptorProto::New(::google::protobuf::Arena* arena) const { MethodDescriptorProto* n = new MethodDescriptorProto; @@ -7380,7 +7479,7 @@ void MethodDescriptorProto::Clear() { #undef ZR_HELPER_ #undef ZR_ - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -7463,10 +7562,10 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( case 5: { if (tag == 40) { parse_client_streaming: + set_has_client_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &client_streaming_))); - set_has_client_streaming(); } else { goto handle_unusual; } @@ -7478,10 +7577,10 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( case 6: { if (tag == 48) { parse_server_streaming: + set_has_server_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &server_streaming_))); - set_has_server_streaming(); } else { goto handle_unusual; } @@ -7629,9 +7728,9 @@ void MethodDescriptorProto::SerializeWithCachedSizes( return target; } -int MethodDescriptorProto::ByteSize() const { +size_t MethodDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 63u) { // optional string name = 1; @@ -7678,18 +7777,17 @@ int MethodDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 MethodDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const MethodDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const MethodDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const MethodDescriptorProto>( &from); if (source == NULL) { @@ -7697,15 +7795,21 @@ void MethodDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MethodDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void MethodDescriptorProto::UnsafeMergeFrom(const MethodDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { set_has_name(); @@ -7730,7 +7834,8 @@ void MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -7745,7 +7850,7 @@ void MethodDescriptorProto::CopyFrom(const MethodDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool MethodDescriptorProto::IsInitialized() const { @@ -7797,37 +7902,37 @@ void MethodDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& MethodDescriptorProto::name() const { +const ::std::string& MethodDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void MethodDescriptorProto::set_name(const ::std::string& value) { +void MethodDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name) } - void MethodDescriptorProto::set_name(const char* value) { +void MethodDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.name) } - void MethodDescriptorProto::set_name(const char* value, size_t size) { +void MethodDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.name) } - ::std::string* MethodDescriptorProto::mutable_name() { +::std::string* MethodDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* MethodDescriptorProto::release_name() { +::std::string* MethodDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void MethodDescriptorProto::set_allocated_name(::std::string* name) { +void MethodDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -7851,37 +7956,37 @@ void MethodDescriptorProto::clear_input_type() { input_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_input_type(); } - const ::std::string& MethodDescriptorProto::input_type() const { +const ::std::string& MethodDescriptorProto::input_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type) return input_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void MethodDescriptorProto::set_input_type(const ::std::string& value) { +void MethodDescriptorProto::set_input_type(const ::std::string& value) { set_has_input_type(); input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type) } - void MethodDescriptorProto::set_input_type(const char* value) { +void MethodDescriptorProto::set_input_type(const char* value) { set_has_input_type(); input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.input_type) } - void MethodDescriptorProto::set_input_type(const char* value, size_t size) { +void MethodDescriptorProto::set_input_type(const char* value, size_t size) { set_has_input_type(); input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.input_type) } - ::std::string* MethodDescriptorProto::mutable_input_type() { +::std::string* MethodDescriptorProto::mutable_input_type() { set_has_input_type(); // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.input_type) return input_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* MethodDescriptorProto::release_input_type() { +::std::string* MethodDescriptorProto::release_input_type() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.input_type) clear_has_input_type(); return input_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void MethodDescriptorProto::set_allocated_input_type(::std::string* input_type) { +void MethodDescriptorProto::set_allocated_input_type(::std::string* input_type) { if (input_type != NULL) { set_has_input_type(); } else { @@ -7905,37 +8010,37 @@ void MethodDescriptorProto::clear_output_type() { output_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_output_type(); } - const ::std::string& MethodDescriptorProto::output_type() const { +const ::std::string& MethodDescriptorProto::output_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type) return output_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void MethodDescriptorProto::set_output_type(const ::std::string& value) { +void MethodDescriptorProto::set_output_type(const ::std::string& value) { set_has_output_type(); output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type) } - void MethodDescriptorProto::set_output_type(const char* value) { +void MethodDescriptorProto::set_output_type(const char* value) { set_has_output_type(); output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.output_type) } - void MethodDescriptorProto::set_output_type(const char* value, size_t size) { +void MethodDescriptorProto::set_output_type(const char* value, size_t size) { set_has_output_type(); output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.output_type) } - ::std::string* MethodDescriptorProto::mutable_output_type() { +::std::string* MethodDescriptorProto::mutable_output_type() { set_has_output_type(); // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.output_type) return output_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* MethodDescriptorProto::release_output_type() { +::std::string* MethodDescriptorProto::release_output_type() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.output_type) clear_has_output_type(); return output_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void MethodDescriptorProto::set_allocated_output_type(::std::string* output_type) { +void MethodDescriptorProto::set_allocated_output_type(::std::string* output_type) { if (output_type != NULL) { set_has_output_type(); } else { @@ -7961,7 +8066,8 @@ void MethodDescriptorProto::clear_options() { } const ::google::protobuf::MethodOptions& MethodDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::MethodOptions::internal_default_instance(); } ::google::protobuf::MethodOptions* MethodDescriptorProto::mutable_options() { set_has_options(); @@ -8003,11 +8109,11 @@ void MethodDescriptorProto::clear_client_streaming() { client_streaming_ = false; clear_has_client_streaming(); } - bool MethodDescriptorProto::client_streaming() const { +bool MethodDescriptorProto::client_streaming() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.client_streaming) return client_streaming_; } - void MethodDescriptorProto::set_client_streaming(bool value) { +void MethodDescriptorProto::set_client_streaming(bool value) { set_has_client_streaming(); client_streaming_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.client_streaming) @@ -8027,11 +8133,11 @@ void MethodDescriptorProto::clear_server_streaming() { server_streaming_ = false; clear_has_server_streaming(); } - bool MethodDescriptorProto::server_streaming() const { +bool MethodDescriptorProto::server_streaming() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.server_streaming) return server_streaming_; } - void MethodDescriptorProto::set_server_streaming(bool value) { +void MethodDescriptorProto::set_server_streaming(bool value) { set_has_server_streaming(); server_streaming_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.server_streaming) @@ -8046,7 +8152,7 @@ const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor() return FileOptions_OptimizeMode_descriptor_; } bool FileOptions_OptimizeMode_IsValid(int value) { - switch(value) { + switch (value) { case 1: case 2: case 3: @@ -8068,7 +8174,6 @@ const int FileOptions::OptimizeMode_ARRAYSIZE; const int FileOptions::kJavaPackageFieldNumber; const int FileOptions::kJavaOuterClassnameFieldNumber; const int FileOptions::kJavaMultipleFilesFieldNumber; -const int FileOptions::kJavaGenerateEqualsAndHashFieldNumber; const int FileOptions::kJavaStringCheckUtf8FieldNumber; const int FileOptions::kOptimizeForFieldNumber; const int FileOptions::kGoPackageFieldNumber; @@ -8084,6 +8189,7 @@ const int FileOptions::kUninterpretedOptionFieldNumber; FileOptions::FileOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileOptions) } @@ -8095,28 +8201,20 @@ FileOptions::FileOptions(const FileOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileOptions) } void FileOptions::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; java_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); java_outer_classname_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - java_multiple_files_ = false; - java_generate_equals_and_hash_ = false; - java_string_check_utf8_ = false; - optimize_for_ = 1; go_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - cc_generic_services_ = false; - java_generic_services_ = false; - py_generic_services_ = false; - deprecated_ = false; - cc_enable_arenas_ = false; objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&java_multiple_files_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) - + reinterpret_cast<char*>(&java_multiple_files_) + sizeof(cc_enable_arenas_)); + optimize_for_ = 1; } FileOptions::~FileOptions() { @@ -8130,8 +8228,6 @@ void FileOptions::SharedDtor() { go_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); objc_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void FileOptions::SetCachedSize(int size) const { @@ -8145,11 +8241,11 @@ const ::google::protobuf::Descriptor* FileOptions::descriptor() { } const FileOptions& FileOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -FileOptions* FileOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<FileOptions> FileOptions::default_instance_; FileOptions* FileOptions::New(::google::protobuf::Arena* arena) const { FileOptions* n = new FileOptions; @@ -8179,7 +8275,7 @@ void FileOptions::Clear() { } while (0) if (_has_bits_[0 / 32] & 255u) { - ZR_(java_multiple_files_, cc_generic_services_); + ZR_(java_multiple_files_, java_generic_services_); if (has_java_package()) { java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } @@ -8191,8 +8287,8 @@ void FileOptions::Clear() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } } - if (_has_bits_[8 / 32] & 16128u) { - ZR_(java_generic_services_, cc_enable_arenas_); + if (_has_bits_[8 / 32] & 7936u) { + ZR_(py_generic_services_, cc_enable_arenas_); if (has_objc_class_prefix()) { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } @@ -8205,7 +8301,7 @@ void FileOptions::Clear() { #undef ZR_ uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -8278,10 +8374,10 @@ bool FileOptions::MergePartialFromCodedStream( case 10: { if (tag == 80) { parse_java_multiple_files: + set_has_java_multiple_files(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &java_multiple_files_))); - set_has_java_multiple_files(); } else { goto handle_unusual; } @@ -8310,10 +8406,10 @@ bool FileOptions::MergePartialFromCodedStream( case 16: { if (tag == 128) { parse_cc_generic_services: + set_has_cc_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &cc_generic_services_))); - set_has_cc_generic_services(); } else { goto handle_unusual; } @@ -8325,10 +8421,10 @@ bool FileOptions::MergePartialFromCodedStream( case 17: { if (tag == 136) { parse_java_generic_services: + set_has_java_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &java_generic_services_))); - set_has_java_generic_services(); } else { goto handle_unusual; } @@ -8340,25 +8436,10 @@ bool FileOptions::MergePartialFromCodedStream( case 18: { if (tag == 144) { parse_py_generic_services: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &py_generic_services_))); set_has_py_generic_services(); - } else { - goto handle_unusual; - } - if (input->ExpectTag(160)) goto parse_java_generate_equals_and_hash; - break; - } - - // optional bool java_generate_equals_and_hash = 20 [default = false]; - case 20: { - if (tag == 160) { - parse_java_generate_equals_and_hash: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &java_generate_equals_and_hash_))); - set_has_java_generate_equals_and_hash(); + input, &py_generic_services_))); } else { goto handle_unusual; } @@ -8370,10 +8451,10 @@ bool FileOptions::MergePartialFromCodedStream( case 23: { if (tag == 184) { parse_deprecated: + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -8385,10 +8466,10 @@ bool FileOptions::MergePartialFromCodedStream( case 27: { if (tag == 216) { parse_java_string_check_utf8: + set_has_java_string_check_utf8(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &java_string_check_utf8_))); - set_has_java_string_check_utf8(); } else { goto handle_unusual; } @@ -8400,10 +8481,10 @@ bool FileOptions::MergePartialFromCodedStream( case 31: { if (tag == 248) { parse_cc_enable_arenas: + set_has_cc_enable_arenas(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &cc_enable_arenas_))); - set_has_cc_enable_arenas(); } else { goto handle_unusual; } @@ -8470,7 +8551,7 @@ bool FileOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -8548,11 +8629,6 @@ void FileOptions::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(18, this->py_generic_services(), output); } - // optional bool java_generate_equals_and_hash = 20 [default = false]; - if (has_java_generate_equals_and_hash()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(20, this->java_generate_equals_and_hash(), output); - } - // optional bool deprecated = 23 [default = false]; if (has_deprecated()) { ::google::protobuf::internal::WireFormatLite::WriteBool(23, this->deprecated(), output); @@ -8668,11 +8744,6 @@ void FileOptions::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(18, this->py_generic_services(), target); } - // optional bool java_generate_equals_and_hash = 20 [default = false]; - if (has_java_generate_equals_and_hash()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(20, this->java_generate_equals_and_hash(), target); - } - // optional bool deprecated = 23 [default = false]; if (has_deprecated()) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(23, this->deprecated(), target); @@ -8729,9 +8800,9 @@ void FileOptions::SerializeWithCachedSizes( return target; } -int FileOptions::ByteSize() const { +size_t FileOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileOptions) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 255u) { // optional string java_package = 1; @@ -8753,11 +8824,6 @@ int FileOptions::ByteSize() const { total_size += 1 + 1; } - // optional bool java_generate_equals_and_hash = 20 [default = false]; - if (has_java_generate_equals_and_hash()) { - total_size += 2 + 1; - } - // optional bool java_string_check_utf8 = 27 [default = false]; if (has_java_string_check_utf8()) { total_size += 2 + 1; @@ -8781,13 +8847,13 @@ int FileOptions::ByteSize() const { total_size += 2 + 1; } - } - if (_has_bits_[8 / 32] & 16128u) { // optional bool java_generic_services = 17 [default = false]; if (has_java_generic_services()) { total_size += 2 + 1; } + } + if (_has_bits_[8 / 32] & 7936u) { // optional bool py_generic_services = 18 [default = false]; if (has_py_generic_services()) { total_size += 2 + 1; @@ -8819,11 +8885,14 @@ int FileOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -8833,18 +8902,17 @@ int FileOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 FileOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const FileOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FileOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const FileOptions>( &from); if (source == NULL) { @@ -8852,15 +8920,21 @@ void FileOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void FileOptions::MergeFrom(const FileOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void FileOptions::UnsafeMergeFrom(const FileOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_java_package()) { @@ -8874,9 +8948,6 @@ void FileOptions::MergeFrom(const FileOptions& from) { if (from.has_java_multiple_files()) { set_java_multiple_files(from.java_multiple_files()); } - if (from.has_java_generate_equals_and_hash()) { - set_java_generate_equals_and_hash(from.java_generate_equals_and_hash()); - } if (from.has_java_string_check_utf8()) { set_java_string_check_utf8(from.java_string_check_utf8()); } @@ -8890,11 +8961,11 @@ void FileOptions::MergeFrom(const FileOptions& from) { if (from.has_cc_generic_services()) { set_cc_generic_services(from.cc_generic_services()); } - } - if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (from.has_java_generic_services()) { set_java_generic_services(from.java_generic_services()); } + } + if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (from.has_py_generic_services()) { set_py_generic_services(from.py_generic_services()); } @@ -8915,7 +8986,8 @@ void FileOptions::MergeFrom(const FileOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -8930,14 +9002,17 @@ void FileOptions::CopyFrom(const FileOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FileOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; return true; + if (!_extensions_.IsInitialized()) { + return false; + } + return true; } void FileOptions::Swap(FileOptions* other) { @@ -8948,7 +9023,6 @@ void FileOptions::InternalSwap(FileOptions* other) { java_package_.Swap(&other->java_package_); java_outer_classname_.Swap(&other->java_outer_classname_); std::swap(java_multiple_files_, other->java_multiple_files_); - std::swap(java_generate_equals_and_hash_, other->java_generate_equals_and_hash_); std::swap(java_string_check_utf8_, other->java_string_check_utf8_); std::swap(optimize_for_, other->optimize_for_); go_package_.Swap(&other->go_package_); @@ -8991,37 +9065,37 @@ void FileOptions::clear_java_package() { java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_java_package(); } - const ::std::string& FileOptions::java_package() const { +const ::std::string& FileOptions::java_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package) return java_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_java_package(const ::std::string& value) { +void FileOptions::set_java_package(const ::std::string& value) { set_has_java_package(); java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package) } - void FileOptions::set_java_package(const char* value) { +void FileOptions::set_java_package(const char* value) { set_has_java_package(); java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_package) } - void FileOptions::set_java_package(const char* value, size_t size) { +void FileOptions::set_java_package(const char* value, size_t size) { set_has_java_package(); java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_package) } - ::std::string* FileOptions::mutable_java_package() { +::std::string* FileOptions::mutable_java_package() { set_has_java_package(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_package) return java_package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileOptions::release_java_package() { +::std::string* FileOptions::release_java_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_package) clear_has_java_package(); return java_package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_allocated_java_package(::std::string* java_package) { +void FileOptions::set_allocated_java_package(::std::string* java_package) { if (java_package != NULL) { set_has_java_package(); } else { @@ -9045,37 +9119,37 @@ void FileOptions::clear_java_outer_classname() { java_outer_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_java_outer_classname(); } - const ::std::string& FileOptions::java_outer_classname() const { +const ::std::string& FileOptions::java_outer_classname() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname) return java_outer_classname_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_java_outer_classname(const ::std::string& value) { +void FileOptions::set_java_outer_classname(const ::std::string& value) { set_has_java_outer_classname(); java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname) } - void FileOptions::set_java_outer_classname(const char* value) { +void FileOptions::set_java_outer_classname(const char* value) { set_has_java_outer_classname(); java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_outer_classname) } - void FileOptions::set_java_outer_classname(const char* value, size_t size) { +void FileOptions::set_java_outer_classname(const char* value, size_t size) { set_has_java_outer_classname(); java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_outer_classname) } - ::std::string* FileOptions::mutable_java_outer_classname() { +::std::string* FileOptions::mutable_java_outer_classname() { set_has_java_outer_classname(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_outer_classname) return java_outer_classname_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileOptions::release_java_outer_classname() { +::std::string* FileOptions::release_java_outer_classname() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_outer_classname) clear_has_java_outer_classname(); return java_outer_classname_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_classname) { +void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_classname) { if (java_outer_classname != NULL) { set_has_java_outer_classname(); } else { @@ -9099,59 +9173,35 @@ void FileOptions::clear_java_multiple_files() { java_multiple_files_ = false; clear_has_java_multiple_files(); } - bool FileOptions::java_multiple_files() const { +bool FileOptions::java_multiple_files() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_multiple_files) return java_multiple_files_; } - void FileOptions::set_java_multiple_files(bool value) { +void FileOptions::set_java_multiple_files(bool value) { set_has_java_multiple_files(); java_multiple_files_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_multiple_files) } -// optional bool java_generate_equals_and_hash = 20 [default = false]; -bool FileOptions::has_java_generate_equals_and_hash() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000008u; -} -void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000008u; -} -void FileOptions::clear_java_generate_equals_and_hash() { - java_generate_equals_and_hash_ = false; - clear_has_java_generate_equals_and_hash(); -} - bool FileOptions::java_generate_equals_and_hash() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generate_equals_and_hash) - return java_generate_equals_and_hash_; -} - void FileOptions::set_java_generate_equals_and_hash(bool value) { - set_has_java_generate_equals_and_hash(); - java_generate_equals_and_hash_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generate_equals_and_hash) -} - // optional bool java_string_check_utf8 = 27 [default = false]; bool FileOptions::has_java_string_check_utf8() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000008u; } void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000008u; } void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; clear_has_java_string_check_utf8(); } - bool FileOptions::java_string_check_utf8() const { +bool FileOptions::java_string_check_utf8() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_string_check_utf8) return java_string_check_utf8_; } - void FileOptions::set_java_string_check_utf8(bool value) { +void FileOptions::set_java_string_check_utf8(bool value) { set_has_java_string_check_utf8(); java_string_check_utf8_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_string_check_utf8) @@ -9159,23 +9209,23 @@ void FileOptions::clear_java_string_check_utf8() { // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; bool FileOptions::has_optimize_for() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000010u; } void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000010u; } void FileOptions::clear_optimize_for() { optimize_for_ = 1; clear_has_optimize_for(); } - ::google::protobuf::FileOptions_OptimizeMode FileOptions::optimize_for() const { +::google::protobuf::FileOptions_OptimizeMode FileOptions::optimize_for() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.optimize_for) return static_cast< ::google::protobuf::FileOptions_OptimizeMode >(optimize_for_); } - void FileOptions::set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value) { +void FileOptions::set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value) { assert(::google::protobuf::FileOptions_OptimizeMode_IsValid(value)); set_has_optimize_for(); optimize_for_ = value; @@ -9184,49 +9234,49 @@ void FileOptions::clear_optimize_for() { // optional string go_package = 11; bool FileOptions::has_go_package() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } void FileOptions::set_has_go_package() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000020u; } void FileOptions::clear_has_go_package() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000020u; } void FileOptions::clear_go_package() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_go_package(); } - const ::std::string& FileOptions::go_package() const { +const ::std::string& FileOptions::go_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package) return go_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_go_package(const ::std::string& value) { +void FileOptions::set_go_package(const ::std::string& value) { set_has_go_package(); go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package) } - void FileOptions::set_go_package(const char* value) { +void FileOptions::set_go_package(const char* value) { set_has_go_package(); go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.go_package) } - void FileOptions::set_go_package(const char* value, size_t size) { +void FileOptions::set_go_package(const char* value, size_t size) { set_has_go_package(); go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.go_package) } - ::std::string* FileOptions::mutable_go_package() { +::std::string* FileOptions::mutable_go_package() { set_has_go_package(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.go_package) return go_package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileOptions::release_go_package() { +::std::string* FileOptions::release_go_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.go_package) clear_has_go_package(); return go_package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_allocated_go_package(::std::string* go_package) { +void FileOptions::set_allocated_go_package(::std::string* go_package) { if (go_package != NULL) { set_has_go_package(); } else { @@ -9238,23 +9288,23 @@ void FileOptions::clear_go_package() { // optional bool cc_generic_services = 16 [default = false]; bool FileOptions::has_cc_generic_services() const { - return (_has_bits_[0] & 0x00000080u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000040u; } void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000040u; } void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; clear_has_cc_generic_services(); } - bool FileOptions::cc_generic_services() const { +bool FileOptions::cc_generic_services() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_generic_services) return cc_generic_services_; } - void FileOptions::set_cc_generic_services(bool value) { +void FileOptions::set_cc_generic_services(bool value) { set_has_cc_generic_services(); cc_generic_services_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_generic_services) @@ -9262,23 +9312,23 @@ void FileOptions::clear_cc_generic_services() { // optional bool java_generic_services = 17 [default = false]; bool FileOptions::has_java_generic_services() const { - return (_has_bits_[0] & 0x00000100u) != 0; + return (_has_bits_[0] & 0x00000080u) != 0; } void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000080u; } void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000080u; } void FileOptions::clear_java_generic_services() { java_generic_services_ = false; clear_has_java_generic_services(); } - bool FileOptions::java_generic_services() const { +bool FileOptions::java_generic_services() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generic_services) return java_generic_services_; } - void FileOptions::set_java_generic_services(bool value) { +void FileOptions::set_java_generic_services(bool value) { set_has_java_generic_services(); java_generic_services_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generic_services) @@ -9286,23 +9336,23 @@ void FileOptions::clear_java_generic_services() { // optional bool py_generic_services = 18 [default = false]; bool FileOptions::has_py_generic_services() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000100u) != 0; } void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000100u; } void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000100u; } void FileOptions::clear_py_generic_services() { py_generic_services_ = false; clear_has_py_generic_services(); } - bool FileOptions::py_generic_services() const { +bool FileOptions::py_generic_services() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.py_generic_services) return py_generic_services_; } - void FileOptions::set_py_generic_services(bool value) { +void FileOptions::set_py_generic_services(bool value) { set_has_py_generic_services(); py_generic_services_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.py_generic_services) @@ -9310,23 +9360,23 @@ void FileOptions::clear_py_generic_services() { // optional bool deprecated = 23 [default = false]; bool FileOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00000200u) != 0; } void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00000200u; } void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00000200u; } void FileOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool FileOptions::deprecated() const { +bool FileOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.deprecated) return deprecated_; } - void FileOptions::set_deprecated(bool value) { +void FileOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.deprecated) @@ -9334,23 +9384,23 @@ void FileOptions::clear_deprecated() { // optional bool cc_enable_arenas = 31 [default = false]; bool FileOptions::has_cc_enable_arenas() const { - return (_has_bits_[0] & 0x00000800u) != 0; + return (_has_bits_[0] & 0x00000400u) != 0; } void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00000400u; } void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00000400u; } void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; clear_has_cc_enable_arenas(); } - bool FileOptions::cc_enable_arenas() const { +bool FileOptions::cc_enable_arenas() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_enable_arenas) return cc_enable_arenas_; } - void FileOptions::set_cc_enable_arenas(bool value) { +void FileOptions::set_cc_enable_arenas(bool value) { set_has_cc_enable_arenas(); cc_enable_arenas_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_enable_arenas) @@ -9358,49 +9408,49 @@ void FileOptions::clear_cc_enable_arenas() { // optional string objc_class_prefix = 36; bool FileOptions::has_objc_class_prefix() const { - return (_has_bits_[0] & 0x00001000u) != 0; + return (_has_bits_[0] & 0x00000800u) != 0; } void FileOptions::set_has_objc_class_prefix() { - _has_bits_[0] |= 0x00001000u; + _has_bits_[0] |= 0x00000800u; } void FileOptions::clear_has_objc_class_prefix() { - _has_bits_[0] &= ~0x00001000u; + _has_bits_[0] &= ~0x00000800u; } void FileOptions::clear_objc_class_prefix() { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_objc_class_prefix(); } - const ::std::string& FileOptions::objc_class_prefix() const { +const ::std::string& FileOptions::objc_class_prefix() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix) return objc_class_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_objc_class_prefix(const ::std::string& value) { +void FileOptions::set_objc_class_prefix(const ::std::string& value) { set_has_objc_class_prefix(); objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix) } - void FileOptions::set_objc_class_prefix(const char* value) { +void FileOptions::set_objc_class_prefix(const char* value) { set_has_objc_class_prefix(); objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.objc_class_prefix) } - void FileOptions::set_objc_class_prefix(const char* value, size_t size) { +void FileOptions::set_objc_class_prefix(const char* value, size_t size) { set_has_objc_class_prefix(); objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.objc_class_prefix) } - ::std::string* FileOptions::mutable_objc_class_prefix() { +::std::string* FileOptions::mutable_objc_class_prefix() { set_has_objc_class_prefix(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.objc_class_prefix) return objc_class_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileOptions::release_objc_class_prefix() { +::std::string* FileOptions::release_objc_class_prefix() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.objc_class_prefix) clear_has_objc_class_prefix(); return objc_class_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_class_prefix) { +void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_class_prefix) { if (objc_class_prefix != NULL) { set_has_objc_class_prefix(); } else { @@ -9412,49 +9462,49 @@ void FileOptions::clear_objc_class_prefix() { // optional string csharp_namespace = 37; bool FileOptions::has_csharp_namespace() const { - return (_has_bits_[0] & 0x00002000u) != 0; + return (_has_bits_[0] & 0x00001000u) != 0; } void FileOptions::set_has_csharp_namespace() { - _has_bits_[0] |= 0x00002000u; + _has_bits_[0] |= 0x00001000u; } void FileOptions::clear_has_csharp_namespace() { - _has_bits_[0] &= ~0x00002000u; + _has_bits_[0] &= ~0x00001000u; } void FileOptions::clear_csharp_namespace() { csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_csharp_namespace(); } - const ::std::string& FileOptions::csharp_namespace() const { +const ::std::string& FileOptions::csharp_namespace() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace) return csharp_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_csharp_namespace(const ::std::string& value) { +void FileOptions::set_csharp_namespace(const ::std::string& value) { set_has_csharp_namespace(); csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace) } - void FileOptions::set_csharp_namespace(const char* value) { +void FileOptions::set_csharp_namespace(const char* value) { set_has_csharp_namespace(); csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_namespace) } - void FileOptions::set_csharp_namespace(const char* value, size_t size) { +void FileOptions::set_csharp_namespace(const char* value, size_t size) { set_has_csharp_namespace(); csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_namespace) } - ::std::string* FileOptions::mutable_csharp_namespace() { +::std::string* FileOptions::mutable_csharp_namespace() { set_has_csharp_namespace(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_namespace) return csharp_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileOptions::release_csharp_namespace() { +::std::string* FileOptions::release_csharp_namespace() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.csharp_namespace) clear_has_csharp_namespace(); return csharp_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_namespace) { +void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_namespace) { if (csharp_namespace != NULL) { set_has_csharp_namespace(); } else { @@ -9508,6 +9558,7 @@ const int MessageOptions::kUninterpretedOptionFieldNumber; MessageOptions::MessageOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MessageOptions) } @@ -9519,17 +9570,14 @@ MessageOptions::MessageOptions(const MessageOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.MessageOptions) } void MessageOptions::SharedCtor() { _cached_size_ = 0; - message_set_wire_format_ = false; - no_standard_descriptor_accessor_ = false; - deprecated_ = false; - map_entry_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&message_set_wire_format_, 0, reinterpret_cast<char*>(&map_entry_) - + reinterpret_cast<char*>(&message_set_wire_format_) + sizeof(map_entry_)); } MessageOptions::~MessageOptions() { @@ -9538,8 +9586,6 @@ MessageOptions::~MessageOptions() { } void MessageOptions::SharedDtor() { - if (this != default_instance_) { - } } void MessageOptions::SetCachedSize(int size) const { @@ -9553,11 +9599,11 @@ const ::google::protobuf::Descriptor* MessageOptions::descriptor() { } const MessageOptions& MessageOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -MessageOptions* MessageOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> MessageOptions::default_instance_; MessageOptions* MessageOptions::New(::google::protobuf::Arena* arena) const { MessageOptions* n = new MessageOptions; @@ -9592,7 +9638,7 @@ void MessageOptions::Clear() { #undef ZR_ uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -9611,10 +9657,10 @@ bool MessageOptions::MergePartialFromCodedStream( // optional bool message_set_wire_format = 1 [default = false]; case 1: { if (tag == 8) { + set_has_message_set_wire_format(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &message_set_wire_format_))); - set_has_message_set_wire_format(); } else { goto handle_unusual; } @@ -9626,10 +9672,10 @@ bool MessageOptions::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_no_standard_descriptor_accessor: + set_has_no_standard_descriptor_accessor(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &no_standard_descriptor_accessor_))); - set_has_no_standard_descriptor_accessor(); } else { goto handle_unusual; } @@ -9641,10 +9687,10 @@ bool MessageOptions::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_deprecated: + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -9656,10 +9702,10 @@ bool MessageOptions::MergePartialFromCodedStream( case 7: { if (tag == 56) { parse_map_entry: + set_has_map_entry(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &map_entry_))); - set_has_map_entry(); } else { goto handle_unusual; } @@ -9692,7 +9738,7 @@ bool MessageOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -9794,9 +9840,9 @@ void MessageOptions::SerializeWithCachedSizes( return target; } -int MessageOptions::ByteSize() const { +size_t MessageOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MessageOptions) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 15u) { // optional bool message_set_wire_format = 1 [default = false]; @@ -9821,11 +9867,14 @@ int MessageOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -9835,18 +9884,17 @@ int MessageOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 MessageOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MessageOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const MessageOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const MessageOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const MessageOptions>( &from); if (source == NULL) { @@ -9854,15 +9902,21 @@ void MessageOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MessageOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void MessageOptions::MergeFrom(const MessageOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MessageOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void MessageOptions::UnsafeMergeFrom(const MessageOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_message_set_wire_format()) { @@ -9880,7 +9934,8 @@ void MessageOptions::MergeFrom(const MessageOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -9895,14 +9950,17 @@ void MessageOptions::CopyFrom(const MessageOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MessageOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool MessageOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; return true; + if (!_extensions_.IsInitialized()) { + return false; + } + return true; } void MessageOptions::Swap(MessageOptions* other) { @@ -9946,11 +10004,11 @@ void MessageOptions::clear_message_set_wire_format() { message_set_wire_format_ = false; clear_has_message_set_wire_format(); } - bool MessageOptions::message_set_wire_format() const { +bool MessageOptions::message_set_wire_format() const { // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.message_set_wire_format) return message_set_wire_format_; } - void MessageOptions::set_message_set_wire_format(bool value) { +void MessageOptions::set_message_set_wire_format(bool value) { set_has_message_set_wire_format(); message_set_wire_format_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.message_set_wire_format) @@ -9970,11 +10028,11 @@ void MessageOptions::clear_no_standard_descriptor_accessor() { no_standard_descriptor_accessor_ = false; clear_has_no_standard_descriptor_accessor(); } - bool MessageOptions::no_standard_descriptor_accessor() const { +bool MessageOptions::no_standard_descriptor_accessor() const { // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.no_standard_descriptor_accessor) return no_standard_descriptor_accessor_; } - void MessageOptions::set_no_standard_descriptor_accessor(bool value) { +void MessageOptions::set_no_standard_descriptor_accessor(bool value) { set_has_no_standard_descriptor_accessor(); no_standard_descriptor_accessor_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.no_standard_descriptor_accessor) @@ -9994,11 +10052,11 @@ void MessageOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool MessageOptions::deprecated() const { +bool MessageOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.deprecated) return deprecated_; } - void MessageOptions::set_deprecated(bool value) { +void MessageOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.deprecated) @@ -10018,11 +10076,11 @@ void MessageOptions::clear_map_entry() { map_entry_ = false; clear_has_map_entry(); } - bool MessageOptions::map_entry() const { +bool MessageOptions::map_entry() const { // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.map_entry) return map_entry_; } - void MessageOptions::set_map_entry(bool value) { +void MessageOptions::set_map_entry(bool value) { set_has_map_entry(); map_entry_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.map_entry) @@ -10067,7 +10125,7 @@ const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor() { return FieldOptions_CType_descriptor_; } bool FieldOptions_CType_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -10090,7 +10148,7 @@ const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor() { return FieldOptions_JSType_descriptor_; } bool FieldOptions_JSType_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -10120,6 +10178,7 @@ const int FieldOptions::kUninterpretedOptionFieldNumber; FieldOptions::FieldOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldOptions) } @@ -10131,19 +10190,14 @@ FieldOptions::FieldOptions(const FieldOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldOptions) } void FieldOptions::SharedCtor() { _cached_size_ = 0; - ctype_ = 0; - packed_ = false; - jstype_ = 0; - lazy_ = false; - deprecated_ = false; - weak_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&ctype_, 0, reinterpret_cast<char*>(&weak_) - + reinterpret_cast<char*>(&ctype_) + sizeof(weak_)); } FieldOptions::~FieldOptions() { @@ -10152,8 +10206,6 @@ FieldOptions::~FieldOptions() { } void FieldOptions::SharedDtor() { - if (this != default_instance_) { - } } void FieldOptions::SetCachedSize(int size) const { @@ -10167,11 +10219,11 @@ const ::google::protobuf::Descriptor* FieldOptions::descriptor() { } const FieldOptions& FieldOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -FieldOptions* FieldOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> FieldOptions::default_instance_; FieldOptions* FieldOptions::New(::google::protobuf::Arena* arena) const { FieldOptions* n = new FieldOptions; @@ -10200,16 +10252,13 @@ void FieldOptions::Clear() { ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ } while (0) - if (_has_bits_[0 / 32] & 63u) { - ZR_(ctype_, jstype_); - ZR_(packed_, weak_); - } + ZR_(ctype_, weak_); #undef ZR_HELPER_ #undef ZR_ uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -10248,10 +10297,10 @@ bool FieldOptions::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_packed: + set_has_packed(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &packed_))); - set_has_packed(); } else { goto handle_unusual; } @@ -10263,10 +10312,10 @@ bool FieldOptions::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_deprecated: + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -10278,10 +10327,10 @@ bool FieldOptions::MergePartialFromCodedStream( case 5: { if (tag == 40) { parse_lazy: + set_has_lazy(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &lazy_))); - set_has_lazy(); } else { goto handle_unusual; } @@ -10313,10 +10362,10 @@ bool FieldOptions::MergePartialFromCodedStream( case 10: { if (tag == 80) { parse_weak: + set_has_weak(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &weak_))); - set_has_weak(); } else { goto handle_unusual; } @@ -10349,7 +10398,7 @@ bool FieldOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -10475,9 +10524,9 @@ void FieldOptions::SerializeWithCachedSizes( return target; } -int FieldOptions::ByteSize() const { +size_t FieldOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldOptions) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 63u) { // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; @@ -10514,11 +10563,14 @@ int FieldOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -10528,18 +10580,17 @@ int FieldOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 FieldOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const FieldOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FieldOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const FieldOptions>( &from); if (source == NULL) { @@ -10547,15 +10598,21 @@ void FieldOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void FieldOptions::MergeFrom(const FieldOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void FieldOptions::UnsafeMergeFrom(const FieldOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_ctype()) { @@ -10579,7 +10636,8 @@ void FieldOptions::MergeFrom(const FieldOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -10594,14 +10652,17 @@ void FieldOptions::CopyFrom(const FieldOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FieldOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; return true; + if (!_extensions_.IsInitialized()) { + return false; + } + return true; } void FieldOptions::Swap(FieldOptions* other) { @@ -10647,11 +10708,11 @@ void FieldOptions::clear_ctype() { ctype_ = 0; clear_has_ctype(); } - ::google::protobuf::FieldOptions_CType FieldOptions::ctype() const { +::google::protobuf::FieldOptions_CType FieldOptions::ctype() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.ctype) return static_cast< ::google::protobuf::FieldOptions_CType >(ctype_); } - void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value) { +void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value) { assert(::google::protobuf::FieldOptions_CType_IsValid(value)); set_has_ctype(); ctype_ = value; @@ -10672,11 +10733,11 @@ void FieldOptions::clear_packed() { packed_ = false; clear_has_packed(); } - bool FieldOptions::packed() const { +bool FieldOptions::packed() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.packed) return packed_; } - void FieldOptions::set_packed(bool value) { +void FieldOptions::set_packed(bool value) { set_has_packed(); packed_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.packed) @@ -10696,11 +10757,11 @@ void FieldOptions::clear_jstype() { jstype_ = 0; clear_has_jstype(); } - ::google::protobuf::FieldOptions_JSType FieldOptions::jstype() const { +::google::protobuf::FieldOptions_JSType FieldOptions::jstype() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.jstype) return static_cast< ::google::protobuf::FieldOptions_JSType >(jstype_); } - void FieldOptions::set_jstype(::google::protobuf::FieldOptions_JSType value) { +void FieldOptions::set_jstype(::google::protobuf::FieldOptions_JSType value) { assert(::google::protobuf::FieldOptions_JSType_IsValid(value)); set_has_jstype(); jstype_ = value; @@ -10721,11 +10782,11 @@ void FieldOptions::clear_lazy() { lazy_ = false; clear_has_lazy(); } - bool FieldOptions::lazy() const { +bool FieldOptions::lazy() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.lazy) return lazy_; } - void FieldOptions::set_lazy(bool value) { +void FieldOptions::set_lazy(bool value) { set_has_lazy(); lazy_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.lazy) @@ -10745,11 +10806,11 @@ void FieldOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool FieldOptions::deprecated() const { +bool FieldOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.deprecated) return deprecated_; } - void FieldOptions::set_deprecated(bool value) { +void FieldOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.deprecated) @@ -10769,11 +10830,11 @@ void FieldOptions::clear_weak() { weak_ = false; clear_has_weak(); } - bool FieldOptions::weak() const { +bool FieldOptions::weak() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.weak) return weak_; } - void FieldOptions::set_weak(bool value) { +void FieldOptions::set_weak(bool value) { set_has_weak(); weak_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.weak) @@ -10819,6 +10880,7 @@ const int OneofOptions::kUninterpretedOptionFieldNumber; OneofOptions::OneofOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.OneofOptions) } @@ -10830,13 +10892,12 @@ OneofOptions::OneofOptions(const OneofOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.OneofOptions) } void OneofOptions::SharedCtor() { _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } OneofOptions::~OneofOptions() { @@ -10845,8 +10906,6 @@ OneofOptions::~OneofOptions() { } void OneofOptions::SharedDtor() { - if (this != default_instance_) { - } } void OneofOptions::SetCachedSize(int size) const { @@ -10860,11 +10919,11 @@ const ::google::protobuf::Descriptor* OneofOptions::descriptor() { } const OneofOptions& OneofOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -OneofOptions* OneofOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> OneofOptions::default_instance_; OneofOptions* OneofOptions::New(::google::protobuf::Arena* arena) const { OneofOptions* n = new OneofOptions; @@ -10878,7 +10937,7 @@ void OneofOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.OneofOptions) _extensions_.Clear(); uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -10918,7 +10977,7 @@ bool OneofOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -10980,16 +11039,19 @@ void OneofOptions::SerializeWithCachedSizes( return target; } -int OneofOptions::ByteSize() const { +size_t OneofOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofOptions) - int total_size = 0; + size_t total_size = 0; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -10999,18 +11061,17 @@ int OneofOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 OneofOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const OneofOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const OneofOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const OneofOptions>( &from); if (source == NULL) { @@ -11018,19 +11079,26 @@ void OneofOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.OneofOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void OneofOptions::MergeFrom(const OneofOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void OneofOptions::UnsafeMergeFrom(const OneofOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -11045,14 +11113,17 @@ void OneofOptions::CopyFrom(const OneofOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool OneofOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; return true; + if (!_extensions_.IsInitialized()) { + return false; + } + return true; } void OneofOptions::Swap(OneofOptions* other) { @@ -11120,6 +11191,7 @@ const int EnumOptions::kUninterpretedOptionFieldNumber; EnumOptions::EnumOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumOptions) } @@ -11131,15 +11203,14 @@ EnumOptions::EnumOptions(const EnumOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumOptions) } void EnumOptions::SharedCtor() { _cached_size_ = 0; - allow_alias_ = false; - deprecated_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&allow_alias_, 0, reinterpret_cast<char*>(&deprecated_) - + reinterpret_cast<char*>(&allow_alias_) + sizeof(deprecated_)); } EnumOptions::~EnumOptions() { @@ -11148,8 +11219,6 @@ EnumOptions::~EnumOptions() { } void EnumOptions::SharedDtor() { - if (this != default_instance_) { - } } void EnumOptions::SetCachedSize(int size) const { @@ -11163,11 +11232,11 @@ const ::google::protobuf::Descriptor* EnumOptions::descriptor() { } const EnumOptions& EnumOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -EnumOptions* EnumOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> EnumOptions::default_instance_; EnumOptions* EnumOptions::New(::google::protobuf::Arena* arena) const { EnumOptions* n = new EnumOptions; @@ -11202,7 +11271,7 @@ void EnumOptions::Clear() { #undef ZR_ uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -11221,10 +11290,10 @@ bool EnumOptions::MergePartialFromCodedStream( // optional bool allow_alias = 2; case 2: { if (tag == 16) { + set_has_allow_alias(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &allow_alias_))); - set_has_allow_alias(); } else { goto handle_unusual; } @@ -11236,10 +11305,10 @@ bool EnumOptions::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_deprecated: + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -11272,7 +11341,7 @@ bool EnumOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -11354,9 +11423,9 @@ void EnumOptions::SerializeWithCachedSizes( return target; } -int EnumOptions::ByteSize() const { +size_t EnumOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumOptions) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 3u) { // optional bool allow_alias = 2; @@ -11371,11 +11440,14 @@ int EnumOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -11385,18 +11457,17 @@ int EnumOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 EnumOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const EnumOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const EnumOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumOptions>( &from); if (source == NULL) { @@ -11404,15 +11475,21 @@ void EnumOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void EnumOptions::MergeFrom(const EnumOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void EnumOptions::UnsafeMergeFrom(const EnumOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_allow_alias()) { @@ -11424,7 +11501,8 @@ void EnumOptions::MergeFrom(const EnumOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -11439,14 +11517,17 @@ void EnumOptions::CopyFrom(const EnumOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool EnumOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; return true; + if (!_extensions_.IsInitialized()) { + return false; + } + return true; } void EnumOptions::Swap(EnumOptions* other) { @@ -11488,11 +11569,11 @@ void EnumOptions::clear_allow_alias() { allow_alias_ = false; clear_has_allow_alias(); } - bool EnumOptions::allow_alias() const { +bool EnumOptions::allow_alias() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.allow_alias) return allow_alias_; } - void EnumOptions::set_allow_alias(bool value) { +void EnumOptions::set_allow_alias(bool value) { set_has_allow_alias(); allow_alias_ = value; // @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.allow_alias) @@ -11512,11 +11593,11 @@ void EnumOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool EnumOptions::deprecated() const { +bool EnumOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.deprecated) return deprecated_; } - void EnumOptions::set_deprecated(bool value) { +void EnumOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.deprecated) @@ -11563,6 +11644,7 @@ const int EnumValueOptions::kUninterpretedOptionFieldNumber; EnumValueOptions::EnumValueOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValueOptions) } @@ -11574,14 +11656,13 @@ EnumValueOptions::EnumValueOptions(const EnumValueOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueOptions) } void EnumValueOptions::SharedCtor() { _cached_size_ = 0; deprecated_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } EnumValueOptions::~EnumValueOptions() { @@ -11590,8 +11671,6 @@ EnumValueOptions::~EnumValueOptions() { } void EnumValueOptions::SharedDtor() { - if (this != default_instance_) { - } } void EnumValueOptions::SetCachedSize(int size) const { @@ -11605,11 +11684,11 @@ const ::google::protobuf::Descriptor* EnumValueOptions::descriptor() { } const EnumValueOptions& EnumValueOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -EnumValueOptions* EnumValueOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> EnumValueOptions::default_instance_; EnumValueOptions* EnumValueOptions::New(::google::protobuf::Arena* arena) const { EnumValueOptions* n = new EnumValueOptions; @@ -11624,7 +11703,7 @@ void EnumValueOptions::Clear() { _extensions_.Clear(); deprecated_ = false; uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -11643,10 +11722,10 @@ bool EnumValueOptions::MergePartialFromCodedStream( // optional bool deprecated = 1 [default = false]; case 1: { if (tag == 8) { + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -11679,7 +11758,7 @@ bool EnumValueOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -11751,9 +11830,9 @@ void EnumValueOptions::SerializeWithCachedSizes( return target; } -int EnumValueOptions::ByteSize() const { +size_t EnumValueOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueOptions) - int total_size = 0; + size_t total_size = 0; // optional bool deprecated = 1 [default = false]; if (has_deprecated()) { @@ -11761,11 +11840,14 @@ int EnumValueOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -11775,18 +11857,17 @@ int EnumValueOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 EnumValueOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const EnumValueOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const EnumValueOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumValueOptions>( &from); if (source == NULL) { @@ -11794,15 +11875,21 @@ void EnumValueOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValueOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void EnumValueOptions::MergeFrom(const EnumValueOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void EnumValueOptions::UnsafeMergeFrom(const EnumValueOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_deprecated()) { @@ -11811,7 +11898,8 @@ void EnumValueOptions::MergeFrom(const EnumValueOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -11826,14 +11914,17 @@ void EnumValueOptions::CopyFrom(const EnumValueOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool EnumValueOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; return true; + if (!_extensions_.IsInitialized()) { + return false; + } + return true; } void EnumValueOptions::Swap(EnumValueOptions* other) { @@ -11874,11 +11965,11 @@ void EnumValueOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool EnumValueOptions::deprecated() const { +bool EnumValueOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.deprecated) return deprecated_; } - void EnumValueOptions::set_deprecated(bool value) { +void EnumValueOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.EnumValueOptions.deprecated) @@ -11925,6 +12016,7 @@ const int ServiceOptions::kUninterpretedOptionFieldNumber; ServiceOptions::ServiceOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ServiceOptions) } @@ -11936,14 +12028,13 @@ ServiceOptions::ServiceOptions(const ServiceOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceOptions) } void ServiceOptions::SharedCtor() { _cached_size_ = 0; deprecated_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } ServiceOptions::~ServiceOptions() { @@ -11952,8 +12043,6 @@ ServiceOptions::~ServiceOptions() { } void ServiceOptions::SharedDtor() { - if (this != default_instance_) { - } } void ServiceOptions::SetCachedSize(int size) const { @@ -11967,11 +12056,11 @@ const ::google::protobuf::Descriptor* ServiceOptions::descriptor() { } const ServiceOptions& ServiceOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -ServiceOptions* ServiceOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> ServiceOptions::default_instance_; ServiceOptions* ServiceOptions::New(::google::protobuf::Arena* arena) const { ServiceOptions* n = new ServiceOptions; @@ -11986,7 +12075,7 @@ void ServiceOptions::Clear() { _extensions_.Clear(); deprecated_ = false; uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -12005,10 +12094,10 @@ bool ServiceOptions::MergePartialFromCodedStream( // optional bool deprecated = 33 [default = false]; case 33: { if (tag == 264) { + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -12041,7 +12130,7 @@ bool ServiceOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -12113,9 +12202,9 @@ void ServiceOptions::SerializeWithCachedSizes( return target; } -int ServiceOptions::ByteSize() const { +size_t ServiceOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceOptions) - int total_size = 0; + size_t total_size = 0; // optional bool deprecated = 33 [default = false]; if (has_deprecated()) { @@ -12123,11 +12212,14 @@ int ServiceOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -12137,18 +12229,17 @@ int ServiceOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 ServiceOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const ServiceOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ServiceOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const ServiceOptions>( &from); if (source == NULL) { @@ -12156,15 +12247,21 @@ void ServiceOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ServiceOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void ServiceOptions::MergeFrom(const ServiceOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void ServiceOptions::UnsafeMergeFrom(const ServiceOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_deprecated()) { @@ -12173,7 +12270,8 @@ void ServiceOptions::MergeFrom(const ServiceOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -12188,14 +12286,17 @@ void ServiceOptions::CopyFrom(const ServiceOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ServiceOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; return true; + if (!_extensions_.IsInitialized()) { + return false; + } + return true; } void ServiceOptions::Swap(ServiceOptions* other) { @@ -12236,11 +12337,11 @@ void ServiceOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool ServiceOptions::deprecated() const { +bool ServiceOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.deprecated) return deprecated_; } - void ServiceOptions::set_deprecated(bool value) { +void ServiceOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.ServiceOptions.deprecated) @@ -12287,6 +12388,7 @@ const int MethodOptions::kUninterpretedOptionFieldNumber; MethodOptions::MethodOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MethodOptions) } @@ -12298,14 +12400,13 @@ MethodOptions::MethodOptions(const MethodOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodOptions) } void MethodOptions::SharedCtor() { _cached_size_ = 0; deprecated_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } MethodOptions::~MethodOptions() { @@ -12314,8 +12415,6 @@ MethodOptions::~MethodOptions() { } void MethodOptions::SharedDtor() { - if (this != default_instance_) { - } } void MethodOptions::SetCachedSize(int size) const { @@ -12329,11 +12428,11 @@ const ::google::protobuf::Descriptor* MethodOptions::descriptor() { } const MethodOptions& MethodOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -MethodOptions* MethodOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> MethodOptions::default_instance_; MethodOptions* MethodOptions::New(::google::protobuf::Arena* arena) const { MethodOptions* n = new MethodOptions; @@ -12348,7 +12447,7 @@ void MethodOptions::Clear() { _extensions_.Clear(); deprecated_ = false; uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -12367,10 +12466,10 @@ bool MethodOptions::MergePartialFromCodedStream( // optional bool deprecated = 33 [default = false]; case 33: { if (tag == 264) { + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -12403,7 +12502,7 @@ bool MethodOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -12475,9 +12574,9 @@ void MethodOptions::SerializeWithCachedSizes( return target; } -int MethodOptions::ByteSize() const { +size_t MethodOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodOptions) - int total_size = 0; + size_t total_size = 0; // optional bool deprecated = 33 [default = false]; if (has_deprecated()) { @@ -12485,11 +12584,14 @@ int MethodOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -12499,18 +12601,17 @@ int MethodOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 MethodOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const MethodOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const MethodOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const MethodOptions>( &from); if (source == NULL) { @@ -12518,15 +12619,21 @@ void MethodOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MethodOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void MethodOptions::MergeFrom(const MethodOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void MethodOptions::UnsafeMergeFrom(const MethodOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_deprecated()) { @@ -12535,7 +12642,8 @@ void MethodOptions::MergeFrom(const MethodOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -12550,14 +12658,17 @@ void MethodOptions::CopyFrom(const MethodOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool MethodOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; return true; + if (!_extensions_.IsInitialized()) { + return false; + } + return true; } void MethodOptions::Swap(MethodOptions* other) { @@ -12598,11 +12709,11 @@ void MethodOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool MethodOptions::deprecated() const { +bool MethodOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.deprecated) return deprecated_; } - void MethodOptions::set_deprecated(bool value) { +void MethodOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.deprecated) @@ -12649,6 +12760,7 @@ const int UninterpretedOption_NamePart::kIsExtensionFieldNumber; UninterpretedOption_NamePart::UninterpretedOption_NamePart() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption.NamePart) } @@ -12660,16 +12772,14 @@ UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOp : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart) } void UninterpretedOption_NamePart::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_part_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); is_extension_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } UninterpretedOption_NamePart::~UninterpretedOption_NamePart() { @@ -12679,8 +12789,6 @@ UninterpretedOption_NamePart::~UninterpretedOption_NamePart() { void UninterpretedOption_NamePart::SharedDtor() { name_part_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void UninterpretedOption_NamePart::SetCachedSize(int size) const { @@ -12694,11 +12802,11 @@ const ::google::protobuf::Descriptor* UninterpretedOption_NamePart::descriptor() } const UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -UninterpretedOption_NamePart* UninterpretedOption_NamePart::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> UninterpretedOption_NamePart::default_instance_; UninterpretedOption_NamePart* UninterpretedOption_NamePart::New(::google::protobuf::Arena* arena) const { UninterpretedOption_NamePart* n = new UninterpretedOption_NamePart; @@ -12716,7 +12824,7 @@ void UninterpretedOption_NamePart::Clear() { } is_extension_ = false; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -12752,10 +12860,10 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_is_extension: + set_has_is_extension(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &is_extension_))); - set_has_is_extension(); } else { goto handle_unusual; } @@ -12838,9 +12946,9 @@ void UninterpretedOption_NamePart::SerializeWithCachedSizes( return target; } -int UninterpretedOption_NamePart::RequiredFieldsByteSizeFallback() const { +size_t UninterpretedOption_NamePart::RequiredFieldsByteSizeFallback() const { // @@protoc_insertion_point(required_fields_byte_size_fallback_start:google.protobuf.UninterpretedOption.NamePart) - int total_size = 0; + size_t total_size = 0; if (has_name_part()) { // required string name_part = 1; @@ -12856,9 +12964,9 @@ int UninterpretedOption_NamePart::RequiredFieldsByteSizeFallback() const { return total_size; } -int UninterpretedOption_NamePart::ByteSize() const { +size_t UninterpretedOption_NamePart::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption.NamePart) - int total_size = 0; + size_t total_size = 0; if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. // required string name_part = 1; @@ -12877,18 +12985,17 @@ int UninterpretedOption_NamePart::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 UninterpretedOption_NamePart::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UninterpretedOption.NamePart) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const UninterpretedOption_NamePart* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const UninterpretedOption_NamePart* source = ::google::protobuf::internal::DynamicCastToGenerated<const UninterpretedOption_NamePart>( &from); if (source == NULL) { @@ -12896,15 +13003,21 @@ void UninterpretedOption_NamePart::MergeFrom(const ::google::protobuf::Message& ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UninterpretedOption.NamePart) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void UninterpretedOption_NamePart::UnsafeMergeFrom(const UninterpretedOption_NamePart& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name_part()) { set_has_name_part(); @@ -12915,7 +13028,8 @@ void UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -12930,7 +13044,7 @@ void UninterpretedOption_NamePart::CopyFrom(const UninterpretedOption_NamePart& // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption.NamePart) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool UninterpretedOption_NamePart::IsInitialized() const { @@ -12974,6 +13088,7 @@ const int UninterpretedOption::kAggregateValueFieldNumber; UninterpretedOption::UninterpretedOption() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption) } @@ -12985,20 +13100,17 @@ UninterpretedOption::UninterpretedOption(const UninterpretedOption& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption) } void UninterpretedOption::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; identifier_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - positive_int_value_ = GOOGLE_ULONGLONG(0); - negative_int_value_ = GOOGLE_LONGLONG(0); - double_value_ = 0; string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); aggregate_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&positive_int_value_, 0, reinterpret_cast<char*>(&double_value_) - + reinterpret_cast<char*>(&positive_int_value_) + sizeof(double_value_)); } UninterpretedOption::~UninterpretedOption() { @@ -13010,8 +13122,6 @@ void UninterpretedOption::SharedDtor() { identifier_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); aggregate_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void UninterpretedOption::SetCachedSize(int size) const { @@ -13025,11 +13135,11 @@ const ::google::protobuf::Descriptor* UninterpretedOption::descriptor() { } const UninterpretedOption& UninterpretedOption::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -UninterpretedOption* UninterpretedOption::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> UninterpretedOption::default_instance_; UninterpretedOption* UninterpretedOption::New(::google::protobuf::Arena* arena) const { UninterpretedOption* n = new UninterpretedOption; @@ -13074,7 +13184,7 @@ void UninterpretedOption::Clear() { #undef ZR_ name_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -13127,10 +13237,10 @@ bool UninterpretedOption::MergePartialFromCodedStream( case 4: { if (tag == 32) { parse_positive_int_value: + set_has_positive_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( input, &positive_int_value_))); - set_has_positive_int_value(); } else { goto handle_unusual; } @@ -13142,10 +13252,10 @@ bool UninterpretedOption::MergePartialFromCodedStream( case 5: { if (tag == 40) { parse_negative_int_value: + set_has_negative_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( input, &negative_int_value_))); - set_has_negative_int_value(); } else { goto handle_unusual; } @@ -13157,10 +13267,10 @@ bool UninterpretedOption::MergePartialFromCodedStream( case 6: { if (tag == 49) { parse_double_value: + set_has_double_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( input, &double_value_))); - set_has_double_value(); } else { goto handle_unusual; } @@ -13340,9 +13450,9 @@ void UninterpretedOption::SerializeWithCachedSizes( return target; } -int UninterpretedOption::ByteSize() const { +size_t UninterpretedOption::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[1 / 32] & 126u) { // optional string identifier_value = 3; @@ -13387,11 +13497,14 @@ int UninterpretedOption::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - total_size += 1 * this->name_size(); - for (int i = 0; i < this->name_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->name(i)); + { + unsigned int count = this->name_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->name(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -13399,18 +13512,17 @@ int UninterpretedOption::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 UninterpretedOption::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UninterpretedOption) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const UninterpretedOption* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const UninterpretedOption* source = ::google::protobuf::internal::DynamicCastToGenerated<const UninterpretedOption>( &from); if (source == NULL) { @@ -13418,15 +13530,21 @@ void UninterpretedOption::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UninterpretedOption) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void UninterpretedOption::MergeFrom(const UninterpretedOption& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void UninterpretedOption::UnsafeMergeFrom(const UninterpretedOption& from) { + GOOGLE_DCHECK(&from != this); name_.MergeFrom(from.name_); if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) { if (from.has_identifier_value()) { @@ -13452,7 +13570,8 @@ void UninterpretedOption::MergeFrom(const UninterpretedOption& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -13467,7 +13586,7 @@ void UninterpretedOption::CopyFrom(const UninterpretedOption& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool UninterpretedOption::IsInitialized() const { @@ -13518,37 +13637,37 @@ void UninterpretedOption_NamePart::clear_name_part() { name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name_part(); } - const ::std::string& UninterpretedOption_NamePart::name_part() const { +const ::std::string& UninterpretedOption_NamePart::name_part() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part) return name_part_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) { +void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) { set_has_name_part(); name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part) } - void UninterpretedOption_NamePart::set_name_part(const char* value) { +void UninterpretedOption_NamePart::set_name_part(const char* value) { set_has_name_part(); name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.NamePart.name_part) } - void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) { +void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) { set_has_name_part(); name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part) } - ::std::string* UninterpretedOption_NamePart::mutable_name_part() { +::std::string* UninterpretedOption_NamePart::mutable_name_part() { set_has_name_part(); // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.NamePart.name_part) return name_part_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* UninterpretedOption_NamePart::release_name_part() { +::std::string* UninterpretedOption_NamePart::release_name_part() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part) clear_has_name_part(); return name_part_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) { +void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) { if (name_part != NULL) { set_has_name_part(); } else { @@ -13572,11 +13691,11 @@ void UninterpretedOption_NamePart::clear_is_extension() { is_extension_ = false; clear_has_is_extension(); } - bool UninterpretedOption_NamePart::is_extension() const { +bool UninterpretedOption_NamePart::is_extension() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.is_extension) return is_extension_; } - void UninterpretedOption_NamePart::set_is_extension(bool value) { +void UninterpretedOption_NamePart::set_is_extension(bool value) { set_has_is_extension(); is_extension_ = value; // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension) @@ -13630,37 +13749,37 @@ void UninterpretedOption::clear_identifier_value() { identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_identifier_value(); } - const ::std::string& UninterpretedOption::identifier_value() const { +const ::std::string& UninterpretedOption::identifier_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value) return identifier_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption::set_identifier_value(const ::std::string& value) { +void UninterpretedOption::set_identifier_value(const ::std::string& value) { set_has_identifier_value(); identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value) } - void UninterpretedOption::set_identifier_value(const char* value) { +void UninterpretedOption::set_identifier_value(const char* value) { set_has_identifier_value(); identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.identifier_value) } - void UninterpretedOption::set_identifier_value(const char* value, size_t size) { +void UninterpretedOption::set_identifier_value(const char* value, size_t size) { set_has_identifier_value(); identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.identifier_value) } - ::std::string* UninterpretedOption::mutable_identifier_value() { +::std::string* UninterpretedOption::mutable_identifier_value() { set_has_identifier_value(); // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.identifier_value) return identifier_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* UninterpretedOption::release_identifier_value() { +::std::string* UninterpretedOption::release_identifier_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.identifier_value) clear_has_identifier_value(); return identifier_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption::set_allocated_identifier_value(::std::string* identifier_value) { +void UninterpretedOption::set_allocated_identifier_value(::std::string* identifier_value) { if (identifier_value != NULL) { set_has_identifier_value(); } else { @@ -13684,11 +13803,11 @@ void UninterpretedOption::clear_positive_int_value() { positive_int_value_ = GOOGLE_ULONGLONG(0); clear_has_positive_int_value(); } - ::google::protobuf::uint64 UninterpretedOption::positive_int_value() const { +::google::protobuf::uint64 UninterpretedOption::positive_int_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.positive_int_value) return positive_int_value_; } - void UninterpretedOption::set_positive_int_value(::google::protobuf::uint64 value) { +void UninterpretedOption::set_positive_int_value(::google::protobuf::uint64 value) { set_has_positive_int_value(); positive_int_value_ = value; // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.positive_int_value) @@ -13708,11 +13827,11 @@ void UninterpretedOption::clear_negative_int_value() { negative_int_value_ = GOOGLE_LONGLONG(0); clear_has_negative_int_value(); } - ::google::protobuf::int64 UninterpretedOption::negative_int_value() const { +::google::protobuf::int64 UninterpretedOption::negative_int_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.negative_int_value) return negative_int_value_; } - void UninterpretedOption::set_negative_int_value(::google::protobuf::int64 value) { +void UninterpretedOption::set_negative_int_value(::google::protobuf::int64 value) { set_has_negative_int_value(); negative_int_value_ = value; // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.negative_int_value) @@ -13732,11 +13851,11 @@ void UninterpretedOption::clear_double_value() { double_value_ = 0; clear_has_double_value(); } - double UninterpretedOption::double_value() const { +double UninterpretedOption::double_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.double_value) return double_value_; } - void UninterpretedOption::set_double_value(double value) { +void UninterpretedOption::set_double_value(double value) { set_has_double_value(); double_value_ = value; // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.double_value) @@ -13756,37 +13875,37 @@ void UninterpretedOption::clear_string_value() { string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_string_value(); } - const ::std::string& UninterpretedOption::string_value() const { +const ::std::string& UninterpretedOption::string_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value) return string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption::set_string_value(const ::std::string& value) { +void UninterpretedOption::set_string_value(const ::std::string& value) { set_has_string_value(); string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value) } - void UninterpretedOption::set_string_value(const char* value) { +void UninterpretedOption::set_string_value(const char* value) { set_has_string_value(); string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.string_value) } - void UninterpretedOption::set_string_value(const void* value, size_t size) { +void UninterpretedOption::set_string_value(const void* value, size_t size) { set_has_string_value(); string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.string_value) } - ::std::string* UninterpretedOption::mutable_string_value() { +::std::string* UninterpretedOption::mutable_string_value() { set_has_string_value(); // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.string_value) return string_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* UninterpretedOption::release_string_value() { +::std::string* UninterpretedOption::release_string_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.string_value) clear_has_string_value(); return string_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption::set_allocated_string_value(::std::string* string_value) { +void UninterpretedOption::set_allocated_string_value(::std::string* string_value) { if (string_value != NULL) { set_has_string_value(); } else { @@ -13810,37 +13929,37 @@ void UninterpretedOption::clear_aggregate_value() { aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_aggregate_value(); } - const ::std::string& UninterpretedOption::aggregate_value() const { +const ::std::string& UninterpretedOption::aggregate_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value) return aggregate_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption::set_aggregate_value(const ::std::string& value) { +void UninterpretedOption::set_aggregate_value(const ::std::string& value) { set_has_aggregate_value(); aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value) } - void UninterpretedOption::set_aggregate_value(const char* value) { +void UninterpretedOption::set_aggregate_value(const char* value) { set_has_aggregate_value(); aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.aggregate_value) } - void UninterpretedOption::set_aggregate_value(const char* value, size_t size) { +void UninterpretedOption::set_aggregate_value(const char* value, size_t size) { set_has_aggregate_value(); aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.aggregate_value) } - ::std::string* UninterpretedOption::mutable_aggregate_value() { +::std::string* UninterpretedOption::mutable_aggregate_value() { set_has_aggregate_value(); // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.aggregate_value) return aggregate_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* UninterpretedOption::release_aggregate_value() { +::std::string* UninterpretedOption::release_aggregate_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.aggregate_value) clear_has_aggregate_value(); return aggregate_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption::set_allocated_aggregate_value(::std::string* aggregate_value) { +void UninterpretedOption::set_allocated_aggregate_value(::std::string* aggregate_value) { if (aggregate_value != NULL) { set_has_aggregate_value(); } else { @@ -13864,6 +13983,7 @@ const int SourceCodeInfo_Location::kLeadingDetachedCommentsFieldNumber; SourceCodeInfo_Location::SourceCodeInfo_Location() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo.Location) } @@ -13875,16 +13995,14 @@ SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location) } void SourceCodeInfo_Location::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; leading_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); trailing_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } SourceCodeInfo_Location::~SourceCodeInfo_Location() { @@ -13895,8 +14013,6 @@ SourceCodeInfo_Location::~SourceCodeInfo_Location() { void SourceCodeInfo_Location::SharedDtor() { leading_comments_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); trailing_comments_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void SourceCodeInfo_Location::SetCachedSize(int size) const { @@ -13910,11 +14026,11 @@ const ::google::protobuf::Descriptor* SourceCodeInfo_Location::descriptor() { } const SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -SourceCodeInfo_Location* SourceCodeInfo_Location::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> SourceCodeInfo_Location::default_instance_; SourceCodeInfo_Location* SourceCodeInfo_Location::New(::google::protobuf::Arena* arena) const { SourceCodeInfo_Location* n = new SourceCodeInfo_Location; @@ -13937,7 +14053,7 @@ void SourceCodeInfo_Location::Clear() { path_.Clear(); span_.Clear(); leading_detached_comments_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -14195,9 +14311,9 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( return target; } -int SourceCodeInfo_Location::ByteSize() const { +size_t SourceCodeInfo_Location::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo.Location) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[2 / 32] & 12u) { // optional string leading_comments = 3; @@ -14217,8 +14333,9 @@ int SourceCodeInfo_Location::ByteSize() const { } // repeated int32 path = 1 [packed = true]; { - int data_size = 0; - for (int i = 0; i < this->path_size(); i++) { + size_t data_size = 0; + unsigned int count = this->path_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int32Size(this->path(i)); } @@ -14226,16 +14343,18 @@ int SourceCodeInfo_Location::ByteSize() const { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); } + int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _path_cached_byte_size_ = data_size; + _path_cached_byte_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); total_size += data_size; } // repeated int32 span = 2 [packed = true]; { - int data_size = 0; - for (int i = 0; i < this->span_size(); i++) { + size_t data_size = 0; + unsigned int count = this->span_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int32Size(this->span(i)); } @@ -14243,14 +14362,16 @@ int SourceCodeInfo_Location::ByteSize() const { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); } + int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _span_cached_byte_size_ = data_size; + _span_cached_byte_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); total_size += data_size; } // repeated string leading_detached_comments = 6; - total_size += 1 * this->leading_detached_comments_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->leading_detached_comments_size()); for (int i = 0; i < this->leading_detached_comments_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->leading_detached_comments(i)); @@ -14261,18 +14382,17 @@ int SourceCodeInfo_Location::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 SourceCodeInfo_Location::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo.Location) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const SourceCodeInfo_Location* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const SourceCodeInfo_Location* source = ::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo_Location>( &from); if (source == NULL) { @@ -14280,18 +14400,24 @@ void SourceCodeInfo_Location::MergeFrom(const ::google::protobuf::Message& from) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo.Location) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } - path_.MergeFrom(from.path_); - span_.MergeFrom(from.span_); - leading_detached_comments_.MergeFrom(from.leading_detached_comments_); +} + +void SourceCodeInfo_Location::UnsafeMergeFrom(const SourceCodeInfo_Location& from) { + GOOGLE_DCHECK(&from != this); + path_.UnsafeMergeFrom(from.path_); + span_.UnsafeMergeFrom(from.span_); + leading_detached_comments_.UnsafeMergeFrom(from.leading_detached_comments_); if (from._has_bits_[2 / 32] & (0xffu << (2 % 32))) { if (from.has_leading_comments()) { set_has_leading_comments(); @@ -14303,7 +14429,8 @@ void SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -14318,7 +14445,7 @@ void SourceCodeInfo_Location::CopyFrom(const SourceCodeInfo_Location& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo.Location) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool SourceCodeInfo_Location::IsInitialized() const { @@ -14358,6 +14485,7 @@ const int SourceCodeInfo::kLocationFieldNumber; SourceCodeInfo::SourceCodeInfo() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo) } @@ -14369,13 +14497,12 @@ SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo) } void SourceCodeInfo::SharedCtor() { _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } SourceCodeInfo::~SourceCodeInfo() { @@ -14384,8 +14511,6 @@ SourceCodeInfo::~SourceCodeInfo() { } void SourceCodeInfo::SharedDtor() { - if (this != default_instance_) { - } } void SourceCodeInfo::SetCachedSize(int size) const { @@ -14399,11 +14524,11 @@ const ::google::protobuf::Descriptor* SourceCodeInfo::descriptor() { } const SourceCodeInfo& SourceCodeInfo::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -SourceCodeInfo* SourceCodeInfo::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> SourceCodeInfo::default_instance_; SourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const { SourceCodeInfo* n = new SourceCodeInfo; @@ -14416,7 +14541,7 @@ SourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const { void SourceCodeInfo::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo) location_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -14505,16 +14630,19 @@ void SourceCodeInfo::SerializeWithCachedSizes( return target; } -int SourceCodeInfo::ByteSize() const { +size_t SourceCodeInfo::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo) - int total_size = 0; + size_t total_size = 0; // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - total_size += 1 * this->location_size(); - for (int i = 0; i < this->location_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->location(i)); + { + unsigned int count = this->location_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->location(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -14522,18 +14650,17 @@ int SourceCodeInfo::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 SourceCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const SourceCodeInfo* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const SourceCodeInfo* source = ::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo>( &from); if (source == NULL) { @@ -14541,18 +14668,25 @@ void SourceCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void SourceCodeInfo::MergeFrom(const SourceCodeInfo& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void SourceCodeInfo::UnsafeMergeFrom(const SourceCodeInfo& from) { + GOOGLE_DCHECK(&from != this); location_.MergeFrom(from.location_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -14567,7 +14701,7 @@ void SourceCodeInfo::CopyFrom(const SourceCodeInfo& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool SourceCodeInfo::IsInitialized() const { @@ -14604,24 +14738,24 @@ int SourceCodeInfo_Location::path_size() const { void SourceCodeInfo_Location::clear_path() { path_.Clear(); } - ::google::protobuf::int32 SourceCodeInfo_Location::path(int index) const { +::google::protobuf::int32 SourceCodeInfo_Location::path(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.path) return path_.Get(index); } - void SourceCodeInfo_Location::set_path(int index, ::google::protobuf::int32 value) { +void SourceCodeInfo_Location::set_path(int index, ::google::protobuf::int32 value) { path_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.path) } - void SourceCodeInfo_Location::add_path(::google::protobuf::int32 value) { +void SourceCodeInfo_Location::add_path(::google::protobuf::int32 value) { path_.Add(value); // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.path) } - const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& SourceCodeInfo_Location::path() const { // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.path) return path_; } - ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* SourceCodeInfo_Location::mutable_path() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.path) return &path_; @@ -14634,24 +14768,24 @@ int SourceCodeInfo_Location::span_size() const { void SourceCodeInfo_Location::clear_span() { span_.Clear(); } - ::google::protobuf::int32 SourceCodeInfo_Location::span(int index) const { +::google::protobuf::int32 SourceCodeInfo_Location::span(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.span) return span_.Get(index); } - void SourceCodeInfo_Location::set_span(int index, ::google::protobuf::int32 value) { +void SourceCodeInfo_Location::set_span(int index, ::google::protobuf::int32 value) { span_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.span) } - void SourceCodeInfo_Location::add_span(::google::protobuf::int32 value) { +void SourceCodeInfo_Location::add_span(::google::protobuf::int32 value) { span_.Add(value); // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.span) } - const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& SourceCodeInfo_Location::span() const { // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.span) return span_; } - ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* SourceCodeInfo_Location::mutable_span() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.span) return &span_; @@ -14671,37 +14805,37 @@ void SourceCodeInfo_Location::clear_leading_comments() { leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_leading_comments(); } - const ::std::string& SourceCodeInfo_Location::leading_comments() const { +const ::std::string& SourceCodeInfo_Location::leading_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments) return leading_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) { +void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) { set_has_leading_comments(); leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments) } - void SourceCodeInfo_Location::set_leading_comments(const char* value) { +void SourceCodeInfo_Location::set_leading_comments(const char* value) { set_has_leading_comments(); leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_comments) } - void SourceCodeInfo_Location::set_leading_comments(const char* value, size_t size) { +void SourceCodeInfo_Location::set_leading_comments(const char* value, size_t size) { set_has_leading_comments(); leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_comments) } - ::std::string* SourceCodeInfo_Location::mutable_leading_comments() { +::std::string* SourceCodeInfo_Location::mutable_leading_comments() { set_has_leading_comments(); // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.leading_comments) return leading_comments_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* SourceCodeInfo_Location::release_leading_comments() { +::std::string* SourceCodeInfo_Location::release_leading_comments() { // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.leading_comments) clear_has_leading_comments(); return leading_comments_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void SourceCodeInfo_Location::set_allocated_leading_comments(::std::string* leading_comments) { +void SourceCodeInfo_Location::set_allocated_leading_comments(::std::string* leading_comments) { if (leading_comments != NULL) { set_has_leading_comments(); } else { @@ -14725,37 +14859,37 @@ void SourceCodeInfo_Location::clear_trailing_comments() { trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_trailing_comments(); } - const ::std::string& SourceCodeInfo_Location::trailing_comments() const { +const ::std::string& SourceCodeInfo_Location::trailing_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments) return trailing_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) { +void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) { set_has_trailing_comments(); trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments) } - void SourceCodeInfo_Location::set_trailing_comments(const char* value) { +void SourceCodeInfo_Location::set_trailing_comments(const char* value) { set_has_trailing_comments(); trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.trailing_comments) } - void SourceCodeInfo_Location::set_trailing_comments(const char* value, size_t size) { +void SourceCodeInfo_Location::set_trailing_comments(const char* value, size_t size) { set_has_trailing_comments(); trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.trailing_comments) } - ::std::string* SourceCodeInfo_Location::mutable_trailing_comments() { +::std::string* SourceCodeInfo_Location::mutable_trailing_comments() { set_has_trailing_comments(); // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.trailing_comments) return trailing_comments_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* SourceCodeInfo_Location::release_trailing_comments() { +::std::string* SourceCodeInfo_Location::release_trailing_comments() { // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.trailing_comments) clear_has_trailing_comments(); return trailing_comments_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void SourceCodeInfo_Location::set_allocated_trailing_comments(::std::string* trailing_comments) { +void SourceCodeInfo_Location::set_allocated_trailing_comments(::std::string* trailing_comments) { if (trailing_comments != NULL) { set_has_trailing_comments(); } else { @@ -14772,49 +14906,49 @@ int SourceCodeInfo_Location::leading_detached_comments_size() const { void SourceCodeInfo_Location::clear_leading_detached_comments() { leading_detached_comments_.Clear(); } - const ::std::string& SourceCodeInfo_Location::leading_detached_comments(int index) const { +const ::std::string& SourceCodeInfo_Location::leading_detached_comments(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) return leading_detached_comments_.Get(index); } - ::std::string* SourceCodeInfo_Location::mutable_leading_detached_comments(int index) { +::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); } - void SourceCodeInfo_Location::set_leading_detached_comments(int index, const ::std::string& value) { +void SourceCodeInfo_Location::set_leading_detached_comments(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) leading_detached_comments_.Mutable(index)->assign(value); } - void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) { +void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) { leading_detached_comments_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } - void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value, size_t size) { +void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value, size_t size) { 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) } - ::std::string* SourceCodeInfo_Location::add_leading_detached_comments() { +::std::string* SourceCodeInfo_Location::add_leading_detached_comments() { // @@protoc_insertion_point(field_add_mutable:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) return leading_detached_comments_.Add(); } - void SourceCodeInfo_Location::add_leading_detached_comments(const ::std::string& value) { +void SourceCodeInfo_Location::add_leading_detached_comments(const ::std::string& value) { leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } - void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) { +void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) { leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } - void SourceCodeInfo_Location::add_leading_detached_comments(const char* value, size_t size) { +void SourceCodeInfo_Location::add_leading_detached_comments(const char* value, size_t size) { leading_detached_comments_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } - const ::google::protobuf::RepeatedPtrField< ::std::string>& +const ::google::protobuf::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_; } - ::google::protobuf::RepeatedPtrField< ::std::string>* +::google::protobuf::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_; @@ -14867,6 +15001,7 @@ const int GeneratedCodeInfo_Annotation::kEndFieldNumber; GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo.Annotation) } @@ -14878,17 +15013,15 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeIn : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo.Annotation) } void GeneratedCodeInfo_Annotation::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; source_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - begin_ = 0; - end_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&begin_, 0, reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&begin_) + sizeof(end_)); } GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() { @@ -14898,8 +15031,6 @@ GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() { void GeneratedCodeInfo_Annotation::SharedDtor() { source_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const { @@ -14913,11 +15044,11 @@ const ::google::protobuf::Descriptor* GeneratedCodeInfo_Annotation::descriptor() } const GeneratedCodeInfo_Annotation& GeneratedCodeInfo_Annotation::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> GeneratedCodeInfo_Annotation::default_instance_; GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::New(::google::protobuf::Arena* arena) const { GeneratedCodeInfo_Annotation* n = new GeneratedCodeInfo_Annotation; @@ -14956,7 +15087,7 @@ void GeneratedCodeInfo_Annotation::Clear() { #undef ZR_ path_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -15010,10 +15141,10 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_begin: + set_has_begin(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &begin_))); - set_has_begin(); } else { goto handle_unusual; } @@ -15025,10 +15156,10 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( case 4: { if (tag == 32) { parse_end: + set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &end_))); - set_has_end(); } else { goto handle_unusual; } @@ -15145,9 +15276,9 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes( return target; } -int GeneratedCodeInfo_Annotation::ByteSize() const { +size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo.Annotation) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[1 / 32] & 14u) { // optional string source_file = 2; @@ -15174,8 +15305,9 @@ int GeneratedCodeInfo_Annotation::ByteSize() const { } // repeated int32 path = 1 [packed = true]; { - int data_size = 0; - for (int i = 0; i < this->path_size(); i++) { + size_t data_size = 0; + unsigned int count = this->path_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int32Size(this->path(i)); } @@ -15183,8 +15315,9 @@ int GeneratedCodeInfo_Annotation::ByteSize() const { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); } + int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _path_cached_byte_size_ = data_size; + _path_cached_byte_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); total_size += data_size; } @@ -15194,18 +15327,17 @@ int GeneratedCodeInfo_Annotation::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 GeneratedCodeInfo_Annotation::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const GeneratedCodeInfo_Annotation* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const GeneratedCodeInfo_Annotation* source = ::google::protobuf::internal::DynamicCastToGenerated<const GeneratedCodeInfo_Annotation>( &from); if (source == NULL) { @@ -15213,16 +15345,22 @@ void GeneratedCodeInfo_Annotation::MergeFrom(const ::google::protobuf::Message& ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.GeneratedCodeInfo.Annotation) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void GeneratedCodeInfo_Annotation::MergeFrom(const GeneratedCodeInfo_Annotation& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } - path_.MergeFrom(from.path_); +} + +void GeneratedCodeInfo_Annotation::UnsafeMergeFrom(const GeneratedCodeInfo_Annotation& from) { + GOOGLE_DCHECK(&from != this); + path_.UnsafeMergeFrom(from.path_); if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) { if (from.has_source_file()) { set_has_source_file(); @@ -15236,7 +15374,8 @@ void GeneratedCodeInfo_Annotation::MergeFrom(const GeneratedCodeInfo_Annotation& } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -15251,7 +15390,7 @@ void GeneratedCodeInfo_Annotation::CopyFrom(const GeneratedCodeInfo_Annotation& // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo.Annotation) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool GeneratedCodeInfo_Annotation::IsInitialized() const { @@ -15290,6 +15429,7 @@ const int GeneratedCodeInfo::kAnnotationFieldNumber; GeneratedCodeInfo::GeneratedCodeInfo() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo) } @@ -15301,13 +15441,12 @@ GeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo) } void GeneratedCodeInfo::SharedCtor() { _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } GeneratedCodeInfo::~GeneratedCodeInfo() { @@ -15316,8 +15455,6 @@ GeneratedCodeInfo::~GeneratedCodeInfo() { } void GeneratedCodeInfo::SharedDtor() { - if (this != default_instance_) { - } } void GeneratedCodeInfo::SetCachedSize(int size) const { @@ -15331,11 +15468,11 @@ const ::google::protobuf::Descriptor* GeneratedCodeInfo::descriptor() { } const GeneratedCodeInfo& GeneratedCodeInfo::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -GeneratedCodeInfo* GeneratedCodeInfo::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> GeneratedCodeInfo::default_instance_; GeneratedCodeInfo* GeneratedCodeInfo::New(::google::protobuf::Arena* arena) const { GeneratedCodeInfo* n = new GeneratedCodeInfo; @@ -15348,7 +15485,7 @@ GeneratedCodeInfo* GeneratedCodeInfo::New(::google::protobuf::Arena* arena) cons void GeneratedCodeInfo::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo) annotation_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -15437,16 +15574,19 @@ void GeneratedCodeInfo::SerializeWithCachedSizes( return target; } -int GeneratedCodeInfo::ByteSize() const { +size_t GeneratedCodeInfo::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo) - int total_size = 0; + size_t total_size = 0; // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; - total_size += 1 * this->annotation_size(); - for (int i = 0; i < this->annotation_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->annotation(i)); + { + unsigned int count = this->annotation_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->annotation(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -15454,18 +15594,17 @@ int GeneratedCodeInfo::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + 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 GeneratedCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.GeneratedCodeInfo) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const GeneratedCodeInfo* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const GeneratedCodeInfo* source = ::google::protobuf::internal::DynamicCastToGenerated<const GeneratedCodeInfo>( &from); if (source == NULL) { @@ -15473,18 +15612,25 @@ void GeneratedCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.GeneratedCodeInfo) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void GeneratedCodeInfo::MergeFrom(const GeneratedCodeInfo& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void GeneratedCodeInfo::UnsafeMergeFrom(const GeneratedCodeInfo& from) { + GOOGLE_DCHECK(&from != this); annotation_.MergeFrom(from.annotation_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -15499,7 +15645,7 @@ void GeneratedCodeInfo::CopyFrom(const GeneratedCodeInfo& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool GeneratedCodeInfo::IsInitialized() const { @@ -15536,24 +15682,24 @@ int GeneratedCodeInfo_Annotation::path_size() const { void GeneratedCodeInfo_Annotation::clear_path() { path_.Clear(); } - ::google::protobuf::int32 GeneratedCodeInfo_Annotation::path(int index) const { +::google::protobuf::int32 GeneratedCodeInfo_Annotation::path(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.path) return path_.Get(index); } - void GeneratedCodeInfo_Annotation::set_path(int index, ::google::protobuf::int32 value) { +void GeneratedCodeInfo_Annotation::set_path(int index, ::google::protobuf::int32 value) { path_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path) } - void GeneratedCodeInfo_Annotation::add_path(::google::protobuf::int32 value) { +void GeneratedCodeInfo_Annotation::add_path(::google::protobuf::int32 value) { path_.Add(value); // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.Annotation.path) } - const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& GeneratedCodeInfo_Annotation::path() const { // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.Annotation.path) return path_; } - ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* GeneratedCodeInfo_Annotation::mutable_path() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.Annotation.path) return &path_; @@ -15573,37 +15719,37 @@ void GeneratedCodeInfo_Annotation::clear_source_file() { source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_source_file(); } - const ::std::string& GeneratedCodeInfo_Annotation::source_file() const { +const ::std::string& GeneratedCodeInfo_Annotation::source_file() const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file) return source_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) { +void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) { set_has_source_file(); source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } - void GeneratedCodeInfo_Annotation::set_source_file(const char* value) { +void GeneratedCodeInfo_Annotation::set_source_file(const char* value) { set_has_source_file(); source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } - void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) { +void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) { set_has_source_file(); source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } - ::std::string* GeneratedCodeInfo_Annotation::mutable_source_file() { +::std::string* GeneratedCodeInfo_Annotation::mutable_source_file() { set_has_source_file(); // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.Annotation.source_file) return source_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* GeneratedCodeInfo_Annotation::release_source_file() { +::std::string* GeneratedCodeInfo_Annotation::release_source_file() { // @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file) clear_has_source_file(); return source_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::string* source_file) { +void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::string* source_file) { if (source_file != NULL) { set_has_source_file(); } else { @@ -15627,11 +15773,11 @@ void GeneratedCodeInfo_Annotation::clear_begin() { begin_ = 0; clear_has_begin(); } - ::google::protobuf::int32 GeneratedCodeInfo_Annotation::begin() const { +::google::protobuf::int32 GeneratedCodeInfo_Annotation::begin() const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.begin) return begin_; } - void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 value) { +void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 value) { set_has_begin(); begin_ = value; // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.begin) @@ -15651,11 +15797,11 @@ void GeneratedCodeInfo_Annotation::clear_end() { end_ = 0; clear_has_end(); } - ::google::protobuf::int32 GeneratedCodeInfo_Annotation::end() const { +::google::protobuf::int32 GeneratedCodeInfo_Annotation::end() const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.end) return end_; } - void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 value) { +void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 value) { set_has_end(); end_ = value; // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end) diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 5a9e12bc..b8cd093b 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -35,6 +35,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); @@ -204,6 +205,10 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message static const ::google::protobuf::Descriptor* descriptor(); static const FileDescriptorSet& default_instance(); + static inline const FileDescriptorSet* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(FileDescriptorSet* other); // implements Message ---------------------------------------------- @@ -218,7 +223,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -234,6 +239,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(FileDescriptorSet* other); + void UnsafeMergeFrom(const FileDescriptorSet& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -265,15 +271,16 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > file_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static FileDescriptorSet* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> default_instance_; }; // ------------------------------------------------------------------- @@ -300,6 +307,10 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const FileDescriptorProto& default_instance(); + static inline const FileDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(FileDescriptorProto* other); // implements Message ---------------------------------------------- @@ -314,7 +325,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -330,6 +341,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(FileDescriptorProto* other); + void UnsafeMergeFrom(const FileDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -501,10 +513,8 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag inline void clear_has_syntax(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::internal::ArenaStringPtr name_; - ::google::protobuf::internal::ArenaStringPtr package_; ::google::protobuf::RepeatedPtrField< ::std::string> dependency_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > public_dependency_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > weak_dependency_; @@ -512,15 +522,18 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto > enum_type_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto > service_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > extension_; + ::google::protobuf::internal::ArenaStringPtr name_; + ::google::protobuf::internal::ArenaStringPtr package_; + ::google::protobuf::internal::ArenaStringPtr syntax_; ::google::protobuf::FileOptions* options_; ::google::protobuf::SourceCodeInfo* source_code_info_; - ::google::protobuf::internal::ArenaStringPtr syntax_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static FileDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> default_instance_; }; // ------------------------------------------------------------------- @@ -547,6 +560,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto_ExtensionRange& default_instance(); + static inline const DescriptorProto_ExtensionRange* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(DescriptorProto_ExtensionRange* other); // implements Message ---------------------------------------------- @@ -561,7 +578,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -577,6 +594,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(DescriptorProto_ExtensionRange* other); + void UnsafeMergeFrom(const DescriptorProto_ExtensionRange& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -614,16 +632,17 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto inline void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::int32 start_; ::google::protobuf::int32 end_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static DescriptorProto_ExtensionRange* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> default_instance_; }; // ------------------------------------------------------------------- @@ -650,6 +669,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto_ReservedRange& default_instance(); + static inline const DescriptorProto_ReservedRange* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(DescriptorProto_ReservedRange* other); // implements Message ---------------------------------------------- @@ -664,7 +687,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -680,6 +703,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(DescriptorProto_ReservedRange* other); + void UnsafeMergeFrom(const DescriptorProto_ReservedRange& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -717,16 +741,17 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob inline void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::int32 start_; ::google::protobuf::int32 end_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static DescriptorProto_ReservedRange* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> default_instance_; }; // ------------------------------------------------------------------- @@ -753,6 +778,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto& default_instance(); + static inline const DescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(DescriptorProto* other); // implements Message ---------------------------------------------- @@ -767,7 +796,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -783,6 +812,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(DescriptorProto* other); + void UnsafeMergeFrom(const DescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -930,24 +960,25 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* inline void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > extension_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto > nested_type_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto > enum_type_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange > extension_range_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto > oneof_decl_; - ::google::protobuf::MessageOptions* options_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange > reserved_range_; ::google::protobuf::RepeatedPtrField< ::std::string> reserved_name_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + ::google::protobuf::internal::ArenaStringPtr name_; + ::google::protobuf::MessageOptions* options_; + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static DescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> default_instance_; }; // ------------------------------------------------------------------- @@ -974,6 +1005,10 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa static const ::google::protobuf::Descriptor* descriptor(); static const FieldDescriptorProto& default_instance(); + static inline const FieldDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(FieldDescriptorProto* other); // implements Message ---------------------------------------------- @@ -988,7 +1023,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1004,6 +1039,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(FieldDescriptorProto* other); + void UnsafeMergeFrom(const FieldDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -1226,24 +1262,25 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa inline void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; - ::google::protobuf::int32 number_; - int label_; ::google::protobuf::internal::ArenaStringPtr type_name_; ::google::protobuf::internal::ArenaStringPtr extendee_; - int type_; - ::google::protobuf::int32 oneof_index_; ::google::protobuf::internal::ArenaStringPtr default_value_; ::google::protobuf::internal::ArenaStringPtr json_name_; ::google::protobuf::FieldOptions* options_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + ::google::protobuf::int32 number_; + ::google::protobuf::int32 oneof_index_; + int label_; + int type_; + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static FieldDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> default_instance_; }; // ------------------------------------------------------------------- @@ -1270,6 +1307,10 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa static const ::google::protobuf::Descriptor* descriptor(); static const OneofDescriptorProto& default_instance(); + static inline const OneofDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(OneofDescriptorProto* other); // implements Message ---------------------------------------------- @@ -1284,7 +1325,7 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1300,6 +1341,7 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(OneofDescriptorProto* other); + void UnsafeMergeFrom(const OneofDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -1344,16 +1386,17 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa inline void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::OneofOptions* options_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static OneofDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> default_instance_; }; // ------------------------------------------------------------------- @@ -1380,6 +1423,10 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const EnumDescriptorProto& default_instance(); + static inline const EnumDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(EnumDescriptorProto* other); // implements Message ---------------------------------------------- @@ -1394,7 +1441,7 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1410,6 +1457,7 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(EnumDescriptorProto* other); + void UnsafeMergeFrom(const EnumDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -1466,17 +1514,18 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag inline void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto > value_; + ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::EnumOptions* options_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static EnumDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> default_instance_; }; // ------------------------------------------------------------------- @@ -1503,6 +1552,10 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M static const ::google::protobuf::Descriptor* descriptor(); static const EnumValueDescriptorProto& default_instance(); + static inline const EnumValueDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(EnumValueDescriptorProto* other); // implements Message ---------------------------------------------- @@ -1517,7 +1570,7 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1533,6 +1586,7 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(EnumValueDescriptorProto* other); + void UnsafeMergeFrom(const EnumValueDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -1586,17 +1640,18 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M inline void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::EnumValueOptions* options_; ::google::protobuf::int32 number_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static EnumValueDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> default_instance_; }; // ------------------------------------------------------------------- @@ -1623,6 +1678,10 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes static const ::google::protobuf::Descriptor* descriptor(); static const ServiceDescriptorProto& default_instance(); + static inline const ServiceDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(ServiceDescriptorProto* other); // implements Message ---------------------------------------------- @@ -1637,7 +1696,7 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1653,6 +1712,7 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(ServiceDescriptorProto* other); + void UnsafeMergeFrom(const ServiceDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -1709,17 +1769,18 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes inline void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto > method_; + ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::ServiceOptions* options_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static ServiceDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> default_instance_; }; // ------------------------------------------------------------------- @@ -1746,6 +1807,10 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess static const ::google::protobuf::Descriptor* descriptor(); static const MethodDescriptorProto& default_instance(); + static inline const MethodDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(MethodDescriptorProto* other); // implements Message ---------------------------------------------- @@ -1760,7 +1825,7 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1776,6 +1841,7 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(MethodDescriptorProto* other); + void UnsafeMergeFrom(const MethodDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -1866,7 +1932,7 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess inline void clear_has_server_streaming(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr input_type_; @@ -1874,12 +1940,13 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess ::google::protobuf::MethodOptions* options_; bool client_streaming_; bool server_streaming_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static MethodDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> default_instance_; }; // ------------------------------------------------------------------- @@ -1906,6 +1973,10 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const FileOptions& default_instance(); + static inline const FileOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(FileOptions* other); // implements Message ---------------------------------------------- @@ -1920,7 +1991,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1936,6 +2007,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(FileOptions* other); + void UnsafeMergeFrom(const FileOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2010,13 +2082,6 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p bool java_multiple_files() const; void set_java_multiple_files(bool value); - // optional bool java_generate_equals_and_hash = 20 [default = false]; - bool has_java_generate_equals_and_hash() const; - void clear_java_generate_equals_and_hash(); - static const int kJavaGenerateEqualsAndHashFieldNumber = 20; - bool java_generate_equals_and_hash() const; - void set_java_generate_equals_and_hash(bool value); - // optional bool java_string_check_utf8 = 27 [default = false]; bool has_java_string_check_utf8() const; void clear_java_string_check_utf8(); @@ -2123,8 +2188,6 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p inline void clear_has_java_outer_classname(); inline void set_has_java_multiple_files(); inline void clear_has_java_multiple_files(); - inline void set_has_java_generate_equals_and_hash(); - inline void clear_has_java_generate_equals_and_hash(); inline void set_has_java_string_check_utf8(); inline void clear_has_java_string_check_utf8(); inline void set_has_optimize_for(); @@ -2149,29 +2212,29 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; ::google::protobuf::internal::ArenaStringPtr java_package_; ::google::protobuf::internal::ArenaStringPtr java_outer_classname_; - bool java_multiple_files_; - bool java_generate_equals_and_hash_; - bool java_string_check_utf8_; - bool cc_generic_services_; - int optimize_for_; ::google::protobuf::internal::ArenaStringPtr go_package_; ::google::protobuf::internal::ArenaStringPtr objc_class_prefix_; ::google::protobuf::internal::ArenaStringPtr csharp_namespace_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; + bool java_multiple_files_; + bool java_string_check_utf8_; + bool cc_generic_services_; bool java_generic_services_; bool py_generic_services_; bool deprecated_; bool cc_enable_arenas_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + int optimize_for_; + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static FileOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<FileOptions> default_instance_; }; // ------------------------------------------------------------------- @@ -2198,6 +2261,10 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const MessageOptions& default_instance(); + static inline const MessageOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(MessageOptions* other); // implements Message ---------------------------------------------- @@ -2212,7 +2279,7 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -2228,6 +2295,7 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(MessageOptions* other); + void UnsafeMergeFrom(const MessageOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2298,19 +2366,20 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool message_set_wire_format_; bool no_standard_descriptor_accessor_; bool deprecated_; bool map_entry_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static MessageOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> default_instance_; }; // ------------------------------------------------------------------- @@ -2337,6 +2406,10 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ static const ::google::protobuf::Descriptor* descriptor(); static const FieldOptions& default_instance(); + static inline const FieldOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(FieldOptions* other); // implements Message ---------------------------------------------- @@ -2351,7 +2424,7 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -2367,6 +2440,7 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(FieldOptions* other); + void UnsafeMergeFrom(const FieldOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2511,21 +2585,22 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; int ctype_; int jstype_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool packed_; bool lazy_; bool deprecated_; bool weak_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static FieldOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> default_instance_; }; // ------------------------------------------------------------------- @@ -2552,6 +2627,10 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ static const ::google::protobuf::Descriptor* descriptor(); static const OneofOptions& default_instance(); + static inline const OneofOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(OneofOptions* other); // implements Message ---------------------------------------------- @@ -2566,7 +2645,7 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -2582,6 +2661,7 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(OneofOptions* other); + void UnsafeMergeFrom(const OneofOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2616,15 +2696,16 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static OneofOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> default_instance_; }; // ------------------------------------------------------------------- @@ -2651,6 +2732,10 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const EnumOptions& default_instance(); + static inline const EnumOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(EnumOptions* other); // implements Message ---------------------------------------------- @@ -2665,7 +2750,7 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -2681,6 +2766,7 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(EnumOptions* other); + void UnsafeMergeFrom(const EnumOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2733,17 +2819,18 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool allow_alias_; bool deprecated_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static EnumOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> default_instance_; }; // ------------------------------------------------------------------- @@ -2770,6 +2857,10 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / static const ::google::protobuf::Descriptor* descriptor(); static const EnumValueOptions& default_instance(); + static inline const EnumValueOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(EnumValueOptions* other); // implements Message ---------------------------------------------- @@ -2784,7 +2875,7 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -2800,6 +2891,7 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(EnumValueOptions* other); + void UnsafeMergeFrom(const EnumValueOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2843,16 +2935,17 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static EnumValueOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> default_instance_; }; // ------------------------------------------------------------------- @@ -2879,6 +2972,10 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const ServiceOptions& default_instance(); + static inline const ServiceOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(ServiceOptions* other); // implements Message ---------------------------------------------- @@ -2893,7 +2990,7 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -2909,6 +3006,7 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(ServiceOptions* other); + void UnsafeMergeFrom(const ServiceOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2952,16 +3050,17 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static ServiceOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> default_instance_; }; // ------------------------------------------------------------------- @@ -2988,6 +3087,10 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ static const ::google::protobuf::Descriptor* descriptor(); static const MethodOptions& default_instance(); + static inline const MethodOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(MethodOptions* other); // implements Message ---------------------------------------------- @@ -3002,7 +3105,7 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3018,6 +3121,7 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(MethodOptions* other); + void UnsafeMergeFrom(const MethodOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3061,16 +3165,17 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static MethodOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> default_instance_; }; // ------------------------------------------------------------------- @@ -3097,6 +3202,10 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu static const ::google::protobuf::Descriptor* descriptor(); static const UninterpretedOption_NamePart& default_instance(); + static inline const UninterpretedOption_NamePart* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(UninterpretedOption_NamePart* other); // implements Message ---------------------------------------------- @@ -3111,7 +3220,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3127,6 +3236,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(UninterpretedOption_NamePart* other); + void UnsafeMergeFrom(const UninterpretedOption_NamePart& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3168,20 +3278,21 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu inline void set_has_is_extension(); inline void clear_has_is_extension(); - // helper for ByteSize() - int RequiredFieldsByteSizeFallback() const; + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_part_; bool is_extension_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static UninterpretedOption_NamePart* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> default_instance_; }; // ------------------------------------------------------------------- @@ -3208,6 +3319,10 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const UninterpretedOption& default_instance(); + static inline const UninterpretedOption* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(UninterpretedOption* other); // implements Message ---------------------------------------------- @@ -3222,7 +3337,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3238,6 +3353,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(UninterpretedOption* other); + void UnsafeMergeFrom(const UninterpretedOption& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3340,21 +3456,22 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag inline void clear_has_aggregate_value(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart > name_; ::google::protobuf::internal::ArenaStringPtr identifier_value_; + ::google::protobuf::internal::ArenaStringPtr string_value_; + ::google::protobuf::internal::ArenaStringPtr aggregate_value_; ::google::protobuf::uint64 positive_int_value_; ::google::protobuf::int64 negative_int_value_; double double_value_; - ::google::protobuf::internal::ArenaStringPtr string_value_; - ::google::protobuf::internal::ArenaStringPtr aggregate_value_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static UninterpretedOption* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> default_instance_; }; // ------------------------------------------------------------------- @@ -3381,6 +3498,10 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me static const ::google::protobuf::Descriptor* descriptor(); static const SourceCodeInfo_Location& default_instance(); + static inline const SourceCodeInfo_Location* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(SourceCodeInfo_Location* other); // implements Message ---------------------------------------------- @@ -3395,7 +3516,7 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3411,6 +3532,7 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(SourceCodeInfo_Location* other); + void UnsafeMergeFrom(const SourceCodeInfo_Location& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3498,21 +3620,22 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me inline void clear_has_trailing_comments(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > path_; mutable int _path_cached_byte_size_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > span_; mutable int _span_cached_byte_size_; + ::google::protobuf::RepeatedPtrField< ::std::string> leading_detached_comments_; ::google::protobuf::internal::ArenaStringPtr leading_comments_; ::google::protobuf::internal::ArenaStringPtr trailing_comments_; - ::google::protobuf::RepeatedPtrField< ::std::string> leading_detached_comments_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static SourceCodeInfo_Location* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> default_instance_; }; // ------------------------------------------------------------------- @@ -3539,6 +3662,10 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const SourceCodeInfo& default_instance(); + static inline const SourceCodeInfo* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(SourceCodeInfo* other); // implements Message ---------------------------------------------- @@ -3553,7 +3680,7 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3569,6 +3696,7 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(SourceCodeInfo* other); + void UnsafeMergeFrom(const SourceCodeInfo& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3602,15 +3730,16 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location > location_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static SourceCodeInfo* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> default_instance_; }; // ------------------------------------------------------------------- @@ -3637,6 +3766,10 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu static const ::google::protobuf::Descriptor* descriptor(); static const GeneratedCodeInfo_Annotation& default_instance(); + static inline const GeneratedCodeInfo_Annotation* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(GeneratedCodeInfo_Annotation* other); // implements Message ---------------------------------------------- @@ -3651,7 +3784,7 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3667,6 +3800,7 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(GeneratedCodeInfo_Annotation* other); + void UnsafeMergeFrom(const GeneratedCodeInfo_Annotation& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3730,19 +3864,20 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu inline void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > path_; mutable int _path_cached_byte_size_; ::google::protobuf::internal::ArenaStringPtr source_file_; ::google::protobuf::int32 begin_; ::google::protobuf::int32 end_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static GeneratedCodeInfo_Annotation* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> default_instance_; }; // ------------------------------------------------------------------- @@ -3769,6 +3904,10 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message static const ::google::protobuf::Descriptor* descriptor(); static const GeneratedCodeInfo& default_instance(); + static inline const GeneratedCodeInfo* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(GeneratedCodeInfo* other); // implements Message ---------------------------------------------- @@ -3783,7 +3922,7 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3799,6 +3938,7 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(GeneratedCodeInfo* other); + void UnsafeMergeFrom(const GeneratedCodeInfo& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3832,15 +3972,16 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation > annotation_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static GeneratedCodeInfo* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> default_instance_; }; // =================================================================== @@ -4243,7 +4384,8 @@ inline void FileDescriptorProto::clear_options() { } inline const ::google::protobuf::FileOptions& FileDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::FileOptions::internal_default_instance(); } inline ::google::protobuf::FileOptions* FileDescriptorProto::mutable_options() { set_has_options(); @@ -4287,7 +4429,8 @@ inline void FileDescriptorProto::clear_source_code_info() { } inline const ::google::protobuf::SourceCodeInfo& FileDescriptorProto::source_code_info() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.source_code_info) - return source_code_info_ != NULL ? *source_code_info_ : *default_instance_->source_code_info_; + return source_code_info_ != NULL ? *source_code_info_ + : *::google::protobuf::SourceCodeInfo::internal_default_instance(); } inline ::google::protobuf::SourceCodeInfo* FileDescriptorProto::mutable_source_code_info() { set_has_source_code_info(); @@ -4727,7 +4870,8 @@ inline void DescriptorProto::clear_options() { } inline const ::google::protobuf::MessageOptions& DescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::MessageOptions::internal_default_instance(); } inline ::google::protobuf::MessageOptions* DescriptorProto::mutable_options() { set_has_options(); @@ -5228,7 +5372,8 @@ inline void FieldDescriptorProto::clear_options() { } inline const ::google::protobuf::FieldOptions& FieldDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::FieldOptions::internal_default_instance(); } inline ::google::protobuf::FieldOptions* FieldDescriptorProto::mutable_options() { set_has_options(); @@ -5330,7 +5475,8 @@ inline void OneofDescriptorProto::clear_options() { } inline const ::google::protobuf::OneofOptions& OneofDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::OneofOptions::internal_default_instance(); } inline ::google::protobuf::OneofOptions* OneofDescriptorProto::mutable_options() { set_has_options(); @@ -5462,7 +5608,8 @@ inline void EnumDescriptorProto::clear_options() { } inline const ::google::protobuf::EnumOptions& EnumDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::EnumOptions::internal_default_instance(); } inline ::google::protobuf::EnumOptions* EnumDescriptorProto::mutable_options() { set_has_options(); @@ -5588,7 +5735,8 @@ inline void EnumValueDescriptorProto::clear_options() { } inline const ::google::protobuf::EnumValueOptions& EnumValueDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::EnumValueOptions::internal_default_instance(); } inline ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::mutable_options() { set_has_options(); @@ -5720,7 +5868,8 @@ inline void ServiceDescriptorProto::clear_options() { } inline const ::google::protobuf::ServiceOptions& ServiceDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::ServiceOptions::internal_default_instance(); } inline ::google::protobuf::ServiceOptions* ServiceDescriptorProto::mutable_options() { set_has_options(); @@ -5930,7 +6079,8 @@ inline void MethodDescriptorProto::clear_options() { } inline const ::google::protobuf::MethodOptions& MethodDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::MethodOptions::internal_default_instance(); } inline ::google::protobuf::MethodOptions* MethodDescriptorProto::mutable_options() { set_has_options(); @@ -6142,39 +6292,15 @@ inline void FileOptions::set_java_multiple_files(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_multiple_files) } -// optional bool java_generate_equals_and_hash = 20 [default = false]; -inline bool FileOptions::has_java_generate_equals_and_hash() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -inline void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000008u; -} -inline void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000008u; -} -inline void FileOptions::clear_java_generate_equals_and_hash() { - java_generate_equals_and_hash_ = false; - clear_has_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 java_generate_equals_and_hash_; -} -inline void FileOptions::set_java_generate_equals_and_hash(bool value) { - set_has_java_generate_equals_and_hash(); - java_generate_equals_and_hash_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generate_equals_and_hash) -} - // optional bool java_string_check_utf8 = 27 [default = false]; inline bool FileOptions::has_java_string_check_utf8() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } inline void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000008u; } inline void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000008u; } inline void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; @@ -6192,13 +6318,13 @@ inline void FileOptions::set_java_string_check_utf8(bool value) { // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; inline bool FileOptions::has_optimize_for() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } inline void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000010u; } inline void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000010u; } inline void FileOptions::clear_optimize_for() { optimize_for_ = 1; @@ -6217,13 +6343,13 @@ inline void FileOptions::set_optimize_for(::google::protobuf::FileOptions_Optimi // optional string go_package = 11; inline bool FileOptions::has_go_package() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } inline void FileOptions::set_has_go_package() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000020u; } inline void FileOptions::clear_has_go_package() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000020u; } inline void FileOptions::clear_go_package() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -6271,13 +6397,13 @@ inline void FileOptions::set_allocated_go_package(::std::string* go_package) { // optional bool cc_generic_services = 16 [default = false]; inline bool FileOptions::has_cc_generic_services() const { - return (_has_bits_[0] & 0x00000080u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } inline void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000040u; } inline void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000040u; } inline void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; @@ -6295,13 +6421,13 @@ inline void FileOptions::set_cc_generic_services(bool value) { // optional bool java_generic_services = 17 [default = false]; inline bool FileOptions::has_java_generic_services() const { - return (_has_bits_[0] & 0x00000100u) != 0; + return (_has_bits_[0] & 0x00000080u) != 0; } inline void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000080u; } inline void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000080u; } inline void FileOptions::clear_java_generic_services() { java_generic_services_ = false; @@ -6319,13 +6445,13 @@ inline void FileOptions::set_java_generic_services(bool value) { // optional bool py_generic_services = 18 [default = false]; inline bool FileOptions::has_py_generic_services() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000100u) != 0; } inline void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000100u; } inline void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000100u; } inline void FileOptions::clear_py_generic_services() { py_generic_services_ = false; @@ -6343,13 +6469,13 @@ inline void FileOptions::set_py_generic_services(bool value) { // optional bool deprecated = 23 [default = false]; inline bool FileOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00000200u) != 0; } inline void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00000200u; } inline void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00000200u; } inline void FileOptions::clear_deprecated() { deprecated_ = false; @@ -6367,13 +6493,13 @@ inline void FileOptions::set_deprecated(bool value) { // optional bool cc_enable_arenas = 31 [default = false]; inline bool FileOptions::has_cc_enable_arenas() const { - return (_has_bits_[0] & 0x00000800u) != 0; + return (_has_bits_[0] & 0x00000400u) != 0; } inline void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00000400u; } inline void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00000400u; } inline void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; @@ -6391,13 +6517,13 @@ inline void FileOptions::set_cc_enable_arenas(bool value) { // optional string objc_class_prefix = 36; inline bool FileOptions::has_objc_class_prefix() const { - return (_has_bits_[0] & 0x00001000u) != 0; + return (_has_bits_[0] & 0x00000800u) != 0; } inline void FileOptions::set_has_objc_class_prefix() { - _has_bits_[0] |= 0x00001000u; + _has_bits_[0] |= 0x00000800u; } inline void FileOptions::clear_has_objc_class_prefix() { - _has_bits_[0] &= ~0x00001000u; + _has_bits_[0] &= ~0x00000800u; } inline void FileOptions::clear_objc_class_prefix() { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -6445,13 +6571,13 @@ inline void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_cla // optional string csharp_namespace = 37; inline bool FileOptions::has_csharp_namespace() const { - return (_has_bits_[0] & 0x00002000u) != 0; + return (_has_bits_[0] & 0x00001000u) != 0; } inline void FileOptions::set_has_csharp_namespace() { - _has_bits_[0] |= 0x00002000u; + _has_bits_[0] |= 0x00001000u; } inline void FileOptions::clear_has_csharp_namespace() { - _has_bits_[0] &= ~0x00002000u; + _has_bits_[0] &= ~0x00001000u; } inline void FileOptions::clear_csharp_namespace() { csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index 28410d4a..23a9fe92 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -45,7 +45,6 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "DescriptorProtos"; option csharp_namespace = "Google.Protobuf.Reflection"; option objc_class_prefix = "GPB"; -option java_generate_equals_and_hash = true; // descriptor.proto must be optimized for speed because reflection-based // algorithms don't work during bootstrapping. @@ -306,19 +305,10 @@ message FileOptions { // top-level extensions defined in the file. optional bool java_multiple_files = 10 [default=false]; - // If set true, then the Java code generator will generate equals() and - // hashCode() methods for all messages defined in the .proto file. - // This increases generated code size, potentially substantially for large - // protos, which may harm a memory-constrained application. - // - In the full runtime this is a speed optimization, as the - // AbstractMessage base class includes reflection-based implementations of - // these methods. - // - In the lite runtime, setting this option changes the semantics of - // equals() and hashCode() to more closely match those of the full runtime; - // the generated methods compute their results based on field values rather - // than object identity. (Implementations should not assume that hashcodes - // will be consistent across runtimes or versions of the protocol compiler.) - optional bool java_generate_equals_and_hash = 20 [default=false]; + // BEGIN PROTOBUF-OPENSOURCE + // // This option does nothing. + // optional bool java_generate_equals_and_hash = 20 [deprecated=true]; + // END PROTOBUF-OPENSOURCE // If set true, then the Java2 code generator will generate code that // throws an exception whenever an attempt is made to assign a non-UTF-8 @@ -448,6 +438,8 @@ message MessageOptions { // Clients can define custom options in extensions of this message. See above. extensions 1000 to max; + + reserved 8; // javalite_serializable } message FieldOptions { @@ -471,7 +463,6 @@ message FieldOptions { // false will avoid using packed encoding. optional bool packed = 2; - // The jstype option determines the JavaScript type used for values of the // field. The option is permitted only for 64 bit integral and fixed types // (int64, uint64, sint64, fixed64, sfixed64). By default these types are @@ -512,7 +503,7 @@ message FieldOptions { // // // Note that implementations may choose not to check required fields within - // a lazy sub-message. That is, calling IsInitialized() on the outher message + // a lazy sub-message. That is, calling IsInitialized() on the outer message // may return true even if the inner message has missing required fields. // This is necessary because otherwise the inner message would have to be // parsed in order to perform the check, defeating the purpose of lazy @@ -538,6 +529,8 @@ message FieldOptions { // Clients can define custom options in extensions of this message. See above. extensions 1000 to max; + + reserved 4; // removed jtype } message OneofOptions { diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index 4183138f..07953416 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -773,9 +773,9 @@ TEST_F(DescriptorTest, FieldFullName) { TEST_F(DescriptorTest, FieldJsonName) { EXPECT_EQ("fieldName1", message4_->field(0)->json_name()); EXPECT_EQ("fieldName2", message4_->field(1)->json_name()); - EXPECT_EQ("fieldName3", message4_->field(2)->json_name()); - EXPECT_EQ("fieldName4", message4_->field(3)->json_name()); - EXPECT_EQ("fIELDNAME5", message4_->field(4)->json_name()); + EXPECT_EQ("FieldName3", message4_->field(2)->json_name()); + EXPECT_EQ("FieldName4", message4_->field(3)->json_name()); + EXPECT_EQ("FIELDNAME5", message4_->field(4)->json_name()); EXPECT_EQ("@type", message4_->field(5)->json_name()); DescriptorProto proto; @@ -793,10 +793,20 @@ TEST_F(DescriptorTest, FieldJsonName) { ASSERT_EQ(6, proto.field_size()); EXPECT_EQ("fieldName1", proto.field(0).json_name()); EXPECT_EQ("fieldName2", proto.field(1).json_name()); - EXPECT_EQ("fieldName3", proto.field(2).json_name()); - EXPECT_EQ("fieldName4", proto.field(3).json_name()); - EXPECT_EQ("fIELDNAME5", proto.field(4).json_name()); + EXPECT_EQ("FieldName3", proto.field(2).json_name()); + EXPECT_EQ("FieldName4", proto.field(3).json_name()); + EXPECT_EQ("FIELDNAME5", proto.field(4).json_name()); EXPECT_EQ("@type", proto.field(5).json_name()); + + // Test generated descriptor. + const Descriptor* generated = protobuf_unittest::TestJsonName::descriptor(); + ASSERT_EQ(6, generated->field_count()); + EXPECT_EQ("fieldName1", generated->field(0)->json_name()); + EXPECT_EQ("fieldName2", generated->field(1)->json_name()); + EXPECT_EQ("FieldName3", generated->field(2)->json_name()); + EXPECT_EQ("FieldName4", generated->field(3)->json_name()); + EXPECT_EQ("FIELDNAME5", generated->field(4)->json_name()); + EXPECT_EQ("@type", generated->field(5)->json_name()); } TEST_F(DescriptorTest, FieldFile) { @@ -5553,6 +5563,60 @@ TEST_F(ValidationErrorTest, MapEntryConflictsWithEnum) { "with an existing enum type.\n"); } +TEST_F(ValidationErrorTest, EnumValuesConflictWhenPrefixesStripped) { + BuildFileWithErrors( + "name: 'foo.proto' " + "enum_type {" + " name: 'FooEnum' " + " value { name: 'FOO_ENUM_BAZ' number: 0 }" + " value { name: 'BAZ' number: 1 }" + "}", + "foo.proto: BAZ: NAME: When enum name is stripped and label is " + "PascalCased (Baz), this value label conflicts with FOO_ENUM_BAZ\n"); + + BuildFileWithErrors( + "name: 'foo.proto' " + "enum_type {" + " name: 'FooEnum' " + " value { name: 'FOOENUM_BAZ' number: 0 }" + " value { name: 'BAZ' number: 1 }" + "}", + "foo.proto: BAZ: NAME: When enum name is stripped and label is " + "PascalCased (Baz), this value label conflicts with FOOENUM_BAZ\n"); + + BuildFileWithErrors( + "name: 'foo.proto' " + "enum_type {" + " name: 'FooEnum' " + " value { name: 'FOO_ENUM_BAR_BAZ' number: 0 }" + " value { name: 'BAR__BAZ' number: 1 }" + "}", + "foo.proto: BAR__BAZ: NAME: When enum name is stripped and label is " + "PascalCased (BarBaz), this value label conflicts with " + "FOO_ENUM_BAR_BAZ\n"); + + BuildFileWithErrors( + "name: 'foo.proto' " + "enum_type {" + " name: 'FooEnum' " + " value { name: 'FOO_ENUM__BAR_BAZ' number: 0 }" + " value { name: 'BAR_BAZ' number: 1 }" + "}", + "foo.proto: BAR_BAZ: NAME: When enum name is stripped and label is " + "PascalCased (BarBaz), this value label conflicts with " + "FOO_ENUM__BAR_BAZ\n"); + + // This isn't an error because the underscore will cause the PascalCase to + // differ by case (BarBaz vs. Barbaz). + BuildFile( + "name: 'foo.proto' " + "enum_type {" + " name: 'FooEnum' " + " value { name: 'BAR_BAZ' number: 0 }" + " value { name: 'BARBAZ' number: 1 }" + "}"); +} + TEST_F(ValidationErrorTest, MapEntryConflictsWithOneof) { FileDescriptorProto file_proto; FillValidMapEntry(&file_proto); 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<char*>(&nanos_) - + reinterpret_cast<char*>(&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> 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<Duration>(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<const Duration>( &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) diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index ad479639..c9239bd9 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -34,6 +34,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto(); @@ -53,9 +54,18 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot return *this; } + inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } + inline void* GetMaybeArenaPointer() const { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const Duration& default_instance(); + static inline const Duration* internal_default_instance() { + return &default_instance_.get(); + } + + void UnsafeArenaSwap(Duration* other); void Swap(Duration* other); // implements Message ---------------------------------------------- @@ -70,7 +80,7 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -86,6 +96,12 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Duration* other); + void UnsafeMergeFrom(const Duration& from); + protected: + explicit Duration(::google::protobuf::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -117,16 +133,19 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; + friend class ::google::protobuf::Arena; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::int64 seconds_; ::google::protobuf::int32 nanos_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto(); void InitAsDefaultInstance(); - static Duration* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Duration> default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/duration.proto b/src/google/protobuf/duration.proto index 96c1796d..7f461f40 100644 --- a/src/google/protobuf/duration.proto +++ b/src/google/protobuf/duration.proto @@ -33,11 +33,11 @@ syntax = "proto3"; package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option cc_enable_arenas = true; option go_package = "github.com/golang/protobuf/ptypes/duration"; option java_package = "com.google.protobuf"; option java_outer_classname = "DurationProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; // A Duration represents a signed, fixed-length span of time represented @@ -81,6 +81,12 @@ option objc_class_prefix = "GPB"; // end.nanos -= 1000000000; // } // +// Example 3: Compute Duration from datetime.timedelta in Python. +// +// td = datetime.timedelta(days=3, minutes=10) +// duration = Duration() +// duration.FromTimedelta(td) +// // message Duration { diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc index 5d914bf6..f51bc9d6 100644 --- a/src/google/protobuf/dynamic_message.cc +++ b/src/google/protobuf/dynamic_message.cc @@ -223,7 +223,6 @@ class DynamicMessage : public Message { int oneof_case_offset; int unknown_fields_offset; int extensions_offset; - int is_default_instance_offset; // Not owned by the TypeInfo. DynamicMessageFactory* factory; // The factory that created this object. @@ -332,11 +331,6 @@ void DynamicMessage::SharedCtor() { uint32(0); } - if (type_info_->is_default_instance_offset != -1) { - *reinterpret_cast<bool*>( - OffsetToPointer(type_info_->is_default_instance_offset)) = false; - } - new(OffsetToPointer(type_info_->unknown_fields_offset)) UnknownFieldSet; if (type_info_->extensions_offset != -1) { @@ -556,14 +550,6 @@ void DynamicMessage::CrossLinkPrototypes() { factory->GetPrototypeNoLock(field->message_type()); } } - - // Set as the default instance -- this affects field-presence semantics for - // proto3. - if (type_info_->is_default_instance_offset != -1) { - void* is_default_instance_ptr = - OffsetToPointer(type_info_->is_default_instance_offset); - *reinterpret_cast<bool*>(is_default_instance_ptr) = true; - } } Message* DynamicMessage::New() const { @@ -683,15 +669,6 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( size = AlignOffset(size); } - // The is_default_instance member, if any. - if (type->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) { - type_info->is_default_instance_offset = size; - size += sizeof(bool); - size = AlignOffset(size); - } else { - type_info->is_default_instance_offset = -1; - } - // The oneof_case, if any. It is an array of uint32s. if (type->oneof_decl_count() > 0) { type_info->oneof_case_offset = size; @@ -769,35 +746,18 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( ConstructDefaultOneofInstance(type_info->type, type_info->offsets.get(), type_info->default_oneof_instance); - type_info->reflection.reset( - new GeneratedMessageReflection( - type_info->type, - type_info->prototype, - type_info->offsets.get(), - type_info->has_bits_offset, - type_info->unknown_fields_offset, - type_info->extensions_offset, - type_info->default_oneof_instance, - type_info->oneof_case_offset, - type_info->pool, - this, - type_info->size, - -1 /* arena_offset */, - type_info->is_default_instance_offset)); + type_info->reflection.reset(new GeneratedMessageReflection( + type_info->type, type_info->prototype, type_info->offsets.get(), + type_info->has_bits_offset, type_info->unknown_fields_offset, + type_info->extensions_offset, type_info->default_oneof_instance, + type_info->oneof_case_offset, type_info->pool, this, type_info->size, + -1 /* arena_offset */)); } else { - type_info->reflection.reset( - new GeneratedMessageReflection( - type_info->type, - type_info->prototype, - type_info->offsets.get(), - type_info->has_bits_offset, - type_info->unknown_fields_offset, - type_info->extensions_offset, - type_info->pool, - this, - type_info->size, - -1 /* arena_offset */, - type_info->is_default_instance_offset)); + type_info->reflection.reset(new GeneratedMessageReflection( + type_info->type, type_info->prototype, type_info->offsets.get(), + type_info->has_bits_offset, type_info->unknown_fields_offset, + type_info->extensions_offset, type_info->pool, this, type_info->size, + -1 /* arena_offset */)); } // Cross link prototypes. prototype->CrossLinkPrototypes(); diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index 7ef97790..45bba99b 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -42,20 +42,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto() { Empty_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Empty_descriptor_, - Empty::default_instance_, + Empty::internal_default_instance(), Empty_offsets_, -1, -1, -1, sizeof(Empty), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _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_2fempty_2eproto); } @@ -64,36 +63,47 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Empty_descriptor_, &Empty::default_instance()); + Empty_descriptor_, Empty::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto() { - delete Empty::default_instance_; delete Empty_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + Empty::default_instance_.DefaultConstruct(); + Empty::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\033google/protobuf/empty.proto\022\017google.pr" - "otobuf\"\007\n\005EmptyBy\n\023com.google.protobufB\n" + "otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n" "EmptyProtoP\001Z\'github.com/golang/protobuf" - "/ptypes/empty\240\001\001\370\001\001\242\002\003GPB\252\002\036Google.Proto" - "buf.WellKnownTypesb\006proto3", 186); + "/ptypes/empty\370\001\001\242\002\003GPB\252\002\036Google.Protobuf" + ".WellKnownTypesb\006proto3", 183); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/empty.proto", &protobuf_RegisterTypes); - Empty::default_instance_ = new Empty(); - Empty::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto() { @@ -101,6 +111,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fempty_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 @@ -108,32 +128,33 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto { Empty::Empty() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Empty) } - Empty::Empty(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Empty) } void Empty::InitAsDefaultInstance() { - _is_default_instance_ = true; } Empty::Empty(const Empty& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Empty) } void Empty::SharedCtor() { - _is_default_instance_ = false; _cached_size_ = 0; } @@ -143,12 +164,11 @@ Empty::~Empty() { } void Empty::SharedDtor() { - if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { return; } - if (this != default_instance_) { - } } void Empty::ArenaDtor(void* object) { @@ -168,11 +188,11 @@ const ::google::protobuf::Descriptor* Empty::descriptor() { } const Empty& Empty::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); + return *internal_default_instance(); } -Empty* Empty::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<Empty> Empty::default_instance_; Empty* Empty::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Empty>(arena); @@ -222,22 +242,21 @@ void Empty::SerializeWithCachedSizes( return target; } -int Empty::ByteSize() const { +size_t Empty::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Empty) - int total_size = 0; + size_t total_size = 0; + 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 Empty::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Empty) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Empty* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Empty* source = ::google::protobuf::internal::DynamicCastToGenerated<const Empty>( &from); if (source == NULL) { @@ -245,17 +264,23 @@ void Empty::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Empty) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Empty::MergeFrom(const Empty& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Empty) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } } +void Empty::UnsafeMergeFrom(const Empty& from) { + GOOGLE_DCHECK(&from != this); +} + void Empty::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Empty) if (&from == this) return; @@ -267,7 +292,7 @@ void Empty::CopyFrom(const Empty& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Empty) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Empty::IsInitialized() const { @@ -281,7 +306,7 @@ void Empty::Swap(Empty* other) { InternalSwap(other); } else { Empty temp; - temp.MergeFrom(*this); + temp.UnsafeMergeFrom(*this); CopyFrom(*other); other->CopyFrom(temp); } diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 8e78733b..552b7a61 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -34,6 +34,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto(); @@ -60,6 +61,10 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ static const ::google::protobuf::Descriptor* descriptor(); static const Empty& default_instance(); + static inline const Empty* internal_default_instance() { + return &default_instance_.get(); + } + void UnsafeArenaSwap(Empty* other); void Swap(Empty* other); @@ -75,7 +80,7 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -91,6 +96,7 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Empty* other); + void UnsafeMergeFrom(const Empty& from); protected: explicit Empty(::google::protobuf::Arena* arena); private: @@ -118,14 +124,14 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool _is_default_instance_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto(); void InitAsDefaultInstance(); - static Empty* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Empty> default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/empty.proto b/src/google/protobuf/empty.proto index 37f4cd10..03cacd23 100644 --- a/src/google/protobuf/empty.proto +++ b/src/google/protobuf/empty.proto @@ -37,7 +37,6 @@ option go_package = "github.com/golang/protobuf/ptypes/empty"; option java_package = "com.google.protobuf"; option java_outer_classname = "EmptyProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; option cc_enable_arenas = true; diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc index 7d20a0f8..ad164e3e 100644 --- a/src/google/protobuf/extension_set.cc +++ b/src/google/protobuf/extension_set.cc @@ -1354,8 +1354,8 @@ void ExtensionSet::SerializeWithCachedSizes( } } -int ExtensionSet::ByteSize() const { - int total_size = 0; +size_t ExtensionSet::ByteSize() const { + size_t total_size = 0; for (ExtensionMap::const_iterator iter = extensions_.begin(); iter != extensions_.end(); ++iter) { @@ -1536,8 +1536,8 @@ void ExtensionSet::Extension::SerializeFieldWithCachedSizes( } } -int ExtensionSet::Extension::ByteSize(int number) const { - int result = 0; +size_t ExtensionSet::Extension::ByteSize(int number) const { + size_t result = 0; if (is_repeated) { if (is_packed) { @@ -1563,7 +1563,7 @@ int ExtensionSet::Extension::ByteSize(int number) const { #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ case WireFormatLite::TYPE_##UPPERCASE: \ result += WireFormatLite::k##CAMELCASE##Size * \ - repeated_##LOWERCASE##_value->size(); \ + FromIntSize(repeated_##LOWERCASE##_value->size()); \ break HANDLE_TYPE( FIXED32, Fixed32, uint32); HANDLE_TYPE( FIXED64, Fixed64, uint64); @@ -1582,7 +1582,7 @@ int ExtensionSet::Extension::ByteSize(int number) const { break; } - cached_size = result; + cached_size = ToCachedSize(result); if (result > 0) { result += io::CodedOutputStream::VarintSize32(result); result += io::CodedOutputStream::VarintSize32( @@ -1590,12 +1590,13 @@ int ExtensionSet::Extension::ByteSize(int number) const { WireFormatLite::WIRETYPE_LENGTH_DELIMITED)); } } else { - int tag_size = WireFormatLite::TagSize(number, real_type(type)); + size_t tag_size = WireFormatLite::TagSize(number, real_type(type)); switch (real_type(type)) { #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ case WireFormatLite::TYPE_##UPPERCASE: \ - result += tag_size * repeated_##LOWERCASE##_value->size(); \ + result += tag_size * \ + FromIntSize(repeated_##LOWERCASE##_value->size()); \ for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \ result += WireFormatLite::CAMELCASE##Size( \ repeated_##LOWERCASE##_value->Get(i)); \ @@ -1619,7 +1620,7 @@ int ExtensionSet::Extension::ByteSize(int number) const { #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ case WireFormatLite::TYPE_##UPPERCASE: \ result += (tag_size + WireFormatLite::k##CAMELCASE##Size) * \ - repeated_##LOWERCASE##_value->size(); \ + FromIntSize(repeated_##LOWERCASE##_value->size()); \ break HANDLE_TYPE( FIXED32, Fixed32, uint32); HANDLE_TYPE( FIXED64, Fixed64, uint64); @@ -1652,7 +1653,7 @@ int ExtensionSet::Extension::ByteSize(int number) const { #undef HANDLE_TYPE case WireFormatLite::TYPE_MESSAGE: { if (is_lazy) { - int size = lazymessage_value->ByteSize(); + size_t size = lazymessage_value->ByteSize(); result += io::CodedOutputStream::VarintSize32(size) + size; } else { result += WireFormatLite::MessageSize(*message_value); diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h index 3e1d1ef5..f5aa8de9 100644 --- a/src/google/protobuf/extension_set.h +++ b/src/google/protobuf/extension_set.h @@ -423,10 +423,10 @@ class LIBPROTOBUF_EXPORT ExtensionSet { uint8* SerializeMessageSetWithCachedSizesToArray(uint8* target) const; // Returns the total serialized size of all the extensions. - int ByteSize() const; + size_t ByteSize() const; // Like ByteSize() but uses MessageSet format. - int MessageSetByteSize() const; + size_t MessageSetByteSize() const; // Returns (an estimate of) the total number of bytes used for storing the // extensions in memory, excluding sizeof(*this). If the ExtensionSet is @@ -551,8 +551,8 @@ class LIBPROTOBUF_EXPORT ExtensionSet { int number, bool deterministic, uint8* target) const; - int ByteSize(int number) const; - int MessageSetItemByteSize(int number) const; + size_t ByteSize(int number) const; + size_t MessageSetItemByteSize(int number) const; void Clear(); int GetSize() const; void Free(); diff --git a/src/google/protobuf/extension_set_heavy.cc b/src/google/protobuf/extension_set_heavy.cc index b26a246c..1bbc8fef 100644 --- a/src/google/protobuf/extension_set_heavy.cc +++ b/src/google/protobuf/extension_set_heavy.cc @@ -749,7 +749,7 @@ void ExtensionSet::Extension::SerializeMessageSetItemWithCachedSizes( output->WriteTag(WireFormatLite::kMessageSetItemEndTag); } -int ExtensionSet::Extension::MessageSetItemByteSize(int number) const { +size_t ExtensionSet::Extension::MessageSetItemByteSize(int number) const { if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) { // Not a valid MessageSet extension, but compute the byte size for it the // normal way. @@ -758,13 +758,13 @@ int ExtensionSet::Extension::MessageSetItemByteSize(int number) const { if (is_cleared) return 0; - int our_size = WireFormatLite::kMessageSetItemTagsSize; + size_t our_size = WireFormatLite::kMessageSetItemTagsSize; // type_id our_size += io::CodedOutputStream::VarintSize32(number); // message - int message_size = 0; + size_t message_size = 0; if (is_lazy) { message_size = lazymessage_value->ByteSize(); } else { @@ -785,8 +785,8 @@ void ExtensionSet::SerializeMessageSetWithCachedSizes( } } -int ExtensionSet::MessageSetByteSize() const { - int total_size = 0; +size_t ExtensionSet::MessageSetByteSize() const { + size_t total_size = 0; for (ExtensionMap::const_iterator iter = extensions_.begin(); iter != extensions_.end(); ++iter) { diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc index 688afedb..a70a2ff6 100644 --- a/src/google/protobuf/extension_set_unittest.cc +++ b/src/google/protobuf/extension_set_unittest.cc @@ -796,7 +796,7 @@ TEST(ExtensionSetTest, SpaceUsedExcludingSelf) { } \ int expected_size = sizeof(cpptype) * (16 - \ kMinRepeatedFieldAllocationSize) + empty_repeated_field_size; \ - EXPECT_EQ(expected_size, message.SpaceUsed()) << #type; \ + EXPECT_LE(expected_size, message.SpaceUsed()) << #type; \ } while (0) TEST_REPEATED_EXTENSIONS_SPACE_USED(int32 , int32 , 101); diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index d2acc38b..ffe513d3 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -43,20 +43,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto() { FieldMask_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FieldMask_descriptor_, - FieldMask::default_instance_, + FieldMask::internal_default_instance(), FieldMask_offsets_, -1, -1, -1, sizeof(FieldMask), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _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_2ffield_5fmask_2eproto); } @@ -65,36 +64,48 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldMask_descriptor_, &FieldMask::default_instance()); + FieldMask_descriptor_, FieldMask::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto() { - delete FieldMask::default_instance_; delete FieldMask_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::internal::GetEmptyString(); + FieldMask::default_instance_.DefaultConstruct(); + FieldMask::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n google/protobuf/field_mask.proto\022\017goog" "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB" - "Q\n\023com.google.protobufB\016FieldMaskProtoP\001" - "\240\001\001\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTyp" - "esb\006proto3", 170); + "N\n\023com.google.protobufB\016FieldMaskProtoP\001" + "\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb" + "\006proto3", 167); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/field_mask.proto", &protobuf_RegisterTypes); - FieldMask::default_instance_ = new FieldMask(); - FieldMask::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto() { @@ -102,6 +113,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2ffield_5fmask_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 @@ -110,25 +131,23 @@ const int FieldMask::kPathsFieldNumber; FieldMask::FieldMask() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldMask) } void FieldMask::InitAsDefaultInstance() { - _is_default_instance_ = true; } FieldMask::FieldMask(const FieldMask& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldMask) } void FieldMask::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; } @@ -138,8 +157,6 @@ FieldMask::~FieldMask() { } void FieldMask::SharedDtor() { - if (this != default_instance_) { - } } void FieldMask::SetCachedSize(int size) const { @@ -153,11 +170,11 @@ const ::google::protobuf::Descriptor* FieldMask::descriptor() { } const FieldMask& FieldMask::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); + return *internal_default_instance(); } -FieldMask* FieldMask::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<FieldMask> FieldMask::default_instance_; FieldMask* FieldMask::New(::google::protobuf::Arena* arena) const { FieldMask* n = new FieldMask; @@ -256,29 +273,29 @@ void FieldMask::SerializeWithCachedSizes( return target; } -int FieldMask::ByteSize() const { +size_t FieldMask::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldMask) - int total_size = 0; + size_t total_size = 0; // repeated string paths = 1; - total_size += 1 * this->paths_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->paths_size()); for (int i = 0; i < this->paths_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->paths(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 FieldMask::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldMask) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const FieldMask* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FieldMask* source = ::google::protobuf::internal::DynamicCastToGenerated<const FieldMask>( &from); if (source == NULL) { @@ -286,16 +303,22 @@ void FieldMask::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldMask) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void FieldMask::MergeFrom(const FieldMask& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldMask) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } - paths_.MergeFrom(from.paths_); +} + +void FieldMask::UnsafeMergeFrom(const FieldMask& from) { + GOOGLE_DCHECK(&from != this); + paths_.UnsafeMergeFrom(from.paths_); } void FieldMask::CopyFrom(const ::google::protobuf::Message& from) { @@ -309,7 +332,7 @@ void FieldMask::CopyFrom(const FieldMask& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldMask) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FieldMask::IsInitialized() const { @@ -345,49 +368,49 @@ int FieldMask::paths_size() const { void FieldMask::clear_paths() { paths_.Clear(); } - const ::std::string& FieldMask::paths(int index) const { +const ::std::string& FieldMask::paths(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FieldMask.paths) return paths_.Get(index); } - ::std::string* FieldMask::mutable_paths(int index) { +::std::string* FieldMask::mutable_paths(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FieldMask.paths) return paths_.Mutable(index); } - void FieldMask::set_paths(int index, const ::std::string& value) { +void FieldMask::set_paths(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) paths_.Mutable(index)->assign(value); } - void FieldMask::set_paths(int index, const char* value) { +void FieldMask::set_paths(int index, const char* value) { paths_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths) } - void FieldMask::set_paths(int index, const char* value, size_t size) { +void FieldMask::set_paths(int index, const char* value, size_t size) { paths_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldMask.paths) } - ::std::string* FieldMask::add_paths() { +::std::string* FieldMask::add_paths() { // @@protoc_insertion_point(field_add_mutable:google.protobuf.FieldMask.paths) return paths_.Add(); } - void FieldMask::add_paths(const ::std::string& value) { +void FieldMask::add_paths(const ::std::string& value) { paths_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) } - void FieldMask::add_paths(const char* value) { +void FieldMask::add_paths(const char* value) { paths_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths) } - void FieldMask::add_paths(const char* value, size_t size) { +void FieldMask::add_paths(const char* value, size_t size) { paths_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.FieldMask.paths) } - const ::google::protobuf::RepeatedPtrField< ::std::string>& +const ::google::protobuf::RepeatedPtrField< ::std::string>& FieldMask::paths() const { // @@protoc_insertion_point(field_list:google.protobuf.FieldMask.paths) return paths_; } - ::google::protobuf::RepeatedPtrField< ::std::string>* +::google::protobuf::RepeatedPtrField< ::std::string>* FieldMask::mutable_paths() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldMask.paths) return &paths_; diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 7a19c4aa..87ee9854 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -34,6 +34,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto(); @@ -56,6 +57,10 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro static const ::google::protobuf::Descriptor* descriptor(); static const FieldMask& default_instance(); + static inline const FieldMask* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(FieldMask* other); // implements Message ---------------------------------------------- @@ -70,7 +75,7 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -86,6 +91,7 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(FieldMask* other); + void UnsafeMergeFrom(const FieldMask& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -121,15 +127,15 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; ::google::protobuf::RepeatedPtrField< ::std::string> paths_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto(); void InitAsDefaultInstance(); - static FieldMask* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/field_mask.proto b/src/google/protobuf/field_mask.proto index c51de09a..b6d32a79 100644 --- a/src/google/protobuf/field_mask.proto +++ b/src/google/protobuf/field_mask.proto @@ -37,7 +37,6 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "FieldMaskProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; -option java_generate_equals_and_hash = true; // `FieldMask` represents a set of symbolic field paths, for example: // @@ -82,7 +81,7 @@ option java_generate_equals_and_hash = true; // } // // A repeated field is not allowed except at the last position of a -// field mask. +// paths string. // // If a FieldMask object is not present in a get operation, the // operation applies to all fields (as if a FieldMask of all fields @@ -109,8 +108,8 @@ option java_generate_equals_and_hash = true; // // If a repeated field is specified for an update operation, the existing // repeated values in the target resource will be overwritten by the new values. -// Note that a repeated field is only allowed in the last position of a field -// mask. +// Note that a repeated field is only allowed in the last position of a `paths` +// string. // // If a sub-message is specified in the last position of the field mask for an // update operation, then the existing sub-message in the target resource is diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index d1f7b5ca..6f418433 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -173,62 +173,43 @@ static void ReportReflectionUsageEnumTypeError( // =================================================================== GeneratedMessageReflection::GeneratedMessageReflection( - const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, - const DescriptorPool* descriptor_pool, - MessageFactory* factory, - int object_size, - int arena_offset, - int is_default_instance_offset) - : descriptor_ (descriptor), - default_instance_ (default_instance), - offsets_ (offsets), - has_bits_offset_ (has_bits_offset), - unknown_fields_offset_(unknown_fields_offset), - extensions_offset_(extensions_offset), - arena_offset_ (arena_offset), - is_default_instance_offset_(is_default_instance_offset), - object_size_ (object_size), - descriptor_pool_ ((descriptor_pool == NULL) ? - DescriptorPool::generated_pool() : - descriptor_pool), - message_factory_ (factory) { -} + const Descriptor* descriptor, const Message* default_instance, + const int offsets[], int has_bits_offset, int unknown_fields_offset, + int extensions_offset, const DescriptorPool* descriptor_pool, + MessageFactory* factory, int object_size, int arena_offset) + : descriptor_(descriptor), + default_instance_(default_instance), + offsets_(offsets), + has_bits_offset_(has_bits_offset), + unknown_fields_offset_(unknown_fields_offset), + extensions_offset_(extensions_offset), + arena_offset_(arena_offset), + object_size_(object_size), + descriptor_pool_((descriptor_pool == NULL) + ? DescriptorPool::generated_pool() + : descriptor_pool), + message_factory_(factory) {} GeneratedMessageReflection::GeneratedMessageReflection( - const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, - const void* default_oneof_instance, - int oneof_case_offset, - const DescriptorPool* descriptor_pool, - MessageFactory* factory, - int object_size, - int arena_offset, - int is_default_instance_offset) - : descriptor_ (descriptor), - default_instance_ (default_instance), - default_oneof_instance_ (default_oneof_instance), - offsets_ (offsets), - has_bits_offset_ (has_bits_offset), - oneof_case_offset_(oneof_case_offset), - unknown_fields_offset_(unknown_fields_offset), - extensions_offset_(extensions_offset), - arena_offset_ (arena_offset), - is_default_instance_offset_(is_default_instance_offset), - object_size_ (object_size), - descriptor_pool_ ((descriptor_pool == NULL) ? - DescriptorPool::generated_pool() : - descriptor_pool), - message_factory_ (factory) { -} + const Descriptor* descriptor, const Message* default_instance, + const int offsets[], int has_bits_offset, int unknown_fields_offset, + int extensions_offset, const void* default_oneof_instance, + int oneof_case_offset, const DescriptorPool* descriptor_pool, + MessageFactory* factory, int object_size, int arena_offset) + : descriptor_(descriptor), + default_instance_(default_instance), + default_oneof_instance_(default_oneof_instance), + offsets_(offsets), + has_bits_offset_(has_bits_offset), + oneof_case_offset_(oneof_case_offset), + unknown_fields_offset_(unknown_fields_offset), + extensions_offset_(extensions_offset), + arena_offset_(arena_offset), + object_size_(object_size), + descriptor_pool_((descriptor_pool == NULL) + ? DescriptorPool::generated_pool() + : descriptor_pool), + message_factory_(factory) {} GeneratedMessageReflection::~GeneratedMessageReflection() {} @@ -1026,6 +1007,11 @@ struct FieldNumberSorter { return left->number() < right->number(); } }; + +inline bool IsIndexInHasBitSet(const uint32* has_bit_set, uint32 index) { + return ((has_bit_set[index / 32] >> (index % 32)) & static_cast<uint32>(1)) + != 0; +} } // namespace void GeneratedMessageReflection::ListFields( @@ -1036,6 +1022,12 @@ void GeneratedMessageReflection::ListFields( // Optimization: The default instance never has any fields set. if (&message == default_instance_) return; + // Optimization: Avoid calling GetHasBits() and HasOneofField() many times + // within the field loop. + const uint32* const has_bits = GetHasBits(message); + const uint32* const oneof_case_array = reinterpret_cast<const uint32*>( + reinterpret_cast<const uint8*>(&message) + oneof_case_offset_); + output->reserve(descriptor_->field_count()); for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); @@ -1044,11 +1036,18 @@ void GeneratedMessageReflection::ListFields( output->push_back(field); } } else { - if (field->containing_oneof()) { - if (HasOneofField(message, field)) { + const OneofDescriptor* containing_oneof = field->containing_oneof(); + if (containing_oneof) { + // Equivalent to: HasOneofField(message, field) + if (oneof_case_array[containing_oneof->index()] == field->number()) { output->push_back(field); } - } else if (HasBit(message, field)) { + } else if (has_bits) { + // Equivalent to: HasBit(message, field) + if (IsIndexInHasBitSet(has_bits, i)) { + output->push_back(field); + } + } else if (HasBit(message, field)) { // Fall back on proto3-style HasBit. output->push_back(field); } } @@ -2001,12 +2000,7 @@ GeneratedMessageReflection::MutableInternalMetadataWithArena( inline bool GeneratedMessageReflection::GetIsDefaultInstance( const Message& message) const { - if (is_default_instance_offset_ == kHasNoDefaultInstanceField) { - return false; - } - const void* ptr = reinterpret_cast<const uint8*>(&message) + - is_default_instance_offset_; - return *reinterpret_cast<const bool*>(ptr); + return &message == default_instance_; } // Simple accessors for manipulating has_bits_. @@ -2063,8 +2057,7 @@ inline bool GeneratedMessageReflection::HasBit( } } } - return GetHasBits(message)[field->index() / 32] & - (1 << (field->index() % 32)); + return IsIndexInHasBitSet(GetHasBits(message), field->index()); } inline void GeneratedMessageReflection::SetBit( @@ -2072,7 +2065,9 @@ inline void GeneratedMessageReflection::SetBit( if (has_bits_offset_ == -1) { return; } - MutableHasBits(message)[field->index() / 32] |= (1 << (field->index() % 32)); + const uint32 index = static_cast<uint32>(field->index()); + MutableHasBits(message)[index / 32] |= + (static_cast<uint32>(1) << (index % 32)); } inline void GeneratedMessageReflection::ClearBit( @@ -2080,7 +2075,9 @@ inline void GeneratedMessageReflection::ClearBit( if (has_bits_offset_ == -1) { return; } - MutableHasBits(message)[field->index() / 32] &= ~(1 << (field->index() % 32)); + const uint32 index = static_cast<uint32>(field->index()); + MutableHasBits(message)[index / 32] &= + ~(static_cast<uint32>(1) << (index % 32)); } inline void GeneratedMessageReflection::SwapBit( @@ -2275,19 +2272,11 @@ GeneratedMessageReflection::NewGeneratedMessageReflection( int object_size, int arena_offset, int is_default_instance_offset) { - return new GeneratedMessageReflection(descriptor, - default_instance, - offsets, - has_bits_offset, - unknown_fields_offset, - extensions_offset, - default_oneof_instance, - oneof_case_offset, - DescriptorPool::generated_pool(), - MessageFactory::generated_factory(), - object_size, - arena_offset, - is_default_instance_offset); + return new GeneratedMessageReflection( + descriptor, default_instance, offsets, has_bits_offset, + unknown_fields_offset, extensions_offset, default_oneof_instance, + oneof_case_offset, DescriptorPool::generated_pool(), + MessageFactory::generated_factory(), object_size, arena_offset); } GeneratedMessageReflection* @@ -2301,17 +2290,11 @@ GeneratedMessageReflection::NewGeneratedMessageReflection( int object_size, int arena_offset, int is_default_instance_offset) { - return new GeneratedMessageReflection(descriptor, - default_instance, - offsets, - has_bits_offset, - unknown_fields_offset, - extensions_offset, - DescriptorPool::generated_pool(), - MessageFactory::generated_factory(), - object_size, - arena_offset, - is_default_instance_offset); + return new GeneratedMessageReflection( + descriptor, default_instance, offsets, has_bits_offset, + unknown_fields_offset, extensions_offset, + DescriptorPool::generated_pool(), MessageFactory::generated_factory(), + object_size, arena_offset); } } // namespace internal diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index 15fc802c..1413b110 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -132,15 +132,11 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { // by sizeof(). GeneratedMessageReflection(const Descriptor* descriptor, const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, + const int offsets[], int has_bits_offset, + int unknown_fields_offset, int extensions_offset, const DescriptorPool* pool, - MessageFactory* factory, - int object_size, - int arena_offset, - int is_default_instance_offset = -1); + MessageFactory* factory, int object_size, + int arena_offset); // Similar with the construction above. Call this construction if the // message has oneof definition. @@ -168,17 +164,12 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { // other parameters are the same with the construction above. GeneratedMessageReflection(const Descriptor* descriptor, const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, + const int offsets[], int has_bits_offset, + int unknown_fields_offset, int extensions_offset, const void* default_oneof_instance, - int oneof_case_offset, - const DescriptorPool* pool, - MessageFactory* factory, - int object_size, - int arena_offset, - int is_default_instance_offset = -1); + int oneof_case_offset, const DescriptorPool* pool, + MessageFactory* factory, int object_size, + int arena_offset); ~GeneratedMessageReflection(); // Shorter-to-call helpers for the above two constructions that work if the @@ -226,11 +217,11 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { Message* ReleaseLast(Message* message, const FieldDescriptor* field) const; void Swap(Message* message1, Message* message2) const; void SwapFields(Message* message1, Message* message2, - const vector<const FieldDescriptor*>& fields) const; + const std::vector<const FieldDescriptor*>& fields) const; void SwapElements(Message* message, const FieldDescriptor* field, int index1, int index2) const; void ListFields(const Message& message, - vector<const FieldDescriptor*>* output) const; + std::vector<const FieldDescriptor*>* output) const; int32 GetInt32 (const Message& message, const FieldDescriptor* field) const; @@ -448,11 +439,8 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { int unknown_fields_offset_; int extensions_offset_; int arena_offset_; - int is_default_instance_offset_; int object_size_; - static const int kHasNoDefaultInstanceField = -1; - const DescriptorPool* descriptor_pool_; MessageFactory* message_factory_; diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index 7ad6d61c..73f55927 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -48,15 +48,15 @@ double NaN() { return std::numeric_limits<double>::quiet_NaN(); } -const ::std::string* empty_string_; +ExplicitlyConstructed< ::std::string> fixed_address_empty_string; GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_); void DeleteEmptyString() { - delete empty_string_; + GetEmptyStringAlreadyInited().~string(); } void InitEmptyString() { - empty_string_ = new string; + fixed_address_empty_string.DefaultConstruct(); OnShutdown(&DeleteEmptyString); } diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h index 8967726e..871acca5 100644 --- a/src/google/protobuf/generated_message_util.h +++ b/src/google/protobuf/generated_message_util.h @@ -43,6 +43,7 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/once.h> +#include <google/protobuf/has_bits.h> namespace google { @@ -70,22 +71,49 @@ namespace internal { LIBPROTOBUF_EXPORT double Infinity(); LIBPROTOBUF_EXPORT double NaN(); +// This type is used to define a global variable, without it's constructor +// and destructor run on start and end of the program lifetime. This circumvents +// the initial construction order fiasco, while keeping the address of the +// empty string a compile time constant. +template <typename T> +class ExplicitlyConstructed { + public: + void DefaultConstruct() { + new (&union_) T(); + init_ = true; + } + + bool IsInitialized() { return init_; } + + const T& get() const { return reinterpret_cast<const T&>(union_); } + T* get_mutable() { return reinterpret_cast<T*>(&union_); } + + private: + // Prefer c++14 aligned_storage, but for compatibility this will do. + union AlignedUnion { + char space[sizeof(T)]; + int64 align_to_int64; + void* align_to_ptr; + } union_; + bool init_; // false by linker +}; + // TODO(jieluo): Change to template. We have tried to use template, // but it causes net/rpc/python:rpcutil_test fail (the empty string will // init twice). It may related to swig. Change to template after we // found the solution. -// Default empty string object. Don't use the pointer directly. Instead, call +// Default empty string object. Don't use this directly. Instead, call // GetEmptyString() to get the reference. -LIBPROTOBUF_EXPORT extern const ::std::string* empty_string_; +extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string; LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_; LIBPROTOBUF_EXPORT void InitEmptyString(); LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() { - assert(empty_string_ != NULL); - return *empty_string_; + return fixed_address_empty_string.get(); } + LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyString() { ::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString); return GetEmptyStringAlreadyInited(); @@ -106,20 +134,28 @@ template <class Type> bool AllAreInitialized(const Type& t) { return true; } -class ArenaString; - -// Read a length (varint32), followed by a string, from *input. Return a -// pointer to a copy of the string that resides in *arena. Requires both -// args to be non-NULL. If something goes wrong while reading the data -// then NULL is returned (e.g., input does not start with a valid varint). -LIBPROTOBUF_EXPORT ArenaString* ReadArenaString( - ::google::protobuf::io::CodedInputStream* input, - ::google::protobuf::Arena* arena); - // Helper function to crash on merge failure. // Moved out of generated code to reduce binary size. LIBPROTOBUF_EXPORT void MergeFromFail(const char* file, int line) GOOGLE_ATTRIBUTE_NORETURN; +// We compute sizes as size_t but cache them as int. This function converts a +// computed size to a cached size. Since we don't proceed with serialization if +// the total size was > INT_MAX, it is not important what this function returns +// for inputs > INT_MAX. +inline int ToCachedSize(size_t size) { + return static_cast<int>(size); +} + +// We mainly calculate sizes in terms of size_t, but some functions that compute +// sizes return "int". These int sizes are expected to always be positive. +// This function is more efficient than casting an int to size_t directly on +// 64-bit platforms because it avoids making the compiler emit a sign extending +// instruction, which we don't want and don't want to pay for. +inline size_t FromIntSize(int size) { + // Convert to unsigned before widening so sign extension is not necessary. + return static_cast<unsigned int>(size); +} + } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/has_bits.h b/src/google/protobuf/has_bits.h new file mode 100644 index 00000000..133bc02a --- /dev/null +++ b/src/google/protobuf/has_bits.h @@ -0,0 +1,72 @@ +// 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_HAS_BITS_H__ +#define GOOGLE_PROTOBUF_HAS_BITS_H__ + +#include <google/protobuf/stubs/common.h> + +namespace google { +namespace protobuf { +namespace internal { + +template<size_t doublewords> +class HasBits { + public: + HasBits() GOOGLE_ATTRIBUTE_ALWAYS_INLINE { Clear(); } + + void Clear() GOOGLE_ATTRIBUTE_ALWAYS_INLINE { + memset(has_bits_, 0, sizeof(has_bits_)); + } + + ::google::protobuf::uint32& operator[](int index) GOOGLE_ATTRIBUTE_ALWAYS_INLINE { + return has_bits_[index]; + } + + const ::google::protobuf::uint32& operator[](int index) const GOOGLE_ATTRIBUTE_ALWAYS_INLINE { + return has_bits_[index]; + } + + bool operator==(const HasBits<doublewords>& rhs) const { + return memcmp(has_bits_, rhs.has_bits_, sizeof(has_bits_)) == 0; + } + + bool operator!=(const HasBits<doublewords>& rhs) const { + return !(*this == rhs); + } + private: + ::google::protobuf::uint32 has_bits_[doublewords]; +}; + +} // namespace internal +} // namespace protobuf + +} // namespace google +#endif // GOOGLE_PROTOBUF_HAS_BITS_H__ diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc index a5675e79..08394ca7 100644 --- a/src/google/protobuf/io/coded_stream.cc +++ b/src/google/protobuf/io/coded_stream.cc @@ -47,6 +47,7 @@ #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/stl_util.h> +#include <google/protobuf/stubs/port.h> namespace google { @@ -902,46 +903,18 @@ bool CodedOutputStream::Refresh() { } } -int CodedOutputStream::VarintSize32Fallback(uint32 value) { +size_t CodedOutputStream::VarintSize32Fallback(uint32 value) { + GOOGLE_DCHECK_NE(0, value); // This is enforced by our caller. + + return 1 + Bits::Log2FloorNonZero(value) / 7; +} + +size_t CodedOutputStream::VarintSize64(uint64 value) { if (value < (1 << 7)) { return 1; - } else if (value < (1 << 14)) { - return 2; - } else if (value < (1 << 21)) { - return 3; - } else if (value < (1 << 28)) { - return 4; - } else { - return 5; } -} -int CodedOutputStream::VarintSize64(uint64 value) { - if (value < (1ull << 35)) { - if (value < (1ull << 7)) { - return 1; - } else if (value < (1ull << 14)) { - return 2; - } else if (value < (1ull << 21)) { - return 3; - } else if (value < (1ull << 28)) { - return 4; - } else { - return 5; - } - } else { - if (value < (1ull << 42)) { - return 6; - } else if (value < (1ull << 49)) { - return 7; - } else if (value < (1ull << 56)) { - return 8; - } else if (value < (1ull << 63)) { - return 9; - } else { - return 10; - } - } + return 1 + Bits::Log2FloorNonZero64(value) / 7; } uint8* CodedOutputStream::WriteStringWithSizeToArray(const string& str, diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index 316da765..1402cc17 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -784,17 +784,17 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { uint8* target); // Returns the number of bytes needed to encode the given value as a varint. - static int VarintSize32(uint32 value); + static size_t VarintSize32(uint32 value); // Returns the number of bytes needed to encode the given value as a varint. - static int VarintSize64(uint64 value); + static size_t VarintSize64(uint64 value); // If negative, 10 bytes. Otheriwse, same as VarintSize32(). - static int VarintSize32SignExtended(int32 value); + static size_t VarintSize32SignExtended(int32 value); // Compile-time equivalent of VarintSize32(). template <uint32 Value> struct StaticVarintSize32 { - static const int value = + static const size_t value = (Value < (1 << 7)) ? 1 : (Value < (1 << 14)) @@ -890,7 +890,7 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { GOOGLE_ATTRIBUTE_ALWAYS_INLINE static uint8* WriteVarint64ToArrayInline( uint64 value, uint8* target); - static int VarintSize32Fallback(uint32 value); + static size_t VarintSize32Fallback(uint32 value); // See above. Other projects may use "friend" to allow them to call this. static void SetDefaultSerializationDeterministic() { @@ -1225,7 +1225,7 @@ inline uint8* CodedOutputStream::WriteTagToArray( return WriteVarint32ToArray(value, target); } -inline int CodedOutputStream::VarintSize32(uint32 value) { +inline size_t CodedOutputStream::VarintSize32(uint32 value) { if (value < (1 << 7)) { return 1; } else { @@ -1233,7 +1233,7 @@ inline int CodedOutputStream::VarintSize32(uint32 value) { } } -inline int CodedOutputStream::VarintSize32SignExtended(int32 value) { +inline size_t CodedOutputStream::VarintSize32SignExtended(int32 value) { if (value < 0) { return 10; // TODO(kenton): Make this a symbolic constant. } else { diff --git a/src/google/protobuf/io/coded_stream_unittest.cc b/src/google/protobuf/io/coded_stream_unittest.cc index a8108e45..9f1ebc3f 100644 --- a/src/google/protobuf/io/coded_stream_unittest.cc +++ b/src/google/protobuf/io/coded_stream_unittest.cc @@ -58,6 +58,7 @@ #define ULL(x) GOOGLE_ULONGLONG(x) namespace google { + namespace protobuf { namespace io { namespace { diff --git a/src/google/protobuf/io/zero_copy_stream_impl.h b/src/google/protobuf/io/zero_copy_stream_impl.h index 0746fa6a..3365790e 100644 --- a/src/google/protobuf/io/zero_copy_stream_impl.h +++ b/src/google/protobuf/io/zero_copy_stream_impl.h @@ -218,7 +218,7 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { // If a block_size is given, it specifies the number of bytes that // should be read and returned with each call to Next(). Otherwise, // a reasonable default is used. - explicit IstreamInputStream(istream* stream, int block_size = -1); + explicit IstreamInputStream(std::istream* stream, int block_size = -1); ~IstreamInputStream(); // implements ZeroCopyInputStream ---------------------------------- @@ -230,7 +230,7 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { private: class LIBPROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream { public: - CopyingIstreamInputStream(istream* input); + CopyingIstreamInputStream(std::istream* input); ~CopyingIstreamInputStream(); // implements CopyingInputStream --------------------------------- @@ -239,7 +239,7 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { private: // The stream. - istream* input_; + std::istream* input_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingIstreamInputStream); }; @@ -262,7 +262,7 @@ class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream { // If a block_size is given, it specifies the size of the buffers // that should be returned by Next(). Otherwise, a reasonable default // is used. - explicit OstreamOutputStream(ostream* stream, int block_size = -1); + explicit OstreamOutputStream(std::ostream* stream, int block_size = -1); ~OstreamOutputStream(); // implements ZeroCopyOutputStream --------------------------------- @@ -273,7 +273,7 @@ class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream { private: class LIBPROTOBUF_EXPORT CopyingOstreamOutputStream : public CopyingOutputStream { public: - CopyingOstreamOutputStream(ostream* output); + CopyingOstreamOutputStream(std::ostream* output); ~CopyingOstreamOutputStream(); // implements CopyingOutputStream -------------------------------- @@ -281,7 +281,7 @@ class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream { private: // The stream. - ostream* output_; + std::ostream* output_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingOstreamOutputStream); }; diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index bfc63b0f..2d295510 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -565,7 +565,7 @@ class Map { void Init() { if (old_style_) deprecated_elements_ = Arena::Create<DeprecatedInnerMap>( - arena_, 0, hasher(), equal_to<Key>(), + arena_, 0, hasher(), std::equal_to<Key>(), MapAllocator<std::pair<const Key, MapPair<Key, T>*> >(arena_)); else elements_ = @@ -596,7 +596,7 @@ class Map { // If arena is not given, malloc needs to be called which doesn't // construct element object. if (arena_ == NULL) { - return reinterpret_cast<pointer>(malloc(n * sizeof(value_type))); + return static_cast<pointer>(::operator new(n * sizeof(value_type))); } else { return reinterpret_cast<pointer>( Arena::CreateArray<uint8>(arena_, n * sizeof(value_type))); @@ -605,7 +605,11 @@ class Map { void deallocate(pointer p, size_type n) { if (arena_ == NULL) { - free(p); +#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) + ::operator delete(p, n * sizeof(value_type)); +#else + ::operator delete(p); +#endif } } @@ -1351,7 +1355,7 @@ class Map { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(InnerMap); }; // end of class InnerMap - typedef hash_map<Key, value_type*, hash<Key>, equal_to<Key>, + typedef hash_map<Key, value_type*, hash<Key>, std::equal_to<Key>, MapAllocator<std::pair<const Key, MapPair<Key, T>*> > > DeprecatedInnerMap; diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h index e87eda64..abcd4529 100644 --- a/src/google/protobuf/map_entry.h +++ b/src/google/protobuf/map_entry.h @@ -158,8 +158,8 @@ class MapEntry : public MapEntryBase { return entry_lite_.MergePartialFromCodedStream(input); } - int ByteSize() const { - return entry_lite_.ByteSize(); + size_t ByteSizeLong() const { + return entry_lite_.ByteSizeLong(); } void SerializeWithCachedSizes(::google::protobuf::io::CodedOutputStream* output) const { diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h index 4dedfd57..3fb58220 100644 --- a/src/google/protobuf/map_entry_lite.h +++ b/src/google/protobuf/map_entry_lite.h @@ -119,7 +119,7 @@ class MapEntryLite : public MessageLite { kKeyFieldNumber, KeyTypeHandler::kWireType); static const uint8 kValueTag = GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG( kValueFieldNumber, ValueTypeHandler::kWireType); - static const int kTagSize = 1; + static const size_t kTagSize = 1; public: ~MapEntryLite() { @@ -201,8 +201,8 @@ class MapEntryLite : public MessageLite { } } - int ByteSize() const { - int size = 0; + size_t ByteSizeLong() const { + size_t size = 0; size += has_key() ? kTagSize + KeyTypeHandler::ByteSize(key()) : 0; size += has_value() ? kTagSize + ValueTypeHandler::ByteSize(value()) : 0; return size; diff --git a/src/google/protobuf/map_type_handler.h b/src/google/protobuf/map_type_handler.h index 685a770f..a21c92d9 100644 --- a/src/google/protobuf/map_type_handler.h +++ b/src/google/protobuf/map_type_handler.h @@ -158,7 +158,7 @@ class MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type> { MapWireFieldTypeTraits<WireFormatLite::TYPE_MESSAGE, Type>::kIsEnum; // Functions used in parsing and serialization. =================== - static inline int ByteSize(const MapEntryAccessorType& value); + static inline size_t ByteSize(const MapEntryAccessorType& value); static inline int GetCachedSize(const MapEntryAccessorType& value); static inline bool Read(io::CodedInputStream* input, MapEntryAccessorType* value); @@ -276,7 +276,7 @@ MAP_HANDLER(BOOL) #undef MAP_HANDLER template <typename Type> -inline int +inline size_t MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::ByteSize( const MapEntryAccessorType& value) { return WireFormatLite::MessageSizeNoVirtual(value); diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index f18077dd..c8de458c 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -46,9 +46,9 @@ #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/descriptor.pb.h> -#include <google/protobuf/map_field.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/generated_message_util.h> +#include <google/protobuf/map_field.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> #include <google/protobuf/stubs/strutil.h> @@ -146,9 +146,9 @@ void Message::SerializeWithCachedSizes( WireFormat::SerializeWithCachedSizes(*this, GetCachedSize(), output); } -int Message::ByteSize() const { - int size = WireFormat::ByteSize(*this); - SetCachedSize(size); +size_t Message::ByteSizeLong() const { + size_t size = WireFormat::ByteSize(*this); + SetCachedSize(internal::ToCachedSize(size)); return size; } @@ -299,8 +299,8 @@ class GeneratedMessageFactory : public MessageFactory { hash_map<const char*, RegistrationFunc*, hash<const char*>, streq> file_map_; - // Initialized lazily, so requires locking. Mutex mutex_; + // Initialized lazily, so requires locking. hash_map<const Descriptor*, const Message*> type_map_; }; diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index 9705e97e..bee25f77 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -271,10 +271,10 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite { bool ParsePartialFromFileDescriptor(int file_descriptor); // Parse a protocol buffer from a C++ istream. If successful, the entire // input will be consumed. - bool ParseFromIstream(istream* input); + bool ParseFromIstream(std::istream* input); // Like ParseFromIstream(), but accepts messages that are missing // required fields. - bool ParsePartialFromIstream(istream* input); + bool ParsePartialFromIstream(std::istream* input); // Serialize the message and write it to the given file descriptor. All // required fields must be set. @@ -283,9 +283,9 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite { bool SerializePartialToFileDescriptor(int file_descriptor) const; // Serialize the message and write it to the given C++ ostream. All // required fields must be set. - bool SerializeToOstream(ostream* output) const; + bool SerializeToOstream(std::ostream* output) const; // Like SerializeToOstream(), but allows missing required fields. - bool SerializePartialToOstream(ostream* output) const; + bool SerializePartialToOstream(std::ostream* output) const; // Reflection-based methods ---------------------------------------- @@ -297,7 +297,7 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite { virtual bool IsInitialized() const; virtual void CheckTypeAndMergeFrom(const MessageLite& other); virtual bool MergePartialFromCodedStream(io::CodedInputStream* input); - virtual int ByteSize() const; + virtual size_t ByteSizeLong() const; virtual void SerializeWithCachedSizes(io::CodedOutputStream* output) const; private: diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc index ba56db95..9d6da264 100644 --- a/src/google/protobuf/message_lite.cc +++ b/src/google/protobuf/message_lite.cc @@ -33,8 +33,9 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <google/protobuf/message_lite.h> #include <google/protobuf/arena.h> +#include <google/protobuf/generated_message_util.h> +#include <google/protobuf/message_lite.h> #include <google/protobuf/repeated_field.h> #include <string> #include <google/protobuf/stubs/logging.h> @@ -58,9 +59,9 @@ namespace { // protobuf implementation but is more likely caused by concurrent modification // of the message. This function attempts to distinguish between the two and // provide a useful error message. -void ByteSizeConsistencyError(int byte_size_before_serialization, - int byte_size_after_serialization, - int bytes_produced_by_serialization, +void ByteSizeConsistencyError(size_t byte_size_before_serialization, + size_t byte_size_after_serialization, + size_t bytes_produced_by_serialization, const MessageLite& message) { GOOGLE_CHECK_EQ(byte_size_before_serialization, byte_size_after_serialization) << message.GetTypeName() @@ -236,12 +237,15 @@ bool MessageLite::SerializeToCodedStream(io::CodedOutputStream* output) const { return SerializePartialToCodedStream(output); } +size_t MessageLite::ByteSizeLong() const { + return internal::FromIntSize(ByteSize()); +} + bool MessageLite::SerializePartialToCodedStream( io::CodedOutputStream* output) const { - const int size = ByteSize(); // Force size to be cached. - if (size < 0) { - // Messages >2G cannot be serialized due to overflow computing ByteSize. - GOOGLE_LOG(ERROR) << "Error computing ByteSize (possible overflow?)."; + const size_t size = ByteSizeLong(); // Force size to be cached. + if (size > INT_MAX) { + GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB."; return false; } @@ -249,7 +253,7 @@ bool MessageLite::SerializePartialToCodedStream( if (buffer != NULL) { uint8* end = SerializeWithCachedSizesToArray(buffer); if (end - buffer != size) { - ByteSizeConsistencyError(size, ByteSize(), end - buffer, *this); + ByteSizeConsistencyError(size, ByteSizeLong(), end - buffer, *this); } return true; } else { @@ -261,7 +265,7 @@ bool MessageLite::SerializePartialToCodedStream( int final_byte_count = output->ByteCount(); if (final_byte_count - original_byte_count != size) { - ByteSizeConsistencyError(size, ByteSize(), + ByteSizeConsistencyError(size, ByteSizeLong(), final_byte_count - original_byte_count, *this); } @@ -287,11 +291,10 @@ bool MessageLite::AppendToString(string* output) const { } bool MessageLite::AppendPartialToString(string* output) const { - int old_size = output->size(); - int byte_size = ByteSize(); - if (byte_size < 0) { - // Messages >2G cannot be serialized due to overflow computing ByteSize. - GOOGLE_LOG(ERROR) << "Error computing ByteSize (possible overflow?)."; + size_t old_size = output->size(); + size_t byte_size = ByteSizeLong(); + if (byte_size > INT_MAX) { + GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB."; return false; } @@ -300,7 +303,7 @@ bool MessageLite::AppendPartialToString(string* output) const { reinterpret_cast<uint8*>(io::mutable_string_data(output) + old_size); uint8* end = SerializeWithCachedSizesToArray(start); if (end - start != byte_size) { - ByteSizeConsistencyError(byte_size, ByteSize(), end - start, *this); + ByteSizeConsistencyError(byte_size, ByteSizeLong(), end - start, *this); } return true; } @@ -321,12 +324,12 @@ bool MessageLite::SerializeToArray(void* data, int size) const { } bool MessageLite::SerializePartialToArray(void* data, int size) const { - int byte_size = ByteSize(); + int byte_size = ByteSizeLong(); if (size < byte_size) return false; uint8* start = reinterpret_cast<uint8*>(data); uint8* end = SerializeWithCachedSizesToArray(start); if (end - start != byte_size) { - ByteSizeConsistencyError(byte_size, ByteSize(), end - start, *this); + ByteSizeConsistencyError(byte_size, ByteSizeLong(), end - start, *this); } return true; } diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index 2bdfe496..d3c3b1f0 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -239,12 +239,13 @@ class LIBPROTOBUF_EXPORT MessageLite { bool AppendPartialToString(string* output) const; // Computes the serialized size of the message. This recursively calls - // ByteSize() on all embedded messages. If a subclass does not override - // this, it MUST override SetCachedSize(). + // ByteSize() on all embedded messages. Subclasses MUST override either + // ByteSize() or ByteSizeLong() (overriding both is fine). // // ByteSize() is generally linear in the number of fields defined for the // proto. - virtual int ByteSize() const = 0; + virtual int ByteSize() const { return ByteSizeLong(); } + virtual size_t ByteSizeLong() const; // Serializes the message without recomputing the size. The message must // not have changed since the last call to ByteSize(); if it has, the results diff --git a/src/google/protobuf/message_unittest.cc b/src/google/protobuf/message_unittest.cc index d668a1a6..3af05808 100644 --- a/src/google/protobuf/message_unittest.cc +++ b/src/google/protobuf/message_unittest.cc @@ -265,6 +265,24 @@ TEST(MessageTest, CheckOverflow) { EXPECT_FALSE(message.AppendToCord(&serialized)); } +TEST(MessageTest, CheckBigOverflow) { + unittest::TestAllTypes message; + // Create a message with size just over 4GB. We should be able to detect this + // too, even though it will make a plain "int" wrap back to a positive number. + const string data(1024, 'x'); + Cord one_megabyte; + for (int i = 0; i < 1024; i++) { + one_megabyte.Append(data); + } + + for (int i = 0; i < 4 * 1024 + 1; ++i) { + message.add_repeated_cord()->CopyFrom(one_megabyte); + } + + Cord serialized; + EXPECT_FALSE(message.AppendToCord(&serialized)); +} + #endif // PROTOBUF_HAS_DEATH_TEST namespace { @@ -272,6 +290,12 @@ namespace { class NegativeByteSize : public unittest::TestRequired { public: virtual int ByteSize() const { return -1; } + + // The implementation of ByteSizeLong() from MessageLite, to simulate what + // would happen if TestRequired *hadn't* overridden it already. + virtual size_t ByteSizeLong() const { + return static_cast<unsigned int>(ByteSize()); + } }; } // namespace @@ -319,6 +343,18 @@ TEST(MessageTest, ParseFailsOnInvalidMessageEnd) { EXPECT_FALSE(message.ParseFromArray("\014", 1)); } +// Regression test for b/23630858 +TEST(MessageTest, MessageIsStillValidAfterParseFails) { + unittest::TestAllTypes message; + + // 9 0xFFs for the "optional_uint64" field. + string invalid_data = "\x20\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"; + + EXPECT_FALSE(message.ParseFromString(invalid_data)); + message.Clear(); + EXPECT_EQ(0, message.optional_uint64()); +} + namespace { void ExpectMessageMerged(const unittest::TestAllTypes& message) { diff --git a/src/google/protobuf/metadata.h b/src/google/protobuf/metadata.h index fdee150b..6e3eef63 100644 --- a/src/google/protobuf/metadata.h +++ b/src/google/protobuf/metadata.h @@ -152,10 +152,6 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena { } }; -// Temporary compatibility typedef. Remove once this is released in components -// and upb CL is submitted. -typedef InternalMetadataWithArena InternalMetadata; - } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/reflection.h b/src/google/protobuf/reflection.h index 2391f453..d5a6653c 100755 --- a/src/google/protobuf/reflection.h +++ b/src/google/protobuf/reflection.h @@ -80,6 +80,12 @@ class RepeatedFieldRef< typedef IteratorType iterator; typedef IteratorType const_iterator; + typedef T value_type; + typedef T& reference; + typedef const T& const_reference; + typedef int size_type; + typedef ptrdiff_t difference_type; + iterator begin() const { return iterator(data_, accessor_, true); } @@ -202,11 +208,18 @@ class RepeatedFieldRef< typedef IteratorType iterator; typedef IteratorType const_iterator; + typedef T value_type; + typedef T& reference; + typedef const T& const_reference; + typedef int size_type; + typedef ptrdiff_t difference_type; + iterator begin() const { return iterator(data_, accessor_, true, NewMessage()); } iterator end() const { - return iterator(data_, accessor_, false, NewMessage()); + // The end iterator must not be dereferenced, no need for scratch space. + return iterator(data_, accessor_, false, NULL); } private: @@ -428,13 +441,13 @@ class RepeatedFieldRefIterator public: // Constructor for non-message fields. RepeatedFieldRefIterator(const void* data, - const RepeatedFieldAccessor* accessor, - bool begin) - : data_(data), accessor_(accessor), - iterator_(begin ? accessor->BeginIterator(data) : - accessor->EndIterator(data)), - scratch_space_(new AccessorValueType) { - } + const RepeatedFieldAccessor* accessor, bool begin) + : data_(data), + accessor_(accessor), + iterator_(begin ? accessor->BeginIterator(data) + : accessor->EndIterator(data)), + // The end iterator must not be dereferenced, no need for scratch space. + scratch_space_(begin ? new AccessorValueType : NULL) {} // Constructor for message fields. RepeatedFieldRefIterator(const void* data, const RepeatedFieldAccessor* accessor, diff --git a/src/google/protobuf/reflection_ops.h b/src/google/protobuf/reflection_ops.h index 4775911e..45d8c650 100644 --- a/src/google/protobuf/reflection_ops.h +++ b/src/google/protobuf/reflection_ops.h @@ -67,7 +67,7 @@ class LIBPROTOBUF_EXPORT ReflectionOps { // the front of each name. static void FindInitializationErrors(const Message& message, const string& prefix, - vector<string>* errors); + std::vector<string>* errors); private: // All methods are static. No need to construct. diff --git a/src/google/protobuf/repeated_field.cc b/src/google/protobuf/repeated_field.cc index 77004f59..5ca964c1 100644 --- a/src/google/protobuf/repeated_field.cc +++ b/src/google/protobuf/repeated_field.cc @@ -58,14 +58,16 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) { (std::numeric_limits<size_t>::max() - kRepHeaderSize) / sizeof(old_rep->elements[0])) << "Requested size is too large to fit into size_t."; + size_t bytes = kRepHeaderSize + sizeof(old_rep->elements[0]) * new_size; if (arena == NULL) { - rep_ = reinterpret_cast<Rep*>( - new char[kRepHeaderSize + sizeof(old_rep->elements[0]) * new_size]); + rep_ = reinterpret_cast<Rep*>(::operator new(bytes)); } else { rep_ = reinterpret_cast<Rep*>( - ::google::protobuf::Arena::CreateArray<char>(arena, - kRepHeaderSize + sizeof(old_rep->elements[0]) * new_size)); + ::google::protobuf::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, @@ -75,7 +77,13 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) { rep_->allocated_size = 0; } if (arena == NULL) { - delete [] reinterpret_cast<char*>(old_rep); +#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 } return &rep_->elements[current_size_]; } diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index bc567555..0a41495f 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -120,6 +120,10 @@ class RepeatedField { const Element& Get(int index) const; Element* Mutable(int index); + + const Element& operator[](int index) const { return Get(index); } + Element& operator[](int index) { return *Mutable(index); } + void Set(int index, const Element& value); void Add(const Element& value); Element* Add(); @@ -134,6 +138,7 @@ class RepeatedField { void Clear(); void MergeFrom(const RepeatedField& other); + void UnsafeMergeFrom(const RepeatedField& other); void CopyFrom(const RepeatedField& other); // Reserve space to expand the field to at least the given size. If the @@ -284,7 +289,12 @@ class RepeatedField { e->Element::~Element(); } if (rep->arena == NULL) { - delete[] reinterpret_cast<char*>(rep); +#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 } } } @@ -742,6 +752,9 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase { Element* Mutable(int index); Element* Add(); + const Element& operator[](int index) const { return Get(index); } + Element& operator[](int index) { return *Mutable(index); } + // Remove the last element in the array. // Ownership of the element is retained by the array. void RemoveLast(); @@ -753,6 +766,7 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase { void Clear(); void MergeFrom(const RepeatedPtrField& other); + void UnsafeMergeFrom(const RepeatedPtrField& other) { MergeFrom(other); } void CopyFrom(const RepeatedPtrField& other); // Reserve space to expand the field to at least the given size. This only @@ -1138,8 +1152,7 @@ inline void RepeatedField<Element>::Clear() { } template <typename Element> -inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) { - GOOGLE_CHECK_NE(&other, this); +inline void RepeatedField<Element>::UnsafeMergeFrom(const RepeatedField& other) { if (other.current_size_ != 0) { Reserve(current_size_ + other.current_size_); CopyArray(rep_->elements + current_size_, @@ -1149,6 +1162,12 @@ inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) { } template <typename Element> +inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) { + GOOGLE_CHECK_NE(&other, this); + UnsafeMergeFrom(other); +} + +template <typename Element> inline void RepeatedField<Element>::CopyFrom(const RepeatedField& other) { if (&other == this) return; Clear(); @@ -1265,13 +1284,12 @@ void RepeatedField<Element>::Reserve(int new_size) { (std::numeric_limits<size_t>::max() - kRepHeaderSize) / sizeof(Element)) << "Requested size is too large to fit into size_t."; + size_t bytes = kRepHeaderSize + sizeof(Element) * new_size; if (arena == NULL) { - rep_ = reinterpret_cast<Rep*>( - new char[kRepHeaderSize + sizeof(Element) * new_size]); + rep_ = static_cast<Rep*>(::operator new(bytes)); } else { rep_ = reinterpret_cast<Rep*>( - ::google::protobuf::Arena::CreateArray<char>(arena, - kRepHeaderSize + sizeof(Element) * new_size)); + ::google::protobuf::Arena::CreateArray<char>(arena, bytes)); } rep_->arena = arena; int old_total_size = total_size_; @@ -1363,7 +1381,12 @@ void RepeatedPtrFieldBase::Destroy() { for (int i = 0; i < n; i++) { TypeHandler::Delete(cast<TypeHandler>(elements[i]), NULL); } - delete[] reinterpret_cast<char*>(rep_); +#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_ = NULL; } diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc index 39b24b33..33547146 100644 --- a/src/google/protobuf/repeated_field_unittest.cc +++ b/src/google/protobuf/repeated_field_unittest.cc @@ -95,7 +95,7 @@ TEST(RepeatedField, Small) { EXPECT_EQ(field.size(), 0); // Additional bytes are for 'struct Rep' header. int expected_usage = 4 * sizeof(int) + sizeof(Arena*); - EXPECT_EQ(field.SpaceUsedExcludingSelf(), expected_usage); + EXPECT_GE(field.SpaceUsedExcludingSelf(), expected_usage); } @@ -207,7 +207,7 @@ TEST(RepeatedField, ReserveMoreThanDouble) { RepeatedField<int> field; field.Reserve(20); - EXPECT_EQ(20, ReservedSpace(&field)); + EXPECT_LE(20, ReservedSpace(&field)); } TEST(RepeatedField, ReserveLessThanDouble) { @@ -215,9 +215,10 @@ TEST(RepeatedField, ReserveLessThanDouble) { // field to grow by double instead. RepeatedField<int> field; field.Reserve(20); - field.Reserve(30); + int capacity = field.Capacity(); + field.Reserve(capacity * 1.5); - EXPECT_EQ(40, ReservedSpace(&field)); + EXPECT_LE(2 * capacity, ReservedSpace(&field)); } TEST(RepeatedField, ReserveLessThanExisting) { @@ -229,7 +230,7 @@ TEST(RepeatedField, ReserveLessThanExisting) { field.Reserve(10); EXPECT_EQ(previous_ptr, field.data()); - EXPECT_EQ(20, ReservedSpace(&field)); + EXPECT_LE(20, ReservedSpace(&field)); } TEST(RepeatedField, Resize) { @@ -397,6 +398,16 @@ TEST(RepeatedField, MutableDataIsMutable) { EXPECT_EQ(2, field.Get(0)); } +TEST(RepeatedField, SubscriptOperators) { + RepeatedField<int> field; + field.Add(1); + EXPECT_EQ(1, field.Get(0)); + EXPECT_EQ(1, field[0]); + EXPECT_EQ(field.Mutable(0), &field[0]); + const RepeatedField<int>& const_field = field; + EXPECT_EQ(field.data(), &const_field[0]); +} + TEST(RepeatedField, Truncate) { RepeatedField<int> field; @@ -470,11 +481,11 @@ TEST(RepeatedField, ClearThenReserveMore) { EXPECT_EQ(32, field.size()); field.Clear(); EXPECT_EQ(0, field.size()); - EXPECT_EQ(32, field.Capacity()); + EXPECT_LE(32, field.Capacity()); field.Reserve(1024); EXPECT_EQ(0, field.size()); - EXPECT_EQ(1024, field.Capacity()); + EXPECT_LE(1024, field.Capacity()); // Finish test -- |field| should destroy the cleared-but-not-yet-destroyed // strings. } @@ -629,15 +640,18 @@ TEST(RepeatedPtrField, ReserveMoreThanDouble) { RepeatedPtrField<string> field; field.Reserve(20); - EXPECT_EQ(20, ReservedSpace(&field)); + EXPECT_LE(20, ReservedSpace(&field)); } TEST(RepeatedPtrField, ReserveLessThanDouble) { RepeatedPtrField<string> field; field.Reserve(20); - field.Reserve(30); - EXPECT_EQ(40, ReservedSpace(&field)); + int capacity = field.Capacity(); + // Grow by 1.5x + field.Reserve(capacity + (capacity >> 2)); + + EXPECT_LE(2 * capacity, ReservedSpace(&field)); } TEST(RepeatedPtrField, ReserveLessThanExisting) { @@ -647,7 +661,7 @@ TEST(RepeatedPtrField, ReserveLessThanExisting) { field.Reserve(10); EXPECT_EQ(previous_ptr, field.data()); - EXPECT_EQ(20, ReservedSpace(&field)); + EXPECT_LE(20, ReservedSpace(&field)); } TEST(RepeatedPtrField, ReserveDoesntLoseAllocated) { @@ -918,6 +932,16 @@ TEST(RepeatedPtrField, MutableDataIsMutable) { EXPECT_EQ("2", field.Get(0)); } +TEST(RepeatedPtrField, SubscriptOperators) { + RepeatedPtrField<string> field; + *field.Add() = "1"; + EXPECT_EQ("1", field.Get(0)); + EXPECT_EQ("1", field[0]); + EXPECT_EQ(field.Mutable(0), &field[0]); + const RepeatedPtrField<string>& const_field = field; + EXPECT_EQ(*field.data(), &const_field[0]); +} + TEST(RepeatedPtrField, ExtractSubrange) { // Exhaustively test every subrange in arrays of all sizes from 0 through 9 // with 0 through 3 cleared elements at the end. diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index 019ccf15..195a5d49 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -43,20 +43,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() { SourceContext_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( SourceContext_descriptor_, - SourceContext::default_instance_, + SourceContext::internal_default_instance(), SourceContext_offsets_, -1, -1, -1, sizeof(SourceContext), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _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_2fsource_5fcontext_2eproto); } @@ -65,36 +64,48 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceContext_descriptor_, &SourceContext::default_instance()); + SourceContext_descriptor_, SourceContext::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto() { - delete SourceContext::default_instance_; delete SourceContext_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::internal::GetEmptyString(); + SourceContext::default_instance_.DefaultConstruct(); + SourceContext::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n$google/protobuf/source_context.proto\022\017" "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile" - "_name\030\001 \001(\tBU\n\023com.google.protobufB\022Sour" - "ceContextProtoP\001\240\001\001\242\002\003GPB\252\002\036Google.Proto" - "buf.WellKnownTypesb\006proto3", 186); + "_name\030\001 \001(\tBR\n\023com.google.protobufB\022Sour" + "ceContextProtoP\001\242\002\003GPB\252\002\036Google.Protobuf" + ".WellKnownTypesb\006proto3", 183); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/source_context.proto", &protobuf_RegisterTypes); - SourceContext::default_instance_ = new SourceContext(); - SourceContext::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto() { @@ -102,6 +113,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto } } static_descriptor_initializer_google_2fprotobuf_2fsource_5fcontext_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 @@ -110,27 +131,25 @@ const int SourceContext::kFileNameFieldNumber; SourceContext::SourceContext() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.SourceContext) } void SourceContext::InitAsDefaultInstance() { - _is_default_instance_ = true; } SourceContext::SourceContext(const SourceContext& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext) } void SourceContext::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; file_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + _cached_size_ = 0; } SourceContext::~SourceContext() { @@ -140,8 +159,6 @@ SourceContext::~SourceContext() { void SourceContext::SharedDtor() { file_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void SourceContext::SetCachedSize(int size) const { @@ -155,11 +172,11 @@ const ::google::protobuf::Descriptor* SourceContext::descriptor() { } const SourceContext& SourceContext::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); + return *internal_default_instance(); } -SourceContext* SourceContext::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<SourceContext> SourceContext::default_instance_; SourceContext* SourceContext::New(::google::protobuf::Arena* arena) const { SourceContext* n = new SourceContext; @@ -256,9 +273,9 @@ void SourceContext::SerializeWithCachedSizes( return target; } -int SourceContext::ByteSize() const { +size_t SourceContext::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceContext) - int total_size = 0; + size_t total_size = 0; // optional string file_name = 1; if (this->file_name().size() > 0) { @@ -267,18 +284,17 @@ int SourceContext::ByteSize() const { this->file_name()); } + 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 SourceContext::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceContext) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const SourceContext* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const SourceContext* source = ::google::protobuf::internal::DynamicCastToGenerated<const SourceContext>( &from); if (source == NULL) { @@ -286,15 +302,21 @@ void SourceContext::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceContext) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void SourceContext::MergeFrom(const SourceContext& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceContext) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void SourceContext::UnsafeMergeFrom(const SourceContext& from) { + GOOGLE_DCHECK(&from != this); if (from.file_name().size() > 0) { file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_); @@ -312,7 +334,7 @@ void SourceContext::CopyFrom(const SourceContext& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceContext) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool SourceContext::IsInitialized() const { @@ -345,37 +367,37 @@ void SourceContext::InternalSwap(SourceContext* other) { void SourceContext::clear_file_name() { file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& SourceContext::file_name() const { +const ::std::string& SourceContext::file_name() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name) return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void SourceContext::set_file_name(const ::std::string& value) { +void SourceContext::set_file_name(const ::std::string& value) { file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name) } - void SourceContext::set_file_name(const char* value) { +void SourceContext::set_file_name(const char* value) { file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceContext.file_name) } - void SourceContext::set_file_name(const char* value, size_t size) { +void SourceContext::set_file_name(const char* value, size_t size) { file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceContext.file_name) } - ::std::string* SourceContext::mutable_file_name() { +::std::string* SourceContext::mutable_file_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.SourceContext.file_name) return file_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* SourceContext::release_file_name() { +::std::string* SourceContext::release_file_name() { // @@protoc_insertion_point(field_release:google.protobuf.SourceContext.file_name) return file_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void SourceContext::set_allocated_file_name(::std::string* file_name) { +void SourceContext::set_allocated_file_name(::std::string* file_name) { if (file_name != NULL) { } else { diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 341a4534..3dac5215 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -34,6 +34,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto(); @@ -56,6 +57,10 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ static const ::google::protobuf::Descriptor* descriptor(); static const SourceContext& default_instance(); + static inline const SourceContext* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(SourceContext* other); // implements Message ---------------------------------------------- @@ -70,7 +75,7 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -86,6 +91,7 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(SourceContext* other); + void UnsafeMergeFrom(const SourceContext& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -116,15 +122,15 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; ::google::protobuf::internal::ArenaStringPtr file_name_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto(); void InitAsDefaultInstance(); - static SourceContext* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/source_context.proto b/src/google/protobuf/source_context.proto index a2c08e2b..79137ce8 100644 --- a/src/google/protobuf/source_context.proto +++ b/src/google/protobuf/source_context.proto @@ -36,7 +36,6 @@ option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option java_package = "com.google.protobuf"; option java_outer_classname = "SourceContextProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; // `SourceContext` represents information about the source of a 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> 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<Struct>(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<string, .google.protobuf.Value> fields = 1; - total_size += 1 * this->fields_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->fields_size()); { ::google::protobuf::scoped_ptr<Struct_FieldsEntry> 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<const Struct>( &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> 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<Value>(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<const Value>( &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<const char*>(value), size)); + kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(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,7 +1364,9 @@ 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_; @@ -1241,6 +1375,42 @@ void Value::clear_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_; kind_.struct_value_ = NULL; return temp; @@ -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,7 +1452,9 @@ 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_; @@ -1289,6 +1463,42 @@ void Value::clear_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_; kind_.list_value_ = NULL; return temp; @@ -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> 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<ListValue>(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<const ListValue>( &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) { diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index b085b849..536fe4fb 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -37,6 +37,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); @@ -78,9 +79,18 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc return *this; } + inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } + inline void* GetMaybeArenaPointer() const { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const Struct& default_instance(); + static inline const Struct* internal_default_instance() { + return &default_instance_.get(); + } + + void UnsafeArenaSwap(Struct* other); void Swap(Struct* other); // implements Message ---------------------------------------------- @@ -95,7 +105,7 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -111,6 +121,12 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Struct* other); + void UnsafeMergeFrom(const Struct& from); + protected: + explicit Struct(::google::protobuf::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -140,7 +156,9 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; + friend class ::google::protobuf::Arena; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; typedef ::google::protobuf::internal::MapEntryLite< ::std::string, ::google::protobuf::Value, ::google::protobuf::internal::WireFormatLite::TYPE_STRING, @@ -153,12 +171,13 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > fields_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); void InitAsDefaultInstance(); - static Struct* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Struct> default_instance_; }; // ------------------------------------------------------------------- @@ -174,6 +193,10 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ return *this; } + inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } + inline void* GetMaybeArenaPointer() const { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const Value& default_instance(); @@ -187,6 +210,11 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ KIND_NOT_SET = 0, }; + static inline const Value* internal_default_instance() { + return &default_instance_.get(); + } + + void UnsafeArenaSwap(Value* other); void Swap(Value* other); // implements Message ---------------------------------------------- @@ -201,7 +229,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -217,6 +245,12 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Value* other); + void UnsafeMergeFrom(const Value& from); + protected: + explicit Value(::google::protobuf::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -263,6 +297,9 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ ::std::string* mutable_string_value(); ::std::string* release_string_value(); void set_allocated_string_value(::std::string* string_value); + ::std::string* unsafe_arena_release_string_value(); + void unsafe_arena_set_allocated_string_value( + ::std::string* string_value); // optional bool bool_value = 4; private: @@ -277,19 +314,37 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ bool has_struct_value() const; void clear_struct_value(); static const int kStructValueFieldNumber = 5; + private: + void _slow_mutable_struct_value(); + void _slow_set_allocated_struct_value( + ::google::protobuf::Arena* message_arena, ::google::protobuf::Struct** struct_value); + ::google::protobuf::Struct* _slow_release_struct_value(); + public: const ::google::protobuf::Struct& struct_value() const; ::google::protobuf::Struct* mutable_struct_value(); ::google::protobuf::Struct* release_struct_value(); void set_allocated_struct_value(::google::protobuf::Struct* struct_value); + ::google::protobuf::Struct* unsafe_arena_release_struct_value(); + void unsafe_arena_set_allocated_struct_value( + ::google::protobuf::Struct* struct_value); // optional .google.protobuf.ListValue list_value = 6; bool has_list_value() const; void clear_list_value(); static const int kListValueFieldNumber = 6; + private: + void _slow_mutable_list_value(); + void _slow_set_allocated_list_value( + ::google::protobuf::Arena* message_arena, ::google::protobuf::ListValue** list_value); + ::google::protobuf::ListValue* _slow_release_list_value(); + public: const ::google::protobuf::ListValue& list_value() const; ::google::protobuf::ListValue* mutable_list_value(); ::google::protobuf::ListValue* release_list_value(); void set_allocated_list_value(::google::protobuf::ListValue* list_value); + ::google::protobuf::ListValue* unsafe_arena_release_list_value(); + void unsafe_arena_set_allocated_list_value( + ::google::protobuf::ListValue* list_value); KindCase kind_case() const; // @@protoc_insertion_point(class_scope:google.protobuf.Value) @@ -306,7 +361,9 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ inline void clear_has_kind(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; + friend class ::google::protobuf::Arena; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; union KindUnion { KindUnion() {} int null_value_; @@ -319,12 +376,13 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ mutable int _cached_size_; ::google::protobuf::uint32 _oneof_case_[1]; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); void InitAsDefaultInstance(); - static Value* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Value> default_instance_; }; // ------------------------------------------------------------------- @@ -340,9 +398,18 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro return *this; } + inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } + inline void* GetMaybeArenaPointer() const { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const ListValue& default_instance(); + static inline const ListValue* internal_default_instance() { + return &default_instance_.get(); + } + + void UnsafeArenaSwap(ListValue* other); void Swap(ListValue* other); // implements Message ---------------------------------------------- @@ -357,7 +424,7 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -373,6 +440,12 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(ListValue* other); + void UnsafeMergeFrom(const ListValue& from); + protected: + explicit ListValue(::google::protobuf::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -404,15 +477,18 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; + friend class ::google::protobuf::Arena; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value > values_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); void InitAsDefaultInstance(); - static ListValue* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<ListValue> default_instance_; }; // =================================================================== @@ -511,25 +587,26 @@ inline void Value::set_has_string_value() { } inline 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(); } } inline 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(); } inline void Value::set_string_value(const ::std::string& value) { - // @@protoc_insertion_point(field_set:google.protobuf.Value.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) } inline void Value::set_string_value(const char* value) { @@ -538,18 +615,20 @@ inline void Value::set_string_value(const char* value) { 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) } -inline void Value::set_string_value(const char* value, size_t size) { +inline 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<const char*>(value), size)); + kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value) } inline ::std::string* Value::mutable_string_value() { @@ -558,14 +637,27 @@ inline ::std::string* Value::mutable_string_value() { 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()); } inline ::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; + } +} +inline ::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; } @@ -577,11 +669,23 @@ inline void Value::set_allocated_string_value(::std::string* string_value) { 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) } +inline 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; inline bool Value::has_bool_value() const { @@ -621,7 +725,9 @@ inline void Value::set_has_struct_value() { } inline void Value::clear_struct_value() { if (has_struct_value()) { - delete kind_.struct_value_; + if (GetArenaNoVirtual() == NULL) { + delete kind_.struct_value_; + } clear_has_kind(); } } @@ -635,7 +741,9 @@ inline ::google::protobuf::Struct* Value::mutable_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_; @@ -644,6 +752,42 @@ inline ::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; + } +} +inline 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) +} +inline ::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_; kind_.struct_value_ = NULL; return temp; @@ -651,13 +795,13 @@ inline ::google::protobuf::Struct* Value::release_struct_value() { return NULL; } } -inline void Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value) { +inline 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; @@ -669,7 +813,9 @@ inline void Value::set_has_list_value() { } inline void Value::clear_list_value() { if (has_list_value()) { - delete kind_.list_value_; + if (GetArenaNoVirtual() == NULL) { + delete kind_.list_value_; + } clear_has_kind(); } } @@ -683,7 +829,9 @@ inline ::google::protobuf::ListValue* Value::mutable_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_; @@ -692,6 +840,42 @@ inline ::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; + } +} +inline 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) +} +inline ::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_; kind_.list_value_ = NULL; return temp; @@ -699,13 +883,13 @@ inline ::google::protobuf::ListValue* Value::release_list_value() { return NULL; } } -inline void Value::set_allocated_list_value(::google::protobuf::ListValue* list_value) { +inline 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) } inline bool Value::has_kind() const { diff --git a/src/google/protobuf/struct.proto b/src/google/protobuf/struct.proto index beeba811..7d7808e7 100644 --- a/src/google/protobuf/struct.proto +++ b/src/google/protobuf/struct.proto @@ -33,11 +33,11 @@ syntax = "proto3"; package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option cc_enable_arenas = true; option go_package = "github.com/golang/protobuf/ptypes/struct;structpb"; option java_package = "com.google.protobuf"; option java_outer_classname = "StructProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index d7f93b4c..376be5f7 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -327,6 +327,61 @@ static inline uint64 bswap_64(uint64 x) { #endif // =================================================================== +// from google3/util/bits/bits.h + +class Bits { + public: + static uint32 Log2FloorNonZero(uint32 n) { +#if defined(__GNUC__) + return 31 ^ __builtin_clz(n); +#elif defined(COMPILER_MSVC) && defined(_M_IX86) + _asm { + bsr ebx, n + mov n, ebx + } + return n; +#else + return Log2FloorNonZero_Portable(n); +#endif + } + + static uint64 Log2FloorNonZero64(uint64 n) { +#if defined(__GNUC__) + return 63 ^ __builtin_clzll(n); +#else + return Log2FloorNonZero64_Portable(n); +#endif + } + private: + static int Log2FloorNonZero_Portable(uint32 n) { + if (n == 0) + return -1; + int log = 0; + uint32 value = n; + for (int i = 4; i >= 0; --i) { + int shift = (1 << i); + uint32 x = value >> shift; + if (x != 0) { + value = x; + log += shift; + } + } + assert(value == 1); + return log; + } + + static int Log2FloorNonZero64_Portable(uint64 n) { + const uint32 topbits = static_cast<uint32>(n >> 32); + if (topbits == 0) { + // Top bits are zero, so scan in bottom bits + return Log2FloorNonZero(static_cast<uint32>(n)); + } else { + return 32 + Log2FloorNonZero(topbits); + } + } +}; + +// =================================================================== // from google3/util/endian/endian.h LIBPROTOBUF_EXPORT uint32 ghtonl(uint32 x); diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index 7ba92e8f..4fa8e99f 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -93,6 +93,21 @@ void StripString(string* s, const char* remove, char replacewith) { } } +// ---------------------------------------------------------------------- +// ReplaceCharacters +// Replaces any occurrence of the character 'remove' (or the characters +// in 'remove') with the character 'replacewith'. +// ---------------------------------------------------------------------- +void ReplaceCharacters(string *s, const char *remove, char replacewith) { + const char *str_start = s->c_str(); + const char *str = str_start; + for (str = strpbrk(str, remove); + str != NULL; + str = strpbrk(str + 1, remove)) { + (*s)[str - str_start] = replacewith; + } +} + void StripWhitespace(string* str) { int str_length = str->length(); diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h index 8bdd6110..df28c94d 100644 --- a/src/google/protobuf/stubs/strutil.h +++ b/src/google/protobuf/stubs/strutil.h @@ -147,7 +147,7 @@ inline string StripSuffixString(const string& str, const string& suffix) { } // ---------------------------------------------------------------------- -// StripString +// ReplaceCharacters // Replaces any occurrence of the character 'remove' (or the characters // in 'remove') with the character 'replacewith'. // Good for keeping html characters or protocol characters (\t) out @@ -155,6 +155,8 @@ inline string StripSuffixString(const string& str, const string& suffix) { // StripWhitespace // Removes whitespaces from both ends of the given string. // ---------------------------------------------------------------------- +LIBPROTOBUF_EXPORT void ReplaceCharacters(string* s, const char* remove, + char replacewith); LIBPROTOBUF_EXPORT void StripString(string* s, const char* remove, char replacewith); diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index 66b2648b..5192eca9 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc @@ -393,6 +393,16 @@ class TextFormat::Parser::ParserImpl { DO(ConsumeAnyValue(full_type_name, message->GetDescriptor()->file()->pool(), &serialized_value)); + if (singular_overwrite_policy_ == FORBID_SINGULAR_OVERWRITES) { + // Fail if any_type_url_field has already been specified. + if ((!any_type_url_field->is_repeated() && + reflection->HasField(*message, any_type_url_field)) || + (!any_value_field->is_repeated() && + reflection->HasField(*message, any_value_field))) { + ReportError("Non-repeated Any specified multiple times."); + return false; + } + } reflection->SetString( message, any_type_url_field, string(prefix + full_type_name)); @@ -515,18 +525,21 @@ class TextFormat::Parser::ParserImpl { } if (field->is_repeated() && TryConsume("[")) { - // Short repeated format, e.g. "foo: [1, 2, 3]" - while (true) { - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - // Perform special handling for embedded message types. - DO(ConsumeFieldMessage(message, reflection, field)); - } else { - DO(ConsumeFieldValue(message, reflection, field)); - } - if (TryConsume("]")) { - break; + // Short repeated format, e.g. "foo: [1, 2, 3]". + if (!TryConsume("]")) { + // "foo: []" is treated as empty. + while (true) { + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + // Perform special handling for embedded message types. + DO(ConsumeFieldMessage(message, reflection, field)); + } else { + DO(ConsumeFieldValue(message, reflection, field)); + } + if (TryConsume("]")) { + break; + } + DO(Consume(",")); } - DO(Consume(",")); } } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { DO(ConsumeFieldMessage(message, reflection, field)); diff --git a/src/google/protobuf/text_format.h b/src/google/protobuf/text_format.h index ef3d4a8f..2873d339 100644 --- a/src/google/protobuf/text_format.h +++ b/src/google/protobuf/text_format.h @@ -75,6 +75,8 @@ class LIBPROTOBUF_EXPORT TextFormat { io::ZeroCopyOutputStream* output); // Like Print(), but outputs directly to a string. + // Note: output will be cleared before prior to printing, and will + // be left empty even if printing fails. static bool PrintToString(const Message& message, string* output); // Like PrintUnknownFields(), but outputs directly to a string. @@ -301,8 +303,8 @@ class LIBPROTOBUF_EXPORT TextFormat { int64 truncate_string_field_longer_than_; google::protobuf::scoped_ptr<const FieldValuePrinter> default_field_value_printer_; - typedef map<const FieldDescriptor*, - const FieldValuePrinter*> CustomPrinterMap; + typedef std::map<const FieldDescriptor*, + const FieldValuePrinter*> CustomPrinterMap; CustomPrinterMap custom_printers_; }; @@ -391,11 +393,13 @@ class LIBPROTOBUF_EXPORT TextFormat { ParseInfoTree* CreateNested(const FieldDescriptor* field); // Defines the map from the index-th field descriptor to its parse location. - typedef map<const FieldDescriptor*, vector<ParseLocation> > LocationMap; + typedef std::map<const FieldDescriptor*, + std::vector<ParseLocation> > LocationMap; // Defines the map from the index-th field descriptor to the nested parse // info tree. - typedef map<const FieldDescriptor*, vector<ParseInfoTree*> > NestedMap; + typedef std::map<const FieldDescriptor*, + std::vector<ParseInfoTree*> > NestedMap; LocationMap locations_; NestedMap nested_; diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc index c9521cc3..2f1bd455 100644 --- a/src/google/protobuf/text_format_unittest.cc +++ b/src/google/protobuf/text_format_unittest.cc @@ -157,7 +157,21 @@ TEST_F(TextFormatTest, ShortPrimitiveRepeateds) { TextFormat::Printer printer; printer.SetUseShortRepeatedPrimitives(true); string text; - printer.PrintToString(proto_, &text); + EXPECT_TRUE(printer.PrintToString(proto_, &text)); + + EXPECT_EQ("optional_int32: 123\n" + "repeated_int32: [456, 789]\n" + "repeated_string: \"foo\"\n" + "repeated_string: \"bar\"\n" + "repeated_nested_message {\n bb: 2\n}\n" + "repeated_nested_message {\n bb: 3\n}\n" + "repeated_nested_enum: [FOO, BAR]\n", + text); + + // Verify that any existing data in the string is cleared when + // PrintToString() is called. + text = "just some data here...\n\nblah blah"; + EXPECT_TRUE(printer.PrintToString(proto_, &text)); EXPECT_EQ("optional_int32: 123\n" "repeated_int32: [456, 789]\n" @@ -170,7 +184,7 @@ TEST_F(TextFormatTest, ShortPrimitiveRepeateds) { // Try in single-line mode. printer.SetSingleLineMode(true); - printer.PrintToString(proto_, &text); + EXPECT_TRUE(printer.PrintToString(proto_, &text)); EXPECT_EQ("optional_int32: 123 " "repeated_int32: [456, 789] " @@ -659,6 +673,87 @@ TEST_F(TextFormatTest, ParseShortRepeatedForm) { EXPECT_EQ(4, proto_.repeatedgroup(1).a()); } +TEST_F(TextFormatTest, ParseShortRepeatedWithTrailingComma) { + string parse_string = "repeated_int32: [456,]\n"; + ASSERT_FALSE(TextFormat::ParseFromString(parse_string, &proto_)); + parse_string = "repeated_nested_enum: [ FOO , ]"; + ASSERT_FALSE(TextFormat::ParseFromString(parse_string, &proto_)); + parse_string = "repeated_string: [ \"foo\", ]"; + ASSERT_FALSE(TextFormat::ParseFromString(parse_string, &proto_)); + parse_string = "repeated_nested_message: [ { bb: 1 }, ]"; + ASSERT_FALSE(TextFormat::ParseFromString(parse_string, &proto_)); + parse_string = "RepeatedGroup [{ a: 3 },]\n"; +} + +TEST_F(TextFormatTest, ParseShortRepeatedEmpty) { + string parse_string = + "repeated_int32: []\n" + "repeated_nested_enum: []\n" + "repeated_string: []\n" + "repeated_nested_message: []\n" + "RepeatedGroup []\n"; + + ASSERT_TRUE(TextFormat::ParseFromString(parse_string, &proto_)); + + EXPECT_EQ(0, proto_.repeated_int32_size()); + EXPECT_EQ(0, proto_.repeated_nested_enum_size()); + EXPECT_EQ(0, proto_.repeated_string_size()); + EXPECT_EQ(0, proto_.repeated_nested_message_size()); + EXPECT_EQ(0, proto_.repeatedgroup_size()); +} + +TEST_F(TextFormatTest, ParseShortRepeatedConcatenatedWithEmpty) { + string parse_string = + // Starting with empty [] should have no impact. + "repeated_int32: []\n" + "repeated_nested_enum: []\n" + "repeated_string: []\n" + "repeated_nested_message: []\n" + "RepeatedGroup []\n" + // Mixed short-form and long-form are simply concatenated. + "repeated_int32: 1\n" + "repeated_int32: [456, 789]\n" + "repeated_nested_enum: [ FOO ,BAR, # comment\n" + " 3]\n" + // Note that while the printer won't print repeated strings in short-form, + // the parser will accept them. + "repeated_string: [ \"foo\", 'bar' ]\n" + // Repeated message + "repeated_nested_message: [ { bb: 1 }, { bb : 2 }]\n" + // Repeated group + "RepeatedGroup [{ a: 3 },{ a: 4 }]\n" + // Adding empty [] should have no impact. + "repeated_int32: []\n" + "repeated_nested_enum: []\n" + "repeated_string: []\n" + "repeated_nested_message: []\n" + "RepeatedGroup []\n"; + + ASSERT_TRUE(TextFormat::ParseFromString(parse_string, &proto_)); + + ASSERT_EQ(3, proto_.repeated_int32_size()); + EXPECT_EQ(1, proto_.repeated_int32(0)); + EXPECT_EQ(456, proto_.repeated_int32(1)); + EXPECT_EQ(789, proto_.repeated_int32(2)); + + ASSERT_EQ(3, proto_.repeated_nested_enum_size()); + EXPECT_EQ(unittest::TestAllTypes::FOO, proto_.repeated_nested_enum(0)); + EXPECT_EQ(unittest::TestAllTypes::BAR, proto_.repeated_nested_enum(1)); + EXPECT_EQ(unittest::TestAllTypes::BAZ, proto_.repeated_nested_enum(2)); + + ASSERT_EQ(2, proto_.repeated_string_size()); + EXPECT_EQ("foo", proto_.repeated_string(0)); + EXPECT_EQ("bar", proto_.repeated_string(1)); + + ASSERT_EQ(2, proto_.repeated_nested_message_size()); + EXPECT_EQ(1, proto_.repeated_nested_message(0).bb()); + EXPECT_EQ(2, proto_.repeated_nested_message(1).bb()); + + ASSERT_EQ(2, proto_.repeatedgroup_size()); + EXPECT_EQ(3, proto_.repeatedgroup(0).a()); + EXPECT_EQ(4, proto_.repeatedgroup(1).a()); +} + TEST_F(TextFormatTest, Comments) { // Test that comments are ignored. diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index e6c9c58b..54c6e868 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -44,20 +44,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto() { Timestamp_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Timestamp_descriptor_, - Timestamp::default_instance_, + Timestamp::internal_default_instance(), Timestamp_offsets_, -1, -1, -1, sizeof(Timestamp), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _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_2ftimestamp_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( - Timestamp_descriptor_, &Timestamp::default_instance()); + Timestamp_descriptor_, Timestamp::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto() { - delete Timestamp::default_instance_; delete Timestamp_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + Timestamp::default_instance_.DefaultConstruct(); + Timestamp::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\037google/protobuf/timestamp.proto\022\017googl" "e.protobuf\"+\n\tTimestamp\022\017\n\007seconds\030\001 \001(\003" - "\022\r\n\005nanos\030\002 \001(\005B\201\001\n\023com.google.protobufB" - "\016TimestampProtoP\001Z+github.com/golang/pro" - "tobuf/ptypes/timestamp\240\001\001\370\001\001\242\002\003GPB\252\002\036Goo" - "gle.Protobuf.WellKnownTypesb\006proto3", 235); + "\022\r\n\005nanos\030\002 \001(\005B~\n\023com.google.protobufB\016" + "TimestampProtoP\001Z+github.com/golang/prot" + "obuf/ptypes/timestamp\370\001\001\242\002\003GPB\252\002\036Google." + "Protobuf.WellKnownTypesb\006proto3", 231); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/timestamp.proto", &protobuf_RegisterTypes); - Timestamp::default_instance_ = new Timestamp(); - Timestamp::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto() { @@ -104,6 +114,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2ftimestamp_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,35 +133,36 @@ const int Timestamp::kNanosFieldNumber; Timestamp::Timestamp() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Timestamp) } - Timestamp::Timestamp(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Timestamp) } void Timestamp::InitAsDefaultInstance() { - _is_default_instance_ = true; } Timestamp::Timestamp(const Timestamp& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Timestamp) } void Timestamp::SharedCtor() { - _is_default_instance_ = false; + ::memset(&seconds_, 0, reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); _cached_size_ = 0; - seconds_ = GOOGLE_LONGLONG(0); - nanos_ = 0; } Timestamp::~Timestamp() { @@ -150,12 +171,11 @@ Timestamp::~Timestamp() { } void Timestamp::SharedDtor() { - if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { return; } - if (this != default_instance_) { - } } void Timestamp::ArenaDtor(void* object) { @@ -175,11 +195,11 @@ const ::google::protobuf::Descriptor* Timestamp::descriptor() { } const Timestamp& Timestamp::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); + return *internal_default_instance(); } -Timestamp* Timestamp::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<Timestamp> Timestamp::default_instance_; Timestamp* Timestamp::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Timestamp>(arena); @@ -223,10 +243,10 @@ bool Timestamp::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; } @@ -238,10 +258,10 @@ bool Timestamp::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; } @@ -304,9 +324,9 @@ void Timestamp::SerializeWithCachedSizes( return target; } -int Timestamp::ByteSize() const { +size_t Timestamp::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Timestamp) - int total_size = 0; + size_t total_size = 0; // optional int64 seconds = 1; if (this->seconds() != 0) { @@ -322,18 +342,17 @@ int Timestamp::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 Timestamp::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Timestamp) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Timestamp* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Timestamp* source = ::google::protobuf::internal::DynamicCastToGenerated<const Timestamp>( &from); if (source == NULL) { @@ -341,15 +360,21 @@ void Timestamp::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Timestamp) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Timestamp::MergeFrom(const Timestamp& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Timestamp) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Timestamp::UnsafeMergeFrom(const Timestamp& from) { + GOOGLE_DCHECK(&from != this); if (from.seconds() != 0) { set_seconds(from.seconds()); } @@ -369,7 +394,7 @@ void Timestamp::CopyFrom(const Timestamp& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Timestamp) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Timestamp::IsInitialized() const { @@ -383,7 +408,7 @@ void Timestamp::Swap(Timestamp* other) { InternalSwap(other); } else { Timestamp temp; - temp.MergeFrom(*this); + temp.UnsafeMergeFrom(*this); CopyFrom(*other); other->CopyFrom(temp); } @@ -415,11 +440,11 @@ void Timestamp::InternalSwap(Timestamp* other) { void Timestamp::clear_seconds() { seconds_ = GOOGLE_LONGLONG(0); } - ::google::protobuf::int64 Timestamp::seconds() const { +::google::protobuf::int64 Timestamp::seconds() const { // @@protoc_insertion_point(field_get:google.protobuf.Timestamp.seconds) return seconds_; } - void Timestamp::set_seconds(::google::protobuf::int64 value) { +void Timestamp::set_seconds(::google::protobuf::int64 value) { seconds_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.seconds) @@ -429,11 +454,11 @@ void Timestamp::clear_seconds() { void Timestamp::clear_nanos() { nanos_ = 0; } - ::google::protobuf::int32 Timestamp::nanos() const { +::google::protobuf::int32 Timestamp::nanos() const { // @@protoc_insertion_point(field_get:google.protobuf.Timestamp.nanos) return nanos_; } - void Timestamp::set_nanos(::google::protobuf::int32 value) { +void Timestamp::set_nanos(::google::protobuf::int32 value) { nanos_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.nanos) diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 19f4f86f..b77fb32d 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -34,6 +34,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto(); @@ -60,6 +61,10 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro static const ::google::protobuf::Descriptor* descriptor(); static const Timestamp& default_instance(); + static inline const Timestamp* internal_default_instance() { + return &default_instance_.get(); + } + void UnsafeArenaSwap(Timestamp* other); void Swap(Timestamp* other); @@ -75,7 +80,7 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -91,6 +96,7 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Timestamp* other); + void UnsafeMergeFrom(const Timestamp& from); protected: explicit Timestamp(::google::protobuf::Arena* arena); private: @@ -130,16 +136,16 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool _is_default_instance_; ::google::protobuf::int64 seconds_; ::google::protobuf::int32 nanos_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto(); void InitAsDefaultInstance(); - static Timestamp* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/timestamp.proto b/src/google/protobuf/timestamp.proto index 7992a858..67e2eba4 100644 --- a/src/google/protobuf/timestamp.proto +++ b/src/google/protobuf/timestamp.proto @@ -38,7 +38,6 @@ option go_package = "github.com/golang/protobuf/ptypes/timestamp"; option java_package = "com.google.protobuf"; option java_outer_classname = "TimestampProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; // A Timestamp represents a point in time independent of any time zone @@ -90,16 +89,14 @@ option objc_class_prefix = "GPB"; // // Example 5: Compute Timestamp from current time in Python. // -// now = time.time() -// seconds = int(now) -// nanos = int((now - seconds) * 10**9) -// timestamp = Timestamp(seconds=seconds, nanos=nanos) +// timestamp = Timestamp() +// timestamp.GetCurrentTime() // // message Timestamp { // Represents seconds of UTC time since Unix epoch - // 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to + // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to // 9999-12-31T23:59:59Z inclusive. int64 seconds = 1; diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index fc7d5332..0c6de296 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -63,14 +63,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { Type_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Type_descriptor_, - Type::default_instance_, + Type::internal_default_instance(), Type_offsets_, -1, -1, -1, sizeof(Type), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_)); Field_descriptor_ = file->message_type(1); static const int Field_offsets_[10] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, kind_), @@ -87,14 +86,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { Field_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Field_descriptor_, - Field::default_instance_, + Field::internal_default_instance(), Field_offsets_, -1, -1, -1, sizeof(Field), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _internal_metadata_)); Field_Kind_descriptor_ = Field_descriptor_->enum_type(0); Field_Cardinality_descriptor_ = Field_descriptor_->enum_type(1); Enum_descriptor_ = file->message_type(2); @@ -108,14 +106,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { Enum_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Enum_descriptor_, - Enum::default_instance_, + Enum::internal_default_instance(), Enum_offsets_, -1, -1, -1, sizeof(Enum), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_)); EnumValue_descriptor_ = file->message_type(3); static const int EnumValue_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, name_), @@ -125,14 +122,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { EnumValue_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( EnumValue_descriptor_, - EnumValue::default_instance_, + EnumValue::internal_default_instance(), EnumValue_offsets_, -1, -1, -1, sizeof(EnumValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_)); Option_descriptor_ = file->message_type(4); static const int Option_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, name_), @@ -141,21 +137,20 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { Option_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Option_descriptor_, - Option::default_instance_, + Option::internal_default_instance(), Option_offsets_, -1, -1, -1, sizeof(Option), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_)); Syntax_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_2ftype_2eproto); } @@ -164,41 +159,58 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Type_descriptor_, &Type::default_instance()); + Type_descriptor_, Type::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Field_descriptor_, &Field::default_instance()); + Field_descriptor_, Field::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Enum_descriptor_, &Enum::default_instance()); + Enum_descriptor_, Enum::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValue_descriptor_, &EnumValue::default_instance()); + EnumValue_descriptor_, EnumValue::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Option_descriptor_, &Option::default_instance()); + Option_descriptor_, Option::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto() { - delete Type::default_instance_; delete Type_reflection_; - delete Field::default_instance_; delete Field_reflection_; - delete Enum::default_instance_; delete Enum_reflection_; - delete EnumValue::default_instance_; delete EnumValue_reflection_; - delete Option::default_instance_; delete Option_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); + ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); + ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); + ::google::protobuf::internal::GetEmptyString(); + Type::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + Field::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + Enum::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + EnumValue::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + Option::default_instance_.DefaultConstruct(); + Type::default_instance_.get_mutable()->InitAsDefaultInstance(); + Field::default_instance_.get_mutable()->InitAsDefaultInstance(); + Enum::default_instance_.get_mutable()->InitAsDefaultInstance(); + EnumValue::default_instance_.get_mutable()->InitAsDefaultInstance(); + Option::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\032google/protobuf/type.proto\022\017google.pro" "tobuf\032\031google/protobuf/any.proto\032$google" @@ -237,23 +249,20 @@ void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto() { "\022\014\n\004name\030\001 \001(\t\022#\n\005value\030\002 \001(\0132\024.google.p" "rotobuf.Any*.\n\006Syntax\022\021\n\rSYNTAX_PROTO2\020\000" "\022\021\n\rSYNTAX_PROTO3\020\001BL\n\023com.google.protob" - "ufB\tTypeProtoP\001\240\001\001\242\002\003GPB\252\002\036Google.Protob" + "ufB\tTypeProtoP\001\370\001\001\242\002\003GPB\252\002\036Google.Protob" "uf.WellKnownTypesb\006proto3", 1545); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/type.proto", &protobuf_RegisterTypes); - Type::default_instance_ = new Type(); - Field::default_instance_ = new Field(); - Enum::default_instance_ = new Enum(); - EnumValue::default_instance_ = new EnumValue(); - Option::default_instance_ = new Option(); - Type::default_instance_->InitAsDefaultInstance(); - Field::default_instance_->InitAsDefaultInstance(); - Enum::default_instance_->InitAsDefaultInstance(); - EnumValue::default_instance_->InitAsDefaultInstance(); - Option::default_instance_->InitAsDefaultInstance(); + ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); + ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto() { @@ -265,7 +274,7 @@ const ::google::protobuf::EnumDescriptor* Syntax_descriptor() { return Syntax_descriptor_; } bool Syntax_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: return true; @@ -275,8 +284,51 @@ bool Syntax_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 + + // =================================================================== +void Type::_slow_mutable_source_context() { + source_context_ = ::google::protobuf::Arena::Create< ::google::protobuf::SourceContext >( + GetArenaNoVirtual()); +} +::google::protobuf::SourceContext* Type::_slow_release_source_context() { + if (source_context_ == NULL) { + return NULL; + } else { + ::google::protobuf::SourceContext* temp = new ::google::protobuf::SourceContext(*source_context_); + source_context_ = NULL; + return temp; + } +} +::google::protobuf::SourceContext* Type::unsafe_arena_release_source_context() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Type.source_context) + + ::google::protobuf::SourceContext* temp = source_context_; + source_context_ = NULL; + return temp; +} +void Type::unsafe_arena_set_allocated_source_context( + ::google::protobuf::SourceContext* source_context) { + if (GetArenaNoVirtual() == NULL) { + delete source_context_; + } + source_context_ = source_context; + if (source_context) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Type.source_context) +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Type::kNameFieldNumber; const int Type::kFieldsFieldNumber; @@ -288,30 +340,42 @@ const int Type::kSyntaxFieldNumber; Type::Type() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Type) } +Type::Type(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + fields_(arena), + oneofs_(arena), + options_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Type) +} void Type::InitAsDefaultInstance() { - _is_default_instance_ = true; - source_context_ = const_cast< ::google::protobuf::SourceContext*>(&::google::protobuf::SourceContext::default_instance()); + source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); } Type::Type(const Type& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Type) } void Type::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); source_context_ = NULL; syntax_ = 0; + _cached_size_ = 0; } Type::~Type() { @@ -320,12 +384,21 @@ Type::~Type() { } void Type::SharedDtor() { - name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete source_context_; + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + + name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + delete source_context_; } +void Type::ArenaDtor(void* object) { + Type* _this = reinterpret_cast< Type* >(object); + (void)_this; +} +void Type::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Type::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -337,23 +410,19 @@ const ::google::protobuf::Descriptor* Type::descriptor() { } const Type& Type::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + return *internal_default_instance(); } -Type* Type::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<Type> Type::default_instance_; Type* Type::New(::google::protobuf::Arena* arena) const { - Type* n = new Type; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage<Type>(arena); } void Type::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Type) - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; source_context_ = NULL; syntax_ = 0; @@ -597,9 +666,9 @@ void Type::SerializeWithCachedSizes( return target; } -int Type::ByteSize() const { +size_t Type::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Type) - int total_size = 0; + size_t total_size = 0; // optional string name = 1; if (this->name().size() > 0) { @@ -622,40 +691,46 @@ int Type::ByteSize() const { } // repeated .google.protobuf.Field fields = 2; - total_size += 1 * this->fields_size(); - for (int i = 0; i < this->fields_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->fields(i)); + { + unsigned int count = this->fields_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->fields(i)); + } } // repeated string oneofs = 3; - total_size += 1 * this->oneofs_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->oneofs_size()); for (int i = 0; i < this->oneofs_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->oneofs(i)); } // repeated .google.protobuf.Option options = 4; - total_size += 1 * this->options_size(); - for (int i = 0; i < this->options_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(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 Type::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Type) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Type* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Type* source = ::google::protobuf::internal::DynamicCastToGenerated<const Type>( &from); if (source == NULL) { @@ -663,21 +738,26 @@ void Type::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Type) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Type::MergeFrom(const Type& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Type) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Type::UnsafeMergeFrom(const Type& from) { + GOOGLE_DCHECK(&from != this); fields_.MergeFrom(from.fields_); - oneofs_.MergeFrom(from.oneofs_); + oneofs_.UnsafeMergeFrom(from.oneofs_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { - - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (from.has_source_context()) { mutable_source_context()->::google::protobuf::SourceContext::MergeFrom(from.source_context()); @@ -698,7 +778,7 @@ void Type::CopyFrom(const Type& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Type) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Type::IsInitialized() const { @@ -708,6 +788,18 @@ bool Type::IsInitialized() const { void Type::Swap(Type* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + Type temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void Type::UnsafeArenaSwap(Type* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void Type::InternalSwap(Type* other) { @@ -734,47 +826,69 @@ void Type::InternalSwap(Type* other) { // optional string name = 1; void Type::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& Type::name() const { +const ::std::string& Type::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Type::set_name(const ::std::string& value) { +void Type::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Type.name) } - void Type::set_name(const char* value) { +void Type::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Type.name) } - void Type::set_name(const char* value, size_t size) { +void Type::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.name) } - ::std::string* Type::mutable_name() { +::std::string* Type::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Type.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* Type::release_name() { +::std::string* Type::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Type.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - void Type::set_allocated_name(::std::string* name) { +::std::string* Type::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Type.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +void Type::set_allocated_name(::std::string* name) { if (name != NULL) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name) } +void Type::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Type.name) +} // repeated .google.protobuf.Field fields = 2; int Type::fields_size() const { @@ -813,49 +927,49 @@ int Type::oneofs_size() const { void Type::clear_oneofs() { oneofs_.Clear(); } - const ::std::string& Type::oneofs(int index) const { +const ::std::string& Type::oneofs(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.Type.oneofs) return oneofs_.Get(index); } - ::std::string* Type::mutable_oneofs(int index) { +::std::string* Type::mutable_oneofs(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Type.oneofs) return oneofs_.Mutable(index); } - void Type::set_oneofs(int index, const ::std::string& value) { +void Type::set_oneofs(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) oneofs_.Mutable(index)->assign(value); } - void Type::set_oneofs(int index, const char* value) { +void Type::set_oneofs(int index, const char* value) { oneofs_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.Type.oneofs) } - void Type::set_oneofs(int index, const char* value, size_t size) { +void Type::set_oneofs(int index, const char* value, size_t size) { oneofs_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.oneofs) } - ::std::string* Type::add_oneofs() { +::std::string* Type::add_oneofs() { // @@protoc_insertion_point(field_add_mutable:google.protobuf.Type.oneofs) return oneofs_.Add(); } - void Type::add_oneofs(const ::std::string& value) { +void Type::add_oneofs(const ::std::string& value) { oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) } - void Type::add_oneofs(const char* value) { +void Type::add_oneofs(const char* value) { oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.Type.oneofs) } - void Type::add_oneofs(const char* value, size_t size) { +void Type::add_oneofs(const char* value, size_t size) { oneofs_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.Type.oneofs) } - const ::google::protobuf::RepeatedPtrField< ::std::string>& +const ::google::protobuf::RepeatedPtrField< ::std::string>& Type::oneofs() const { // @@protoc_insertion_point(field_list:google.protobuf.Type.oneofs) return oneofs_; } - ::google::protobuf::RepeatedPtrField< ::std::string>* +::google::protobuf::RepeatedPtrField< ::std::string>* Type::mutable_oneofs() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.oneofs) return &oneofs_; @@ -893,7 +1007,7 @@ Type::options() const { // optional .google.protobuf.SourceContext source_context = 5; bool Type::has_source_context() const { - return !_is_default_instance_ && source_context_ != NULL; + return this != internal_default_instance() && source_context_ != NULL; } void Type::clear_source_context() { if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; @@ -901,12 +1015,13 @@ void Type::clear_source_context() { } const ::google::protobuf::SourceContext& Type::source_context() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.source_context) - return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_; + return source_context_ != NULL ? *source_context_ + : *::google::protobuf::SourceContext::internal_default_instance(); } ::google::protobuf::SourceContext* Type::mutable_source_context() { if (source_context_ == NULL) { - source_context_ = new ::google::protobuf::SourceContext; + _slow_mutable_source_context(); } // @@protoc_insertion_point(field_mutable:google.protobuf.Type.source_context) return source_context_; @@ -914,12 +1029,24 @@ const ::google::protobuf::SourceContext& Type::source_context() const { ::google::protobuf::SourceContext* Type::release_source_context() { // @@protoc_insertion_point(field_release:google.protobuf.Type.source_context) - ::google::protobuf::SourceContext* temp = source_context_; - source_context_ = NULL; - return temp; + if (GetArenaNoVirtual() != NULL) { + return _slow_release_source_context(); + } else { + ::google::protobuf::SourceContext* temp = source_context_; + source_context_ = NULL; + return temp; + } } -void Type::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { - delete source_context_; + void Type::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete source_context_; + } + if (source_context != NULL) { + if (message_arena != NULL) { + message_arena->Own(source_context); + } + } source_context_ = source_context; if (source_context) { @@ -933,11 +1060,11 @@ void Type::set_allocated_source_context(::google::protobuf::SourceContext* sourc void Type::clear_syntax() { syntax_ = 0; } - ::google::protobuf::Syntax Type::syntax() const { +::google::protobuf::Syntax Type::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.syntax) return static_cast< ::google::protobuf::Syntax >(syntax_); } - void Type::set_syntax(::google::protobuf::Syntax value) { +void Type::set_syntax(::google::protobuf::Syntax value) { syntax_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Type.syntax) @@ -952,7 +1079,7 @@ const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor() { return Field_Kind_descriptor_; } bool Field_Kind_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -1007,7 +1134,7 @@ const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor() { return Field_Cardinality_descriptor_; } bool Field_Cardinality_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -1042,35 +1169,41 @@ const int Field::kDefaultValueFieldNumber; Field::Field() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Field) } +Field::Field(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + options_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Field) +} void Field::InitAsDefaultInstance() { - _is_default_instance_ = true; } Field::Field(const Field& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Field) } void Field::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; - kind_ = 0; - cardinality_ = 0; - number_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - oneof_index_ = 0; - packed_ = false; json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::memset(&kind_, 0, reinterpret_cast<char*>(&packed_) - + reinterpret_cast<char*>(&kind_) + sizeof(packed_)); + _cached_size_ = 0; } Field::~Field() { @@ -1079,14 +1212,23 @@ Field::~Field() { } void Field::SharedDtor() { - name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - type_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - json_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - default_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + + name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + type_url_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + json_name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + default_value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); } +void Field::ArenaDtor(void* object) { + Field* _this = reinterpret_cast< Field* >(object); + (void)_this; +} +void Field::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Field::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -1098,18 +1240,14 @@ const ::google::protobuf::Descriptor* Field::descriptor() { } const Field& Field::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + return *internal_default_instance(); } -Field* Field::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<Field> Field::default_instance_; Field* Field::New(::google::protobuf::Arena* arena) const { - Field* n = new Field; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage<Field>(arena); } void Field::Clear() { @@ -1130,13 +1268,11 @@ void Field::Clear() { ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ } while (0) - ZR_(kind_, cardinality_); - ZR_(number_, oneof_index_); - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - packed_ = false; - json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ZR_(kind_, packed_); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); #undef ZR_HELPER_ #undef ZR_ @@ -1189,10 +1325,10 @@ bool Field::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_number: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &number_))); - } else { goto handle_unusual; } @@ -1238,10 +1374,10 @@ bool Field::MergePartialFromCodedStream( case 7: { if (tag == 56) { parse_oneof_index: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &oneof_index_))); - } else { goto handle_unusual; } @@ -1253,10 +1389,10 @@ bool Field::MergePartialFromCodedStream( case 8: { if (tag == 64) { parse_packed: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &packed_))); - } else { goto handle_unusual; } @@ -1501,9 +1637,9 @@ void Field::SerializeWithCachedSizes( return target; } -int Field::ByteSize() const { +size_t Field::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Field) - int total_size = 0; + size_t total_size = 0; // optional .google.protobuf.Field.Kind kind = 1; if (this->kind() != 0) { @@ -1565,25 +1701,27 @@ int Field::ByteSize() const { } // repeated .google.protobuf.Option options = 9; - total_size += 1 * this->options_size(); - for (int i = 0; i < this->options_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(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 Field::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Field) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Field* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Field* source = ::google::protobuf::internal::DynamicCastToGenerated<const Field>( &from); if (source == NULL) { @@ -1591,15 +1729,21 @@ void Field::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Field) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Field::MergeFrom(const Field& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Field) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Field::UnsafeMergeFrom(const Field& from) { + GOOGLE_DCHECK(&from != this); options_.MergeFrom(from.options_); if (from.kind() != 0) { set_kind(from.kind()); @@ -1611,12 +1755,10 @@ void Field::MergeFrom(const Field& from) { set_number(from.number()); } if (from.name().size() > 0) { - - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (from.type_url().size() > 0) { - - type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_); + set_type_url(from.type_url()); } if (from.oneof_index() != 0) { set_oneof_index(from.oneof_index()); @@ -1625,12 +1767,10 @@ void Field::MergeFrom(const Field& from) { set_packed(from.packed()); } if (from.json_name().size() > 0) { - - json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_); + set_json_name(from.json_name()); } if (from.default_value().size() > 0) { - - default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_); + set_default_value(from.default_value()); } } @@ -1645,7 +1785,7 @@ void Field::CopyFrom(const Field& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Field) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Field::IsInitialized() const { @@ -1655,6 +1795,18 @@ bool Field::IsInitialized() const { void Field::Swap(Field* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + Field temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void Field::UnsafeArenaSwap(Field* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void Field::InternalSwap(Field* other) { @@ -1687,11 +1839,11 @@ void Field::InternalSwap(Field* other) { void Field::clear_kind() { kind_ = 0; } - ::google::protobuf::Field_Kind Field::kind() const { +::google::protobuf::Field_Kind Field::kind() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.kind) return static_cast< ::google::protobuf::Field_Kind >(kind_); } - void Field::set_kind(::google::protobuf::Field_Kind value) { +void Field::set_kind(::google::protobuf::Field_Kind value) { kind_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Field.kind) @@ -1701,11 +1853,11 @@ void Field::clear_kind() { void Field::clear_cardinality() { cardinality_ = 0; } - ::google::protobuf::Field_Cardinality Field::cardinality() const { +::google::protobuf::Field_Cardinality Field::cardinality() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.cardinality) return static_cast< ::google::protobuf::Field_Cardinality >(cardinality_); } - void Field::set_cardinality(::google::protobuf::Field_Cardinality value) { +void Field::set_cardinality(::google::protobuf::Field_Cardinality value) { cardinality_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Field.cardinality) @@ -1715,11 +1867,11 @@ void Field::clear_cardinality() { void Field::clear_number() { number_ = 0; } - ::google::protobuf::int32 Field::number() const { +::google::protobuf::int32 Field::number() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.number) return number_; } - void Field::set_number(::google::protobuf::int32 value) { +void Field::set_number(::google::protobuf::int32 value) { number_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Field.number) @@ -1727,101 +1879,145 @@ void Field::clear_number() { // optional string name = 4; void Field::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& Field::name() const { +const ::std::string& Field::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Field::set_name(const ::std::string& value) { +void Field::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.name) } - void Field::set_name(const char* value) { +void Field::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.name) } - void Field::set_name(const char* value, size_t size) { +void Field::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.name) } - ::std::string* Field::mutable_name() { +::std::string* Field::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* Field::release_name() { +::std::string* Field::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Field.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - void Field::set_allocated_name(::std::string* name) { +::std::string* Field::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +void Field::set_allocated_name(::std::string* name) { if (name != NULL) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name) } +void Field::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.name) +} // optional string type_url = 6; void Field::clear_type_url() { - type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& Field::type_url() const { +const ::std::string& Field::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url) - return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Field::set_type_url(const ::std::string& value) { +void Field::set_type_url(const ::std::string& value) { - type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.type_url) } - void Field::set_type_url(const char* value) { +void Field::set_type_url(const char* value) { - type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.type_url) } - void Field::set_type_url(const char* value, size_t size) { +void Field::set_type_url(const char* value, + size_t size) { - type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.type_url) } - ::std::string* Field::mutable_type_url() { +::std::string* Field::mutable_type_url() { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.type_url) - return type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* Field::release_type_url() { +::std::string* Field::release_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Field.type_url) - return type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - void Field::set_allocated_type_url(::std::string* type_url) { +::std::string* Field::unsafe_arena_release_type_url() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.type_url) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return type_url_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +void Field::set_allocated_type_url(::std::string* type_url) { if (type_url != NULL) { } else { } - type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_url); + type_url_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_url, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url) } +void Field::unsafe_arena_set_allocated_type_url( + ::std::string* type_url) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (type_url != NULL) { + + } else { + + } + type_url_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + type_url, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.type_url) +} // optional int32 oneof_index = 7; void Field::clear_oneof_index() { oneof_index_ = 0; } - ::google::protobuf::int32 Field::oneof_index() const { +::google::protobuf::int32 Field::oneof_index() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.oneof_index) return oneof_index_; } - void Field::set_oneof_index(::google::protobuf::int32 value) { +void Field::set_oneof_index(::google::protobuf::int32 value) { oneof_index_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Field.oneof_index) @@ -1831,11 +2027,11 @@ void Field::clear_oneof_index() { void Field::clear_packed() { packed_ = false; } - bool Field::packed() const { +bool Field::packed() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.packed) return packed_; } - void Field::set_packed(bool value) { +void Field::set_packed(bool value) { packed_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Field.packed) @@ -1873,96 +2069,173 @@ Field::options() const { // optional string json_name = 10; void Field::clear_json_name() { - json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& Field::json_name() const { +const ::std::string& Field::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name) - return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Field::set_json_name(const ::std::string& value) { +void Field::set_json_name(const ::std::string& value) { - json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.json_name) } - void Field::set_json_name(const char* value) { +void Field::set_json_name(const char* value) { - json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.json_name) } - void Field::set_json_name(const char* value, size_t size) { +void Field::set_json_name(const char* value, + size_t size) { - json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.json_name) } - ::std::string* Field::mutable_json_name() { +::std::string* Field::mutable_json_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.json_name) - return json_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* Field::release_json_name() { +::std::string* Field::release_json_name() { // @@protoc_insertion_point(field_release:google.protobuf.Field.json_name) - return json_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +::std::string* Field::unsafe_arena_release_json_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.json_name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return json_name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } - void Field::set_allocated_json_name(::std::string* json_name) { +void Field::set_allocated_json_name(::std::string* json_name) { if (json_name != NULL) { } else { } - json_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), json_name); + json_name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), json_name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name) } +void Field::unsafe_arena_set_allocated_json_name( + ::std::string* json_name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (json_name != NULL) { + + } else { + + } + json_name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + json_name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.json_name) +} // optional string default_value = 11; void Field::clear_default_value() { - default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& Field::default_value() const { +const ::std::string& Field::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value) - return default_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Field::set_default_value(const ::std::string& value) { +void Field::set_default_value(const ::std::string& value) { - default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.default_value) } - void Field::set_default_value(const char* value) { +void Field::set_default_value(const char* value) { - default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.default_value) } - void Field::set_default_value(const char* value, size_t size) { +void Field::set_default_value(const char* value, + size_t size) { - default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.default_value) } - ::std::string* Field::mutable_default_value() { +::std::string* Field::mutable_default_value() { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.default_value) - return default_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* Field::release_default_value() { +::std::string* Field::release_default_value() { // @@protoc_insertion_point(field_release:google.protobuf.Field.default_value) - return default_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +::std::string* Field::unsafe_arena_release_default_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.default_value) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return default_value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } - void Field::set_allocated_default_value(::std::string* default_value) { +void Field::set_allocated_default_value(::std::string* default_value) { if (default_value != NULL) { } else { } - default_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), default_value); + default_value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), default_value, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value) } +void Field::unsafe_arena_set_allocated_default_value( + ::std::string* default_value) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (default_value != NULL) { + + } else { + + } + default_value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + default_value, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.default_value) +} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void Enum::_slow_mutable_source_context() { + source_context_ = ::google::protobuf::Arena::Create< ::google::protobuf::SourceContext >( + GetArenaNoVirtual()); +} +::google::protobuf::SourceContext* Enum::_slow_release_source_context() { + if (source_context_ == NULL) { + return NULL; + } else { + ::google::protobuf::SourceContext* temp = new ::google::protobuf::SourceContext(*source_context_); + source_context_ = NULL; + return temp; + } +} +::google::protobuf::SourceContext* Enum::unsafe_arena_release_source_context() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Enum.source_context) + + ::google::protobuf::SourceContext* temp = source_context_; + source_context_ = NULL; + return temp; +} +void Enum::unsafe_arena_set_allocated_source_context( + ::google::protobuf::SourceContext* source_context) { + if (GetArenaNoVirtual() == NULL) { + delete source_context_; + } + source_context_ = source_context; + if (source_context) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Enum.source_context) +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Enum::kNameFieldNumber; const int Enum::kEnumvalueFieldNumber; @@ -1973,30 +2246,41 @@ const int Enum::kSyntaxFieldNumber; Enum::Enum() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Enum) } +Enum::Enum(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + enumvalue_(arena), + options_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Enum) +} void Enum::InitAsDefaultInstance() { - _is_default_instance_ = true; - source_context_ = const_cast< ::google::protobuf::SourceContext*>(&::google::protobuf::SourceContext::default_instance()); + source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); } Enum::Enum(const Enum& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Enum) } void Enum::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); source_context_ = NULL; syntax_ = 0; + _cached_size_ = 0; } Enum::~Enum() { @@ -2005,12 +2289,21 @@ Enum::~Enum() { } void Enum::SharedDtor() { - name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete source_context_; + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + + name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + delete source_context_; } +void Enum::ArenaDtor(void* object) { + Enum* _this = reinterpret_cast< Enum* >(object); + (void)_this; +} +void Enum::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Enum::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -2022,23 +2315,19 @@ const ::google::protobuf::Descriptor* Enum::descriptor() { } const Enum& Enum::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + return *internal_default_instance(); } -Enum* Enum::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<Enum> Enum::default_instance_; Enum* Enum::New(::google::protobuf::Arena* arena) const { - Enum* n = new Enum; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage<Enum>(arena); } void Enum::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Enum) - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; source_context_ = NULL; syntax_ = 0; @@ -2241,9 +2530,9 @@ void Enum::SerializeWithCachedSizes( return target; } -int Enum::ByteSize() const { +size_t Enum::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Enum) - int total_size = 0; + size_t total_size = 0; // optional string name = 1; if (this->name().size() > 0) { @@ -2266,33 +2555,38 @@ int Enum::ByteSize() const { } // repeated .google.protobuf.EnumValue enumvalue = 2; - total_size += 1 * this->enumvalue_size(); - for (int i = 0; i < this->enumvalue_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->enumvalue(i)); + { + unsigned int count = this->enumvalue_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->enumvalue(i)); + } } // repeated .google.protobuf.Option options = 3; - total_size += 1 * this->options_size(); - for (int i = 0; i < this->options_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(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 Enum::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Enum) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Enum* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Enum* source = ::google::protobuf::internal::DynamicCastToGenerated<const Enum>( &from); if (source == NULL) { @@ -2300,20 +2594,25 @@ void Enum::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Enum) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Enum::MergeFrom(const Enum& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Enum) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Enum::UnsafeMergeFrom(const Enum& from) { + GOOGLE_DCHECK(&from != this); enumvalue_.MergeFrom(from.enumvalue_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { - - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (from.has_source_context()) { mutable_source_context()->::google::protobuf::SourceContext::MergeFrom(from.source_context()); @@ -2334,7 +2633,7 @@ void Enum::CopyFrom(const Enum& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Enum) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Enum::IsInitialized() const { @@ -2344,6 +2643,18 @@ bool Enum::IsInitialized() const { void Enum::Swap(Enum* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + Enum temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void Enum::UnsafeArenaSwap(Enum* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void Enum::InternalSwap(Enum* other) { @@ -2369,47 +2680,69 @@ void Enum::InternalSwap(Enum* other) { // optional string name = 1; void Enum::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& Enum::name() const { +const ::std::string& Enum::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Enum::set_name(const ::std::string& value) { +void Enum::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Enum.name) } - void Enum::set_name(const char* value) { +void Enum::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Enum.name) } - void Enum::set_name(const char* value, size_t size) { +void Enum::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Enum.name) } - ::std::string* Enum::mutable_name() { +::std::string* Enum::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* Enum::release_name() { +::std::string* Enum::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Enum.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +::std::string* Enum::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Enum.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } - void Enum::set_allocated_name(::std::string* name) { +void Enum::set_allocated_name(::std::string* name) { if (name != NULL) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name) } +void Enum::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Enum.name) +} // repeated .google.protobuf.EnumValue enumvalue = 2; int Enum::enumvalue_size() const { @@ -2473,7 +2806,7 @@ Enum::options() const { // optional .google.protobuf.SourceContext source_context = 4; bool Enum::has_source_context() const { - return !_is_default_instance_ && source_context_ != NULL; + return this != internal_default_instance() && source_context_ != NULL; } void Enum::clear_source_context() { if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; @@ -2481,12 +2814,13 @@ void Enum::clear_source_context() { } const ::google::protobuf::SourceContext& Enum::source_context() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.source_context) - return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_; + return source_context_ != NULL ? *source_context_ + : *::google::protobuf::SourceContext::internal_default_instance(); } ::google::protobuf::SourceContext* Enum::mutable_source_context() { if (source_context_ == NULL) { - source_context_ = new ::google::protobuf::SourceContext; + _slow_mutable_source_context(); } // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.source_context) return source_context_; @@ -2494,12 +2828,24 @@ const ::google::protobuf::SourceContext& Enum::source_context() const { ::google::protobuf::SourceContext* Enum::release_source_context() { // @@protoc_insertion_point(field_release:google.protobuf.Enum.source_context) - ::google::protobuf::SourceContext* temp = source_context_; - source_context_ = NULL; - return temp; + if (GetArenaNoVirtual() != NULL) { + return _slow_release_source_context(); + } else { + ::google::protobuf::SourceContext* temp = source_context_; + source_context_ = NULL; + return temp; + } } -void Enum::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { - delete source_context_; + void Enum::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete source_context_; + } + if (source_context != NULL) { + if (message_arena != NULL) { + message_arena->Own(source_context); + } + } source_context_ = source_context; if (source_context) { @@ -2513,11 +2859,11 @@ void Enum::set_allocated_source_context(::google::protobuf::SourceContext* sourc void Enum::clear_syntax() { syntax_ = 0; } - ::google::protobuf::Syntax Enum::syntax() const { +::google::protobuf::Syntax Enum::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.syntax) return static_cast< ::google::protobuf::Syntax >(syntax_); } - void Enum::set_syntax(::google::protobuf::Syntax value) { +void Enum::set_syntax(::google::protobuf::Syntax value) { syntax_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Enum.syntax) @@ -2535,28 +2881,37 @@ const int EnumValue::kOptionsFieldNumber; EnumValue::EnumValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValue) } +EnumValue::EnumValue(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + options_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValue) +} void EnumValue::InitAsDefaultInstance() { - _is_default_instance_ = true; } EnumValue::EnumValue(const EnumValue& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValue) } void EnumValue::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); number_ = 0; + _cached_size_ = 0; } EnumValue::~EnumValue() { @@ -2565,11 +2920,20 @@ EnumValue::~EnumValue() { } void EnumValue::SharedDtor() { - name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + + name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); } +void EnumValue::ArenaDtor(void* object) { + EnumValue* _this = reinterpret_cast< EnumValue* >(object); + (void)_this; +} +void EnumValue::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void EnumValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -2581,23 +2945,19 @@ const ::google::protobuf::Descriptor* EnumValue::descriptor() { } const EnumValue& EnumValue::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + return *internal_default_instance(); } -EnumValue* EnumValue::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<EnumValue> EnumValue::default_instance_; EnumValue* EnumValue::New(::google::protobuf::Arena* arena) const { - EnumValue* n = new EnumValue; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage<EnumValue>(arena); } void EnumValue::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValue) - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); number_ = 0; options_.Clear(); } @@ -2632,10 +2992,10 @@ bool EnumValue::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_number: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &number_))); - } else { goto handle_unusual; } @@ -2739,9 +3099,9 @@ void EnumValue::SerializeWithCachedSizes( return target; } -int EnumValue::ByteSize() const { +size_t EnumValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValue) - int total_size = 0; + size_t total_size = 0; // optional string name = 1; if (this->name().size() > 0) { @@ -2758,25 +3118,27 @@ int EnumValue::ByteSize() const { } // repeated .google.protobuf.Option options = 3; - total_size += 1 * this->options_size(); - for (int i = 0; i < this->options_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(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 EnumValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const EnumValue* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const EnumValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumValue>( &from); if (source == NULL) { @@ -2784,19 +3146,24 @@ void EnumValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValue) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void EnumValue::MergeFrom(const EnumValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void EnumValue::UnsafeMergeFrom(const EnumValue& from) { + GOOGLE_DCHECK(&from != this); options_.MergeFrom(from.options_); if (from.name().size() > 0) { - - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (from.number() != 0) { set_number(from.number()); @@ -2814,7 +3181,7 @@ void EnumValue::CopyFrom(const EnumValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValue) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool EnumValue::IsInitialized() const { @@ -2824,6 +3191,18 @@ bool EnumValue::IsInitialized() const { void EnumValue::Swap(EnumValue* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + EnumValue temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void EnumValue::UnsafeArenaSwap(EnumValue* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void EnumValue::InternalSwap(EnumValue* other) { @@ -2847,57 +3226,79 @@ void EnumValue::InternalSwap(EnumValue* other) { // optional string name = 1; void EnumValue::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& EnumValue::name() const { +const ::std::string& EnumValue::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void EnumValue::set_name(const ::std::string& value) { +void EnumValue::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name) } - void EnumValue::set_name(const char* value) { +void EnumValue::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValue.name) } - void EnumValue::set_name(const char* value, size_t size) { +void EnumValue::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValue.name) } - ::std::string* EnumValue::mutable_name() { +::std::string* EnumValue::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* EnumValue::release_name() { +::std::string* EnumValue::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - void EnumValue::set_allocated_name(::std::string* name) { +::std::string* EnumValue::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumValue.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +void EnumValue::set_allocated_name(::std::string* name) { if (name != NULL) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name) } +void EnumValue::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValue.name) +} // optional int32 number = 2; void EnumValue::clear_number() { number_ = 0; } - ::google::protobuf::int32 EnumValue::number() const { +::google::protobuf::int32 EnumValue::number() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.number) return number_; } - void EnumValue::set_number(::google::protobuf::int32 value) { +void EnumValue::set_number(::google::protobuf::int32 value) { number_ = value; // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.number) @@ -2937,6 +3338,39 @@ EnumValue::options() const { // =================================================================== +void Option::_slow_mutable_value() { + value_ = ::google::protobuf::Arena::Create< ::google::protobuf::Any >( + GetArenaNoVirtual()); +} +::google::protobuf::Any* Option::_slow_release_value() { + if (value_ == NULL) { + return NULL; + } else { + ::google::protobuf::Any* temp = new ::google::protobuf::Any(*value_); + value_ = NULL; + return temp; + } +} +::google::protobuf::Any* Option::unsafe_arena_release_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Option.value) + + ::google::protobuf::Any* temp = value_; + value_ = NULL; + return temp; +} +void Option::unsafe_arena_set_allocated_value( + ::google::protobuf::Any* value) { + if (GetArenaNoVirtual() == NULL) { + delete value_; + } + value_ = value; + if (value) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.value) +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Option::kNameFieldNumber; const int Option::kValueFieldNumber; @@ -2944,29 +3378,38 @@ const int Option::kValueFieldNumber; Option::Option() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Option) } +Option::Option(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Option) +} void Option::InitAsDefaultInstance() { - _is_default_instance_ = true; - value_ = const_cast< ::google::protobuf::Any*>(&::google::protobuf::Any::default_instance()); + value_ = const_cast< ::google::protobuf::Any*>( + ::google::protobuf::Any::internal_default_instance()); } Option::Option(const Option& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Option) } void Option::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); value_ = NULL; + _cached_size_ = 0; } Option::~Option() { @@ -2975,12 +3418,21 @@ Option::~Option() { } void Option::SharedDtor() { - name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete value_; + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + + name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + delete value_; } +void Option::ArenaDtor(void* object) { + Option* _this = reinterpret_cast< Option* >(object); + (void)_this; +} +void Option::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Option::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -2992,23 +3444,19 @@ const ::google::protobuf::Descriptor* Option::descriptor() { } const Option& Option::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + return *internal_default_instance(); } -Option* Option::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<Option> Option::default_instance_; Option* Option::New(::google::protobuf::Arena* arena) const { - Option* n = new Option; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage<Option>(arena); } void Option::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Option) - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); if (GetArenaNoVirtual() == NULL && value_ != NULL) delete value_; value_ = NULL; } @@ -3121,9 +3569,9 @@ void Option::SerializeWithCachedSizes( return target; } -int Option::ByteSize() const { +size_t Option::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Option) - int total_size = 0; + size_t total_size = 0; // optional string name = 1; if (this->name().size() > 0) { @@ -3139,18 +3587,17 @@ int Option::ByteSize() const { *this->value_); } + 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 Option::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Option) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Option* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Option* source = ::google::protobuf::internal::DynamicCastToGenerated<const Option>( &from); if (source == NULL) { @@ -3158,18 +3605,23 @@ void Option::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Option) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Option::MergeFrom(const Option& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Option) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } - if (from.name().size() > 0) { +} - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); +void Option::UnsafeMergeFrom(const Option& from) { + GOOGLE_DCHECK(&from != this); + if (from.name().size() > 0) { + set_name(from.name()); } if (from.has_value()) { mutable_value()->::google::protobuf::Any::MergeFrom(from.value()); @@ -3187,7 +3639,7 @@ void Option::CopyFrom(const Option& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Option) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Option::IsInitialized() const { @@ -3197,6 +3649,18 @@ bool Option::IsInitialized() const { void Option::Swap(Option* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + Option temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void Option::UnsafeArenaSwap(Option* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void Option::InternalSwap(Option* other) { @@ -3219,51 +3683,73 @@ void Option::InternalSwap(Option* other) { // optional string name = 1; void Option::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& Option::name() const { +const ::std::string& Option::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Option.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Option::set_name(const ::std::string& value) { +void Option::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Option.name) } - void Option::set_name(const char* value) { +void Option::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Option.name) } - void Option::set_name(const char* value, size_t size) { +void Option::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Option.name) } - ::std::string* Option::mutable_name() { +::std::string* Option::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Option.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* Option::release_name() { +::std::string* Option::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Option.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - void Option::set_allocated_name(::std::string* name) { +::std::string* Option::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Option.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +void Option::set_allocated_name(::std::string* name) { if (name != NULL) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name) } +void Option::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.name) +} // optional .google.protobuf.Any value = 2; bool Option::has_value() const { - return !_is_default_instance_ && value_ != NULL; + return this != internal_default_instance() && value_ != NULL; } void Option::clear_value() { if (GetArenaNoVirtual() == NULL && value_ != NULL) delete value_; @@ -3271,12 +3757,13 @@ void Option::clear_value() { } const ::google::protobuf::Any& Option::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Option.value) - return value_ != NULL ? *value_ : *default_instance_->value_; + return value_ != NULL ? *value_ + : *::google::protobuf::Any::internal_default_instance(); } ::google::protobuf::Any* Option::mutable_value() { if (value_ == NULL) { - value_ = new ::google::protobuf::Any; + _slow_mutable_value(); } // @@protoc_insertion_point(field_mutable:google.protobuf.Option.value) return value_; @@ -3284,12 +3771,24 @@ const ::google::protobuf::Any& Option::value() const { ::google::protobuf::Any* Option::release_value() { // @@protoc_insertion_point(field_release:google.protobuf.Option.value) - ::google::protobuf::Any* temp = value_; - value_ = NULL; - return temp; + if (GetArenaNoVirtual() != NULL) { + return _slow_release_value(); + } else { + ::google::protobuf::Any* temp = value_; + value_ = NULL; + return temp; + } } -void Option::set_allocated_value(::google::protobuf::Any* value) { - delete value_; + void Option::set_allocated_value(::google::protobuf::Any* value) { + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete value_; + } + if (value != NULL) { + if (message_arena != NULL) { + message_arena->Own(value); + } + } value_ = value; if (value) { diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index ce29c281..92d9dd13 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -37,6 +37,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); @@ -142,9 +143,18 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i return *this; } + inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } + inline void* GetMaybeArenaPointer() const { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const Type& default_instance(); + static inline const Type* internal_default_instance() { + return &default_instance_.get(); + } + + void UnsafeArenaSwap(Type* other); void Swap(Type* other); // implements Message ---------------------------------------------- @@ -159,7 +169,7 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -175,6 +185,12 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Type* other); + void UnsafeMergeFrom(const Type& from); + protected: + explicit Type(::google::protobuf::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -200,6 +216,9 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + ::std::string* unsafe_arena_release_name(); + void unsafe_arena_set_allocated_name( + ::std::string* name); // repeated .google.protobuf.Field fields = 2; int fields_size() const; @@ -245,10 +264,17 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i bool has_source_context() const; void clear_source_context(); static const int kSourceContextFieldNumber = 5; + private: + void _slow_mutable_source_context(); + ::google::protobuf::SourceContext* _slow_release_source_context(); + public: const ::google::protobuf::SourceContext& source_context() const; ::google::protobuf::SourceContext* mutable_source_context(); ::google::protobuf::SourceContext* release_source_context(); void set_allocated_source_context(::google::protobuf::SourceContext* source_context); + ::google::protobuf::SourceContext* unsafe_arena_release_source_context(); + void unsafe_arena_set_allocated_source_context( + ::google::protobuf::SourceContext* source_context); // optional .google.protobuf.Syntax syntax = 6; void clear_syntax(); @@ -260,20 +286,23 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; - ::google::protobuf::internal::ArenaStringPtr name_; + friend class ::google::protobuf::Arena; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field > fields_; ::google::protobuf::RepeatedPtrField< ::std::string> oneofs_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; + ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::SourceContext* source_context_; int syntax_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); void InitAsDefaultInstance(); - static Type* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Type> default_instance_; }; // ------------------------------------------------------------------- @@ -289,9 +318,18 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ return *this; } + inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } + inline void* GetMaybeArenaPointer() const { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const Field& default_instance(); + static inline const Field* internal_default_instance() { + return &default_instance_.get(); + } + + void UnsafeArenaSwap(Field* other); void Swap(Field* other); // implements Message ---------------------------------------------- @@ -306,7 +344,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -322,6 +360,12 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Field* other); + void UnsafeMergeFrom(const Field& from); + protected: + explicit Field(::google::protobuf::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -455,6 +499,9 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + ::std::string* unsafe_arena_release_name(); + void unsafe_arena_set_allocated_name( + ::std::string* name); // optional string type_url = 6; void clear_type_url(); @@ -466,6 +513,9 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ ::std::string* mutable_type_url(); ::std::string* release_type_url(); void set_allocated_type_url(::std::string* type_url); + ::std::string* unsafe_arena_release_type_url(); + void unsafe_arena_set_allocated_type_url( + ::std::string* type_url); // optional int32 oneof_index = 7; void clear_oneof_index(); @@ -501,6 +551,9 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ ::std::string* mutable_json_name(); ::std::string* release_json_name(); void set_allocated_json_name(::std::string* json_name); + ::std::string* unsafe_arena_release_json_name(); + void unsafe_arena_set_allocated_json_name( + ::std::string* json_name); // optional string default_value = 11; void clear_default_value(); @@ -512,29 +565,35 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ ::std::string* mutable_default_value(); ::std::string* release_default_value(); void set_allocated_default_value(::std::string* default_value); + ::std::string* unsafe_arena_release_default_value(); + void unsafe_arena_set_allocated_default_value( + ::std::string* default_value); // @@protoc_insertion_point(class_scope:google.protobuf.Field) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; - int kind_; - int cardinality_; + friend class ::google::protobuf::Arena; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; ::google::protobuf::internal::ArenaStringPtr name_; - ::google::protobuf::int32 number_; - ::google::protobuf::int32 oneof_index_; ::google::protobuf::internal::ArenaStringPtr type_url_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; ::google::protobuf::internal::ArenaStringPtr json_name_; ::google::protobuf::internal::ArenaStringPtr default_value_; + int kind_; + int cardinality_; + ::google::protobuf::int32 number_; + ::google::protobuf::int32 oneof_index_; bool packed_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); void InitAsDefaultInstance(); - static Field* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Field> default_instance_; }; // ------------------------------------------------------------------- @@ -550,9 +609,18 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i return *this; } + inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } + inline void* GetMaybeArenaPointer() const { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const Enum& default_instance(); + static inline const Enum* internal_default_instance() { + return &default_instance_.get(); + } + + void UnsafeArenaSwap(Enum* other); void Swap(Enum* other); // implements Message ---------------------------------------------- @@ -567,7 +635,7 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -583,6 +651,12 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Enum* other); + void UnsafeMergeFrom(const Enum& from); + protected: + explicit Enum(::google::protobuf::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -608,6 +682,9 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + ::std::string* unsafe_arena_release_name(); + void unsafe_arena_set_allocated_name( + ::std::string* name); // repeated .google.protobuf.EnumValue enumvalue = 2; int enumvalue_size() const; @@ -637,10 +714,17 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i bool has_source_context() const; void clear_source_context(); static const int kSourceContextFieldNumber = 4; + private: + void _slow_mutable_source_context(); + ::google::protobuf::SourceContext* _slow_release_source_context(); + public: const ::google::protobuf::SourceContext& source_context() const; ::google::protobuf::SourceContext* mutable_source_context(); ::google::protobuf::SourceContext* release_source_context(); void set_allocated_source_context(::google::protobuf::SourceContext* source_context); + ::google::protobuf::SourceContext* unsafe_arena_release_source_context(); + void unsafe_arena_set_allocated_source_context( + ::google::protobuf::SourceContext* source_context); // optional .google.protobuf.Syntax syntax = 5; void clear_syntax(); @@ -652,19 +736,22 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; - ::google::protobuf::internal::ArenaStringPtr name_; + friend class ::google::protobuf::Arena; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue > enumvalue_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; + ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::SourceContext* source_context_; int syntax_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); void InitAsDefaultInstance(); - static Enum* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Enum> default_instance_; }; // ------------------------------------------------------------------- @@ -680,9 +767,18 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro return *this; } + inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } + inline void* GetMaybeArenaPointer() const { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const EnumValue& default_instance(); + static inline const EnumValue* internal_default_instance() { + return &default_instance_.get(); + } + + void UnsafeArenaSwap(EnumValue* other); void Swap(EnumValue* other); // implements Message ---------------------------------------------- @@ -697,7 +793,7 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -713,6 +809,12 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(EnumValue* other); + void UnsafeMergeFrom(const EnumValue& from); + protected: + explicit EnumValue(::google::protobuf::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -738,6 +840,9 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + ::std::string* unsafe_arena_release_name(); + void unsafe_arena_set_allocated_name( + ::std::string* name); // optional int32 number = 2; void clear_number(); @@ -761,17 +866,20 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; - ::google::protobuf::internal::ArenaStringPtr name_; + friend class ::google::protobuf::Arena; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; + ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::int32 number_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); void InitAsDefaultInstance(); - static EnumValue* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<EnumValue> default_instance_; }; // ------------------------------------------------------------------- @@ -787,9 +895,18 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc return *this; } + inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } + inline void* GetMaybeArenaPointer() const { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const Option& default_instance(); + static inline const Option* internal_default_instance() { + return &default_instance_.get(); + } + + void UnsafeArenaSwap(Option* other); void Swap(Option* other); // implements Message ---------------------------------------------- @@ -804,7 +921,7 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -820,6 +937,12 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Option* other); + void UnsafeMergeFrom(const Option& from); + protected: + explicit Option(::google::protobuf::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -845,30 +968,43 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); + ::std::string* unsafe_arena_release_name(); + void unsafe_arena_set_allocated_name( + ::std::string* name); // optional .google.protobuf.Any value = 2; bool has_value() const; void clear_value(); static const int kValueFieldNumber = 2; + private: + void _slow_mutable_value(); + ::google::protobuf::Any* _slow_release_value(); + public: const ::google::protobuf::Any& value() const; ::google::protobuf::Any* mutable_value(); ::google::protobuf::Any* release_value(); void set_allocated_value(::google::protobuf::Any* value); + ::google::protobuf::Any* unsafe_arena_release_value(); + void unsafe_arena_set_allocated_value( + ::google::protobuf::Any* value); // @@protoc_insertion_point(class_scope:google.protobuf.Option) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; + friend class ::google::protobuf::Arena; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::Any* value_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); void InitAsDefaultInstance(); - static Option* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Option> default_instance_; }; // =================================================================== @@ -880,37 +1016,46 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc // optional string name = 1; inline void Type::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Type::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Type::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Type.name) } inline void Type::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Type.name) } -inline void Type::set_name(const char* value, size_t size) { +inline void Type::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.name) } inline ::std::string* Type::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Type.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Type::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Type.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +inline ::std::string* Type::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Type.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } inline void Type::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -918,9 +1063,22 @@ inline void Type::set_allocated_name(::std::string* name) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name) } +inline void Type::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Type.name) +} // repeated .google.protobuf.Field fields = 2; inline int Type::fields_size() const { @@ -1039,7 +1197,7 @@ Type::options() const { // optional .google.protobuf.SourceContext source_context = 5; inline bool Type::has_source_context() const { - return !_is_default_instance_ && source_context_ != NULL; + return this != internal_default_instance() && source_context_ != NULL; } inline void Type::clear_source_context() { if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; @@ -1047,12 +1205,13 @@ inline void Type::clear_source_context() { } inline const ::google::protobuf::SourceContext& Type::source_context() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.source_context) - return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_; + return source_context_ != NULL ? *source_context_ + : *::google::protobuf::SourceContext::internal_default_instance(); } inline ::google::protobuf::SourceContext* Type::mutable_source_context() { if (source_context_ == NULL) { - source_context_ = new ::google::protobuf::SourceContext; + _slow_mutable_source_context(); } // @@protoc_insertion_point(field_mutable:google.protobuf.Type.source_context) return source_context_; @@ -1060,12 +1219,24 @@ inline ::google::protobuf::SourceContext* Type::mutable_source_context() { inline ::google::protobuf::SourceContext* Type::release_source_context() { // @@protoc_insertion_point(field_release:google.protobuf.Type.source_context) - ::google::protobuf::SourceContext* temp = source_context_; - source_context_ = NULL; - return temp; + if (GetArenaNoVirtual() != NULL) { + return _slow_release_source_context(); + } else { + ::google::protobuf::SourceContext* temp = source_context_; + source_context_ = NULL; + return temp; + } } -inline void Type::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { - delete source_context_; +inline void Type::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete source_context_; + } + if (source_context != NULL) { + if (message_arena != NULL) { + message_arena->Own(source_context); + } + } source_context_ = source_context; if (source_context) { @@ -1137,37 +1308,46 @@ inline void Field::set_number(::google::protobuf::int32 value) { // optional string name = 4; inline void Field::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Field::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Field::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.name) } inline void Field::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.name) } -inline void Field::set_name(const char* value, size_t size) { +inline void Field::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.name) } inline ::std::string* Field::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Field::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Field.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +inline ::std::string* Field::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } inline void Field::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -1175,43 +1355,65 @@ inline void Field::set_allocated_name(::std::string* name) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name) } +inline void Field::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.name) +} // optional string type_url = 6; inline void Field::clear_type_url() { - type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Field::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url) - return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Field::set_type_url(const ::std::string& value) { - type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.type_url) } inline void Field::set_type_url(const char* value) { - type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.type_url) } -inline void Field::set_type_url(const char* value, size_t size) { +inline void Field::set_type_url(const char* value, + size_t size) { - type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.type_url) } inline ::std::string* Field::mutable_type_url() { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.type_url) - return type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Field::release_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Field.type_url) - return type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +inline ::std::string* Field::unsafe_arena_release_type_url() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.type_url) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return type_url_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } inline void Field::set_allocated_type_url(::std::string* type_url) { if (type_url != NULL) { @@ -1219,9 +1421,22 @@ inline void Field::set_allocated_type_url(::std::string* type_url) { } else { } - type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_url); + type_url_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_url, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url) } +inline void Field::unsafe_arena_set_allocated_type_url( + ::std::string* type_url) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (type_url != NULL) { + + } else { + + } + type_url_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + type_url, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.type_url) +} // optional int32 oneof_index = 7; inline void Field::clear_oneof_index() { @@ -1283,37 +1498,46 @@ Field::options() const { // optional string json_name = 10; inline void Field::clear_json_name() { - json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Field::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name) - return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Field::set_json_name(const ::std::string& value) { - json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.json_name) } inline void Field::set_json_name(const char* value) { - json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.json_name) } -inline void Field::set_json_name(const char* value, size_t size) { +inline void Field::set_json_name(const char* value, + size_t size) { - json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.json_name) } inline ::std::string* Field::mutable_json_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.json_name) - return json_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Field::release_json_name() { // @@protoc_insertion_point(field_release:google.protobuf.Field.json_name) - return json_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +inline ::std::string* Field::unsafe_arena_release_json_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.json_name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return json_name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } inline void Field::set_allocated_json_name(::std::string* json_name) { if (json_name != NULL) { @@ -1321,43 +1545,65 @@ inline void Field::set_allocated_json_name(::std::string* json_name) { } else { } - json_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), json_name); + json_name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), json_name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name) } +inline void Field::unsafe_arena_set_allocated_json_name( + ::std::string* json_name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (json_name != NULL) { + + } else { + + } + json_name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + json_name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.json_name) +} // optional string default_value = 11; inline void Field::clear_default_value() { - default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Field::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value) - return default_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Field::set_default_value(const ::std::string& value) { - default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.default_value) } inline void Field::set_default_value(const char* value) { - default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.default_value) } -inline void Field::set_default_value(const char* value, size_t size) { +inline void Field::set_default_value(const char* value, + size_t size) { - default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.default_value) } inline ::std::string* Field::mutable_default_value() { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.default_value) - return default_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Field::release_default_value() { // @@protoc_insertion_point(field_release:google.protobuf.Field.default_value) - return default_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +inline ::std::string* Field::unsafe_arena_release_default_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.default_value) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return default_value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } inline void Field::set_allocated_default_value(::std::string* default_value) { if (default_value != NULL) { @@ -1365,9 +1611,22 @@ inline void Field::set_allocated_default_value(::std::string* default_value) { } else { } - default_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), default_value); + default_value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), default_value, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value) } +inline void Field::unsafe_arena_set_allocated_default_value( + ::std::string* default_value) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (default_value != NULL) { + + } else { + + } + default_value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + default_value, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.default_value) +} // ------------------------------------------------------------------- @@ -1375,37 +1634,46 @@ inline void Field::set_allocated_default_value(::std::string* default_value) { // optional string name = 1; inline void Enum::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Enum::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Enum::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Enum.name) } inline void Enum::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Enum.name) } -inline void Enum::set_name(const char* value, size_t size) { +inline void Enum::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Enum.name) } inline ::std::string* Enum::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Enum::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Enum.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +inline ::std::string* Enum::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Enum.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } inline void Enum::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -1413,9 +1681,22 @@ inline void Enum::set_allocated_name(::std::string* name) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name) } +inline void Enum::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Enum.name) +} // repeated .google.protobuf.EnumValue enumvalue = 2; inline int Enum::enumvalue_size() const { @@ -1479,7 +1760,7 @@ Enum::options() const { // optional .google.protobuf.SourceContext source_context = 4; inline bool Enum::has_source_context() const { - return !_is_default_instance_ && source_context_ != NULL; + return this != internal_default_instance() && source_context_ != NULL; } inline void Enum::clear_source_context() { if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; @@ -1487,12 +1768,13 @@ inline void Enum::clear_source_context() { } inline const ::google::protobuf::SourceContext& Enum::source_context() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.source_context) - return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_; + return source_context_ != NULL ? *source_context_ + : *::google::protobuf::SourceContext::internal_default_instance(); } inline ::google::protobuf::SourceContext* Enum::mutable_source_context() { if (source_context_ == NULL) { - source_context_ = new ::google::protobuf::SourceContext; + _slow_mutable_source_context(); } // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.source_context) return source_context_; @@ -1500,12 +1782,24 @@ inline ::google::protobuf::SourceContext* Enum::mutable_source_context() { inline ::google::protobuf::SourceContext* Enum::release_source_context() { // @@protoc_insertion_point(field_release:google.protobuf.Enum.source_context) - ::google::protobuf::SourceContext* temp = source_context_; - source_context_ = NULL; - return temp; + if (GetArenaNoVirtual() != NULL) { + return _slow_release_source_context(); + } else { + ::google::protobuf::SourceContext* temp = source_context_; + source_context_ = NULL; + return temp; + } } -inline void Enum::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { - delete source_context_; +inline void Enum::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete source_context_; + } + if (source_context != NULL) { + if (message_arena != NULL) { + message_arena->Own(source_context); + } + } source_context_ = source_context; if (source_context) { @@ -1535,37 +1829,46 @@ inline void Enum::set_syntax(::google::protobuf::Syntax value) { // optional string name = 1; inline void EnumValue::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& EnumValue::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void EnumValue::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name) } inline void EnumValue::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValue.name) } -inline void EnumValue::set_name(const char* value, size_t size) { +inline void EnumValue::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValue.name) } inline ::std::string* EnumValue::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* EnumValue::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +inline ::std::string* EnumValue::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumValue.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } inline void EnumValue::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -1573,9 +1876,22 @@ inline void EnumValue::set_allocated_name(::std::string* name) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name) } +inline void EnumValue::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValue.name) +} // optional int32 number = 2; inline void EnumValue::clear_number() { @@ -1627,37 +1943,46 @@ EnumValue::options() const { // optional string name = 1; inline void Option::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Option::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Option.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Option::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Option.name) } inline void Option::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Option.name) } -inline void Option::set_name(const char* value, size_t size) { +inline void Option::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Option.name) } inline ::std::string* Option::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Option.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Option::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Option.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +inline ::std::string* Option::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Option.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } inline void Option::set_allocated_name(::std::string* name) { if (name != NULL) { @@ -1665,13 +1990,26 @@ inline void Option::set_allocated_name(::std::string* name) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name) } +inline void Option::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.name) +} // optional .google.protobuf.Any value = 2; inline bool Option::has_value() const { - return !_is_default_instance_ && value_ != NULL; + return this != internal_default_instance() && value_ != NULL; } inline void Option::clear_value() { if (GetArenaNoVirtual() == NULL && value_ != NULL) delete value_; @@ -1679,12 +2017,13 @@ inline void Option::clear_value() { } inline const ::google::protobuf::Any& Option::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Option.value) - return value_ != NULL ? *value_ : *default_instance_->value_; + return value_ != NULL ? *value_ + : *::google::protobuf::Any::internal_default_instance(); } inline ::google::protobuf::Any* Option::mutable_value() { if (value_ == NULL) { - value_ = new ::google::protobuf::Any; + _slow_mutable_value(); } // @@protoc_insertion_point(field_mutable:google.protobuf.Option.value) return value_; @@ -1692,12 +2031,24 @@ inline ::google::protobuf::Any* Option::mutable_value() { inline ::google::protobuf::Any* Option::release_value() { // @@protoc_insertion_point(field_release:google.protobuf.Option.value) - ::google::protobuf::Any* temp = value_; - value_ = NULL; - return temp; + if (GetArenaNoVirtual() != NULL) { + return _slow_release_value(); + } else { + ::google::protobuf::Any* temp = value_; + value_ = NULL; + return temp; + } } -inline void Option::set_allocated_value(::google::protobuf::Any* value) { - delete value_; +inline void Option::set_allocated_value(::google::protobuf::Any* value) { + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete value_; + } + if (value != NULL) { + if (message_arena != NULL) { + message_arena->Own(value); + } + } value_ = value; if (value) { diff --git a/src/google/protobuf/type.proto b/src/google/protobuf/type.proto index 1c9cf53d..504cd25d 100644 --- a/src/google/protobuf/type.proto +++ b/src/google/protobuf/type.proto @@ -36,10 +36,10 @@ import "google/protobuf/any.proto"; import "google/protobuf/source_context.proto"; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option cc_enable_arenas = true; option java_package = "com.google.protobuf"; option java_outer_classname = "TypeProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; // A protocol buffer message type. diff --git a/src/google/protobuf/unittest.proto b/src/google/protobuf/unittest.proto index d5206d24..cc2f4b34 100644 --- a/src/google/protobuf/unittest.proto +++ b/src/google/protobuf/unittest.proto @@ -878,3 +878,11 @@ service TestService { message BarRequest {} message BarResponse {} +message TestJsonName { + optional int32 field_name1 = 1; + optional int32 fieldName2 = 2; + optional int32 FieldName3 = 3; + optional int32 _field_name4 = 4; + optional int32 FIELD_NAME5 = 5; + optional int32 field_name6 = 6 [json_name = "@type"]; +} diff --git a/src/google/protobuf/unknown_field_set.cc b/src/google/protobuf/unknown_field_set.cc index 8ee99d48..bca3fbf8 100644 --- a/src/google/protobuf/unknown_field_set.cc +++ b/src/google/protobuf/unknown_field_set.cc @@ -39,6 +39,7 @@ #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream_impl.h> +#include <google/protobuf/metadata.h> #include <google/protobuf/wire_format.h> #include <google/protobuf/stubs/stl_util.h> @@ -116,6 +117,12 @@ void UnknownFieldSet::MergeFromAndDestroy(UnknownFieldSet* other) { other->fields_ = NULL; } +void UnknownFieldSet::MergeToInternalMetdata( + const UnknownFieldSet& other, + internal::InternalMetadataWithArena* metadata) { + metadata->mutable_unknown_fields()->MergeFrom(other); +} + int UnknownFieldSet::SpaceUsedExcludingSelf() const { if (fields_ == NULL) return 0; diff --git a/src/google/protobuf/unknown_field_set.h b/src/google/protobuf/unknown_field_set.h index aa752916..c2ad8918 100644 --- a/src/google/protobuf/unknown_field_set.h +++ b/src/google/protobuf/unknown_field_set.h @@ -52,6 +52,7 @@ namespace protobuf { class ZeroCopyInputStream; // zero_copy_stream.h } namespace internal { + class InternalMetadataWithArena; // metadata.h class WireFormat; // wire_format.h class MessageSetFieldSkipperUsingCord; // extension_set_heavy.cc @@ -92,6 +93,13 @@ class LIBPROTOBUF_EXPORT UnknownFieldSet { // Similar to above, but this function will destroy the contents of other. void MergeFromAndDestroy(UnknownFieldSet* other); + // Merge the contents an UnknownFieldSet with the UnknownFieldSet in + // *metadata, if there is one. If *metadata doesn't have an UnknownFieldSet + // then add one to it and make it be a copy of the first arg. + static void MergeToInternalMetdata( + const UnknownFieldSet& other, + internal::InternalMetadataWithArena* metadata); + // Swaps the contents of some other UnknownFieldSet with this one. inline void Swap(UnknownFieldSet* x); @@ -175,7 +183,7 @@ class LIBPROTOBUF_EXPORT UnknownField { TYPE_GROUP }; - // The field's tag number, as seen on the wire. + // The field's field number, as seen on the wire. inline int number() const; // The field type. @@ -204,7 +212,7 @@ class LIBPROTOBUF_EXPORT UnknownField { void SerializeLengthDelimitedNoTag(io::CodedOutputStream* output) const; uint8* SerializeLengthDelimitedNoTagToArray(uint8* target) const; - inline int GetLengthDelimitedSize() const; + inline size_t GetLengthDelimitedSize() const; private: friend class UnknownFieldSet; @@ -330,9 +338,9 @@ inline UnknownFieldSet* UnknownField::mutable_group() { return group_; } -inline int UnknownField::GetLengthDelimitedSize() const { +inline size_t UnknownField::GetLengthDelimitedSize() const { GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type()); - return static_cast<int>(length_delimited_.string_value_->size()); + return length_delimited_.string_value_->size(); } inline void UnknownField::SetType(Type type) { diff --git a/src/google/protobuf/util/field_comparator.h b/src/google/protobuf/util/field_comparator.h index 715560ed..3c70a314 100644 --- a/src/google/protobuf/util/field_comparator.h +++ b/src/google/protobuf/util/field_comparator.h @@ -169,7 +169,7 @@ class LIBPROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator { }; // Defines the map to store the tolerances for floating point comparison. - typedef map<const FieldDescriptor*, Tolerance> ToleranceMap; + typedef std::map<const FieldDescriptor*, Tolerance> ToleranceMap; // The following methods get executed when CompareFields is called for the // basic types (instead of submessages). They return true on success. One diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc index ef8da427..eeb55c6b 100644 --- a/src/google/protobuf/util/internal/datapiece.cc +++ b/src/google/protobuf/util/internal/datapiece.cc @@ -259,7 +259,8 @@ StatusOr<string> DataPiece::ToBytes() const { } } -StatusOr<int> DataPiece::ToEnum(const google::protobuf::Enum* enum_type) const { +StatusOr<int> DataPiece::ToEnum(const google::protobuf::Enum* enum_type, + bool use_lower_camel_for_enums) const { if (type_ == TYPE_NULL) return google::protobuf::NULL_VALUE; if (type_ == TYPE_STRING) { @@ -268,20 +269,34 @@ StatusOr<int> DataPiece::ToEnum(const google::protobuf::Enum* enum_type) const { const google::protobuf::EnumValue* value = FindEnumValueByNameOrNull(enum_type, enum_name); if (value != NULL) return value->number(); + + // Check if int version of enum is sent as string. + StatusOr<int32> int_value = ToInt32(); + if (int_value.ok()) { + if (const google::protobuf::EnumValue* enum_value = + FindEnumValueByNumberOrNull(enum_type, int_value.ValueOrDie())) { + return enum_value->number(); + } + } + // Next try a normalized name. for (string::iterator it = enum_name.begin(); it != enum_name.end(); ++it) { *it = *it == '-' ? '_' : ascii_toupper(*it); } value = FindEnumValueByNameOrNull(enum_type, enum_name); if (value != NULL) return value->number(); - } else { - StatusOr<int32> value = ToInt32(); - if (value.ok()) { - if (const google::protobuf::EnumValue* enum_value = - FindEnumValueByNumberOrNull(enum_type, value.ValueOrDie())) { - return enum_value->number(); - } + + // If use_lower_camel_for_enums is true try with enum name without + // underscore. This will also accept camel case names as the enum_name has + // been normalized before. + if (use_lower_camel_for_enums) { + value = FindEnumValueByNameWithoutUnderscoreOrNull(enum_type, enum_name); + if (value != NULL) return value->number(); } + } else { + // We don't need to check whether the value is actually declared in the + // enum because we preserve unknown enum values as well. + return ToInt32(); } return InvalidArgument( ValueAsStringOrDefault("Cannot find enum with given value.")); @@ -354,6 +369,7 @@ bool DataPiece::DecodeBase64(StringPiece src, string* dest) const { void DataPiece::InternalCopy(const DataPiece& other) { type_ = other.type_; + use_strict_base64_decoding_ = other.use_strict_base64_decoding_; switch (type_) { case TYPE_INT32: case TYPE_INT64: diff --git a/src/google/protobuf/util/internal/datapiece.h b/src/google/protobuf/util/internal/datapiece.h index e82cdbac..83516d09 100644 --- a/src/google/protobuf/util/internal/datapiece.h +++ b/src/google/protobuf/util/internal/datapiece.h @@ -76,13 +76,22 @@ class LIBPROTOBUF_EXPORT DataPiece { }; // Constructors and Destructor - explicit DataPiece(const int32 value) : type_(TYPE_INT32), i32_(value) {} - explicit DataPiece(const int64 value) : type_(TYPE_INT64), i64_(value) {} - explicit DataPiece(const uint32 value) : type_(TYPE_UINT32), u32_(value) {} - explicit DataPiece(const uint64 value) : type_(TYPE_UINT64), u64_(value) {} - explicit DataPiece(const double value) : type_(TYPE_DOUBLE), double_(value) {} - explicit DataPiece(const float value) : type_(TYPE_FLOAT), float_(value) {} - explicit DataPiece(const bool value) : type_(TYPE_BOOL), bool_(value) {} + explicit DataPiece(const int32 value) + : type_(TYPE_INT32), i32_(value), use_strict_base64_decoding_(false) {} + explicit DataPiece(const int64 value) + : type_(TYPE_INT64), i64_(value), use_strict_base64_decoding_(false) {} + explicit DataPiece(const uint32 value) + : type_(TYPE_UINT32), u32_(value), use_strict_base64_decoding_(false) {} + explicit DataPiece(const uint64 value) + : type_(TYPE_UINT64), u64_(value), use_strict_base64_decoding_(false) {} + explicit DataPiece(const double value) + : type_(TYPE_DOUBLE), + double_(value), + use_strict_base64_decoding_(false) {} + explicit DataPiece(const float value) + : type_(TYPE_FLOAT), float_(value), use_strict_base64_decoding_(false) {} + explicit DataPiece(const bool value) + : type_(TYPE_BOOL), bool_(value), use_strict_base64_decoding_(false) {} DataPiece(StringPiece value, bool use_strict_base64_decoding) : type_(TYPE_STRING), str_(StringPiecePod::CreateFromStringPiece(value)), @@ -108,6 +117,8 @@ class LIBPROTOBUF_EXPORT DataPiece { // Accessors Type type() const { return type_; } + bool use_strict_base64_decoding() { return use_strict_base64_decoding_; } + StringPiece str() const { GOOGLE_LOG_IF(DFATAL, type_ != TYPE_STRING) << "Not a string type."; return str_; @@ -148,16 +159,20 @@ class LIBPROTOBUF_EXPORT DataPiece { // string, first attempts conversion by name, trying names as follows: // 1) the directly provided string value. // 2) the value upper-cased and replacing '-' by '_' + // 3) if use_lower_camel_for_enums is true it also attempts by comparing + // enum name without underscore with the value upper cased above. // If the value is not a string, attempts to convert to a 32-bit integer. // If none of these succeeds, returns a conversion error status. - util::StatusOr<int> ToEnum(const google::protobuf::Enum* enum_type) const; + util::StatusOr<int> ToEnum(const google::protobuf::Enum* enum_type, + bool use_lower_camel_for_enums) const; private: // Disallow implicit constructor. DataPiece(); // Helper to create NULL or ENUM types. - DataPiece(Type type, int32 val) : type_(type), i32_(val) {} + DataPiece(Type type, int32 val) + : type_(type), i32_(val), use_strict_base64_decoding_(false) {} // For numeric conversion between // int32, int64, uint32, uint64, double, float and bool diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.cc b/src/google/protobuf/util/internal/default_value_objectwriter.cc index fa31f763..3013e12f 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.cc +++ b/src/google/protobuf/util/internal/default_value_objectwriter.cc @@ -557,26 +557,29 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::EndList() { void DefaultValueObjectWriter::RenderDataPiece(StringPiece name, const DataPiece& data) { MaybePopulateChildrenOfAny(current_); - util::StatusOr<string> data_string = data.ToString(); if (current_->type() != NULL && current_->type()->name() == kAnyType && - name == "@type" && data_string.ok()) { - const string& string_value = data_string.ValueOrDie(); - // If the type of current_ is "Any" and its "@type" field is being set here, - // sets the type of current_ to be the type specified by the "@type". - util::StatusOr<const google::protobuf::Type*> found_type = - typeinfo_->ResolveTypeUrl(string_value); - if (!found_type.ok()) { - GOOGLE_LOG(WARNING) << "Failed to resolve type '" << string_value << "'."; - } else { - current_->set_type(found_type.ValueOrDie()); - } - current_->set_is_any(true); - // If the "@type" field is placed after other fields, we should populate - // other children of primitive type now. Otherwise, we should wait until the - // first value field is rendered before we populate the children, because - // the "value" field of a Any message could be omitted. - if (current_->number_of_children() > 1 && current_->type() != NULL) { - current_->PopulateChildren(typeinfo_); + name == "@type") { + util::StatusOr<string> data_string = data.ToString(); + if (data_string.ok()) { + const string& string_value = data_string.ValueOrDie(); + // If the type of current_ is "Any" and its "@type" field is being set + // here, sets the type of current_ to be the type specified by the + // "@type". + util::StatusOr<const google::protobuf::Type*> found_type = + typeinfo_->ResolveTypeUrl(string_value); + if (!found_type.ok()) { + GOOGLE_LOG(WARNING) << "Failed to resolve type '" << string_value << "'."; + } else { + current_->set_type(found_type.ValueOrDie()); + } + current_->set_is_any(true); + // If the "@type" field is placed after other fields, we should populate + // other children of primitive type now. Otherwise, we should wait until + // the first value field is rendered before we populate the children, + // because the "value" field of a Any message could be omitted. + if (current_->number_of_children() > 1 && current_->type() != NULL) { + current_->PopulateChildren(typeinfo_); + } } } Node* child = current_->FindChild(name); diff --git a/src/google/protobuf/util/internal/error_listener.h b/src/google/protobuf/util/internal/error_listener.h index 3f063936..1dc814a3 100644 --- a/src/google/protobuf/util/internal/error_listener.h +++ b/src/google/protobuf/util/internal/error_listener.h @@ -57,7 +57,7 @@ class LIBPROTOBUF_EXPORT ErrorListener { // Reports an invalid name at the given location. virtual void InvalidName(const LocationTrackerInterface& loc, - StringPiece unknown_name, StringPiece message) = 0; + StringPiece invalid_name, StringPiece message) = 0; // Reports an invalid value for a field. virtual void InvalidValue(const LocationTrackerInterface& loc, @@ -82,7 +82,7 @@ class LIBPROTOBUF_EXPORT NoopErrorListener : public ErrorListener { virtual ~NoopErrorListener() {} virtual void InvalidName(const LocationTrackerInterface& loc, - StringPiece unknown_name, StringPiece message) {} + StringPiece invalid_name, StringPiece message) {} virtual void InvalidValue(const LocationTrackerInterface& loc, StringPiece type_name, StringPiece value) {} diff --git a/src/google/protobuf/util/internal/json_objectwriter.cc b/src/google/protobuf/util/internal/json_objectwriter.cc index b84210c1..6e4edd88 100644 --- a/src/google/protobuf/util/internal/json_objectwriter.cc +++ b/src/google/protobuf/util/internal/json_objectwriter.cc @@ -147,7 +147,7 @@ JsonObjectWriter* JsonObjectWriter::RenderBytes(StringPiece name, string base64; if (use_websafe_base64_for_bytes_) - WebSafeBase64Escape(value.ToString(), &base64); + WebSafeBase64EscapeWithPadding(value.ToString(), &base64); else Base64Escape(value, &base64); @@ -164,19 +164,32 @@ JsonObjectWriter* JsonObjectWriter::RenderNull(StringPiece name) { return RenderSimple(name, "null"); } +JsonObjectWriter* JsonObjectWriter::RenderNullAsEmpty(StringPiece name) { + return RenderSimple(name, ""); +} + void JsonObjectWriter::WritePrefix(StringPiece name) { bool not_first = !element()->is_first(); if (not_first) WriteChar(','); if (not_first || !element()->is_root()) NewLine(); - if (!name.empty()) { + bool empty_key_ok = GetAndResetEmptyKeyOk(); + if (!name.empty() || empty_key_ok) { WriteChar('"'); - ArrayByteSource source(name); - JsonEscaping::Escape(&source, &sink_); + if (!name.empty()) { + ArrayByteSource source(name); + JsonEscaping::Escape(&source, &sink_); + } stream_->WriteString("\":"); if (!indent_string_.empty()) WriteChar(' '); } } +bool JsonObjectWriter::GetAndResetEmptyKeyOk() { + bool retval = empty_name_ok_for_next_key_; + empty_name_ok_for_next_key_ = false; + return retval; +} + } // namespace converter } // namespace util } // namespace protobuf diff --git a/src/google/protobuf/util/internal/json_objectwriter.h b/src/google/protobuf/util/internal/json_objectwriter.h index cb7e2fb3..31edc292 100644 --- a/src/google/protobuf/util/internal/json_objectwriter.h +++ b/src/google/protobuf/util/internal/json_objectwriter.h @@ -93,7 +93,8 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { stream_(out), sink_(out), indent_string_(indent_string.ToString()), - use_websafe_base64_for_bytes_(false) {} + use_websafe_base64_for_bytes_(false), + empty_name_ok_for_next_key_(false) {} virtual ~JsonObjectWriter(); // ObjectWriter methods. @@ -111,11 +112,19 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { virtual JsonObjectWriter* RenderString(StringPiece name, StringPiece value); virtual JsonObjectWriter* RenderBytes(StringPiece name, StringPiece value); virtual JsonObjectWriter* RenderNull(StringPiece name); + virtual JsonObjectWriter* RenderNullAsEmpty(StringPiece name); void set_use_websafe_base64_for_bytes(bool value) { use_websafe_base64_for_bytes_ = value; } + // Whether empty strings should be rendered for the next JSON key. This + // setting is only valid until the next key is rendered, after which it gets + // reset to false. + virtual void empty_name_ok_for_next_key() { + empty_name_ok_for_next_key_ = true; + } + protected: class LIBPROTOBUF_EXPORT Element : public BaseElement { public: @@ -195,6 +204,10 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { // Writes an individual character to the output. void WriteChar(const char c) { stream_->WriteRaw(&c, sizeof(c)); } + // Returns the current value of empty_name_ok_for_next_key_ and resets it to + // false. + bool GetAndResetEmptyKeyOk(); + google::protobuf::scoped_ptr<Element> element_; google::protobuf::io::CodedOutputStream* stream_; ByteSinkWrapper sink_; @@ -204,6 +217,11 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { // to regular base64 encoding. bool use_websafe_base64_for_bytes_; + // Whether empty strings should be rendered for the next JSON key. This + // setting is only valid until the next key is rendered, after which it gets + // reset to false. + bool empty_name_ok_for_next_key_; + GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(JsonObjectWriter); }; diff --git a/src/google/protobuf/util/internal/json_objectwriter_test.cc b/src/google/protobuf/util/internal/json_objectwriter_test.cc index b87b06ac..bbd9d78a 100644 --- a/src/google/protobuf/util/internal/json_objectwriter_test.cc +++ b/src/google/protobuf/util/internal/json_objectwriter_test.cc @@ -299,11 +299,11 @@ TEST_F(JsonObjectWriterTest, TestWebsafeByteEncoding) { ow_ = new JsonObjectWriter("", out_stream_); ow_->set_use_websafe_base64_for_bytes(true); ow_->StartObject("") - ->RenderBytes("bytes", "\x03\xef\xc0") + ->RenderBytes("bytes", "\x03\xef\xc0\x10") ->EndObject(); // Test that we get websafe base64 encoding when explicitly asked. - EXPECT_EQ("{\"bytes\":\"A-_A\"}", + EXPECT_EQ("{\"bytes\":\"A-_AEA==\"}", output_.substr(0, out_stream_->ByteCount())); } diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc index 39be7b03..fc61dfc3 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.cc +++ b/src/google/protobuf/util/internal/json_stream_parser.cc @@ -107,7 +107,8 @@ JsonStreamParser::JsonStreamParser(ObjectWriter* ow) parsed_storage_(), string_open_(0), chunk_storage_(), - coerce_to_utf8_(false) { + coerce_to_utf8_(false), + allow_empty_null_(false) { // Initialize the stack with a single value to be parsed. stack_.push(VALUE); } @@ -277,6 +278,10 @@ util::Status JsonStreamParser::ParseValue(TokenType type) { case UNKNOWN: return ReportUnknown("Expected a value."); default: { + if (allow_empty_null_ && IsEmptyNullAllowed(type)) { + return ParseEmptyNull(); + } + // Special case for having been cut off while parsing, wait for more data. // This handles things like 'fals' being at the end of the string, we // don't know if the next char would be e, completing it, or something @@ -293,8 +298,8 @@ util::Status JsonStreamParser::ParseString() { util::Status result = ParseStringHelper(); if (result.ok()) { ow_->RenderString(key_, parsed_); - key_.clear(); - parsed_.clear(); + key_ = StringPiece(); + parsed_ = StringPiece(); parsed_storage_.clear(); } return result; @@ -471,17 +476,17 @@ util::Status JsonStreamParser::ParseNumber() { switch (number.type) { case NumberResult::DOUBLE: ow_->RenderDouble(key_, number.double_val); - key_.clear(); + key_ = StringPiece(); break; case NumberResult::INT: ow_->RenderInt64(key_, number.int_val); - key_.clear(); + key_ = StringPiece(); break; case NumberResult::UINT: ow_->RenderUint64(key_, number.uint_val); - key_.clear(); + key_ = StringPiece(); break; default: @@ -565,7 +570,7 @@ util::Status JsonStreamParser::HandleBeginObject() { GOOGLE_DCHECK_EQ('{', *p_.data()); Advance(); ow_->StartObject(key_); - key_.clear(); + key_ = StringPiece(); stack_.push(ENTRY); return util::Status::OK; } @@ -615,7 +620,7 @@ util::Status JsonStreamParser::ParseEntry(TokenType type) { } else { key_ = parsed_; } - parsed_.clear(); + parsed_ = StringPiece(); } } else if (type == BEGIN_KEY) { // Key is a bare key (back compat), create a StringPiece pointing to it. @@ -648,7 +653,7 @@ util::Status JsonStreamParser::HandleBeginArray() { GOOGLE_DCHECK_EQ('[', *p_.data()); Advance(); ow_->StartList(key_); - key_.clear(); + key_ = StringPiece(); stack_.push(ARRAY_VALUE); return util::Status::OK; } @@ -665,7 +670,8 @@ util::Status JsonStreamParser::ParseArrayValue(TokenType type) { } // The ParseValue call may push something onto the stack so we need to make - // sure an ARRAY_MID is after it, so we push it on now. + // sure an ARRAY_MID is after it, so we push it on now. Also, the parsing of + // empty-null array value is relying on this ARRAY_MID token. stack_.push(ARRAY_MID); util::Status result = ParseValue(type); if (result == util::Status::CANCELLED) { @@ -699,25 +705,37 @@ util::Status JsonStreamParser::ParseArrayMid(TokenType type) { util::Status JsonStreamParser::ParseTrue() { ow_->RenderBool(key_, true); - key_.clear(); + key_ = StringPiece(); p_.remove_prefix(true_len); return util::Status::OK; } util::Status JsonStreamParser::ParseFalse() { ow_->RenderBool(key_, false); - key_.clear(); + key_ = StringPiece(); p_.remove_prefix(false_len); return util::Status::OK; } util::Status JsonStreamParser::ParseNull() { ow_->RenderNull(key_); - key_.clear(); + key_ = StringPiece(); p_.remove_prefix(null_len); return util::Status::OK; } +util::Status JsonStreamParser::ParseEmptyNull() { + ow_->RenderNull(key_); + key_ = StringPiece(); + return util::Status::OK; +} + +bool JsonStreamParser::IsEmptyNullAllowed(TokenType type) { + if (stack_.empty()) return false; + return (stack_.top() == ARRAY_MID && type == VALUE_SEPARATOR) || + stack_.top() == OBJ_MID; +} + util::Status JsonStreamParser::ReportFailure(StringPiece message) { static const int kContextLength = 20; const char* p_start = p_.data(); diff --git a/src/google/protobuf/util/internal/json_stream_parser.h b/src/google/protobuf/util/internal/json_stream_parser.h index 0278c28f..78b35cc2 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.h +++ b/src/google/protobuf/util/internal/json_stream_parser.h @@ -179,6 +179,10 @@ class LIBPROTOBUF_EXPORT JsonStreamParser { util::Status ParseTrue(); util::Status ParseFalse(); util::Status ParseNull(); + util::Status ParseEmptyNull(); + + // Whether an empty-null is allowed in the current state. + bool IsEmptyNullAllowed(TokenType type); // Report a failure as a util::Status. util::Status ReportFailure(StringPiece message); @@ -247,6 +251,10 @@ class LIBPROTOBUF_EXPORT JsonStreamParser { // Whether to allow non UTF-8 encoded input and replace invalid code points. bool coerce_to_utf8_; + // Whether allows empty string represented null array value or object entry + // value. + bool allow_empty_null_; + GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(JsonStreamParser); }; diff --git a/src/google/protobuf/util/internal/json_stream_parser_test.cc b/src/google/protobuf/util/internal/json_stream_parser_test.cc index 059ea6d8..b30d529f 100644 --- a/src/google/protobuf/util/internal/json_stream_parser_test.cc +++ b/src/google/protobuf/util/internal/json_stream_parser_test.cc @@ -81,12 +81,15 @@ using util::Status; // For each test we split the input string on every possible character to ensure // the parser is able to handle arbitrarily split input for all cases. We also // do a final test of the entire test case one character at a time. +// +// It is verified that expected calls to the mocked objects are in sequence. class JsonStreamParserTest : public ::testing::Test { protected: JsonStreamParserTest() : mock_(), ow_(&mock_) {} virtual ~JsonStreamParserTest() {} - util::Status RunTest(StringPiece json, int split, bool coerce_utf8 = false) { + util::Status RunTest(StringPiece json, int split, bool coerce_utf8 = false, + bool allow_empty_null = false) { JsonStreamParser parser(&mock_); // Special case for split == length, test parsing one character at a time. @@ -116,8 +119,10 @@ class JsonStreamParserTest : public ::testing::Test { return result; } - void DoTest(StringPiece json, int split, bool coerce_utf8 = false) { - util::Status result = RunTest(json, split, coerce_utf8); + void DoTest(StringPiece json, int split, bool coerce_utf8 = false, + bool allow_empty_null = false) { + util::Status result = + RunTest(json, split, coerce_utf8, allow_empty_null); if (!result.ok()) { GOOGLE_LOG(WARNING) << result; } @@ -125,14 +130,16 @@ class JsonStreamParserTest : public ::testing::Test { } void DoErrorTest(StringPiece json, int split, StringPiece error_prefix, - bool coerce_utf8 = false) { - util::Status result = RunTest(json, split, coerce_utf8); + bool coerce_utf8 = false, bool allow_empty_null = false) { + util::Status result = + RunTest(json, split, coerce_utf8, allow_empty_null); EXPECT_EQ(util::error::INVALID_ARGUMENT, result.error_code()); StringPiece error_message(result.error_message()); EXPECT_EQ(error_prefix, error_message.substr(0, error_prefix.size())); } + ::testing::InSequence in_sequence_; MockObjectWriter mock_; ExpectingObjectWriter ow_; }; @@ -335,6 +342,7 @@ TEST_F(JsonStreamParserTest, ArrayValues) { } } + // - object containing array, object, value (true, false, null, num, string) TEST_F(JsonStreamParserTest, ObjectValues) { StringPiece str = diff --git a/src/google/protobuf/util/internal/object_writer.h b/src/google/protobuf/util/internal/object_writer.h index 5781aa1e..b6fbd19b 100644 --- a/src/google/protobuf/util/internal/object_writer.h +++ b/src/google/protobuf/util/internal/object_writer.h @@ -119,6 +119,13 @@ class LIBPROTOBUF_EXPORT ObjectWriter { return use_strict_base64_decoding_; } + // Whether empty strings should be rendered for the next name for Start/Render + // calls. This setting is only valid until the next key is rendered, after + // which it gets reset. + // It is up to the derived classes to interpret this and render accordingly. + // Default implementation ignores this setting. + virtual void empty_name_ok_for_next_key() {} + protected: ObjectWriter() : use_strict_base64_decoding_(true) {} diff --git a/src/google/protobuf/util/internal/proto_writer.cc b/src/google/protobuf/util/internal/proto_writer.cc index 0c38aeb9..4dcf4c3b 100644 --- a/src/google/protobuf/util/internal/proto_writer.cc +++ b/src/google/protobuf/util/internal/proto_writer.cc @@ -65,6 +65,7 @@ ProtoWriter::ProtoWriter(TypeResolver* type_resolver, own_typeinfo_(true), done_(false), ignore_unknown_fields_(false), + use_lower_camel_for_enums_(false), element_(NULL), size_insert_(), output_(output), @@ -83,6 +84,7 @@ ProtoWriter::ProtoWriter(const TypeInfo* typeinfo, own_typeinfo_(false), done_(false), ignore_unknown_fields_(false), + use_lower_camel_for_enums_(false), element_(NULL), size_insert_(), output_(output), @@ -264,8 +266,9 @@ inline Status WriteString(int field_number, const DataPiece& data, // Writes an ENUM field, including tag, to the stream. inline Status WriteEnum(int field_number, const DataPiece& data, const google::protobuf::Enum* enum_type, - CodedOutputStream* stream) { - StatusOr<int> e = data.ToEnum(enum_type); + CodedOutputStream* stream, + bool use_lower_camel_for_enums) { + StatusOr<int> e = data.ToEnum(enum_type, use_lower_camel_for_enums); if (e.ok()) { WireFormatLite::WriteEnum(field_number, e.ValueOrDie(), stream); } @@ -662,7 +665,7 @@ ProtoWriter* ProtoWriter::RenderPrimitiveField( case google::protobuf::Field_Kind_TYPE_ENUM: { status = WriteEnum(field.number(), data, typeinfo_->GetEnumByTypeUrl(field.type_url()), - stream_.get()); + stream_.get(), use_lower_camel_for_enums_); break; } default: // TYPE_GROUP or TYPE_MESSAGE diff --git a/src/google/protobuf/util/internal/proto_writer.h b/src/google/protobuf/util/internal/proto_writer.h index 7f1108ab..21dff88d 100644 --- a/src/google/protobuf/util/internal/proto_writer.h +++ b/src/google/protobuf/util/internal/proto_writer.h @@ -148,6 +148,10 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { ignore_unknown_fields_ = ignore_unknown_fields; } + void set_use_lower_camel_for_enums(bool use_lower_camel_for_enums) { + use_lower_camel_for_enums_ = use_lower_camel_for_enums; + } + protected: class LIBPROTOBUF_EXPORT ProtoElement : public BaseElement, public LocationTrackerInterface { public: @@ -308,6 +312,10 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { // If true, don't report unknown field names to the listener. bool ignore_unknown_fields_; + // If true, check if enum name in camel case or without underscore matches the + // field name. + bool use_lower_camel_for_enums_; + // Variable for internal state processing: // element_ : the current element. // size_insert_: sizes of nested messages. diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc index 0048d75b..150f3cf1 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource.cc @@ -288,6 +288,8 @@ StatusOr<uint32> ProtoStreamObjectSource::RenderMap( return Status(util::error::INTERNAL, "Invalid map entry."); } ASSIGN_OR_RETURN(map_key, MapKeyDefaultValueAsString(*key_field)); + // Key is empty, force it to render as empty (for string values). + ow->empty_name_ok_for_next_key(); } RETURN_IF_ERROR(RenderField(field, map_key, ow)); } else { @@ -857,7 +859,8 @@ Status ProtoStreamObjectSource::RenderNonMessageField( // up. const google::protobuf::Enum* en = typeinfo_->GetEnumByTypeUrl(field->type_url()); - // Lookup the name of the enum, and render that. Skips unknown enums. + // Lookup the name of the enum, and render that. Unknown enum values + // are printed as integers. if (en != NULL) { const google::protobuf::EnumValue* enum_value = FindEnumValueByNumber(*en, buffer32); @@ -866,9 +869,11 @@ Status ProtoStreamObjectSource::RenderNonMessageField( ow->RenderString(field_name, ToCamelCase(enum_value->name())); else ow->RenderString(field_name, enum_value->name()); + } else { + ow->RenderInt32(field_name, buffer32); } } else { - GOOGLE_LOG(INFO) << "Unknown enum skipped: " << field->type_url(); + ow->RenderInt32(field_name, buffer32); } break; } @@ -1099,6 +1104,8 @@ const google::protobuf::EnumValue* FindEnumValueByNumber( // TODO(skarvaje): Look into optimizing this by not doing computation on // double. const string FormatNanos(uint32 nanos) { + if (nanos == 0) return ""; + const char* format = (nanos % 1000 != 0) ? "%.9f" : (nanos % 1000000 != 0) ? "%.6f" : "%.3f"; string formatted = diff --git a/src/google/protobuf/util/internal/protostream_objectsource.h b/src/google/protobuf/util/internal/protostream_objectsource.h index 243f85b2..adecfbd3 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.h +++ b/src/google/protobuf/util/internal/protostream_objectsource.h @@ -129,6 +129,28 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { bool include_start_and_end, ObjectWriter* ow) const; + // Renders a repeating field (packed or unpacked). Returns the next tag after + // reading all sequential repeating elements. The caller should use this tag + // before reading more tags from the stream. + virtual util::StatusOr<uint32> RenderList( + const google::protobuf::Field* field, StringPiece name, uint32 list_tag, + ObjectWriter* ow) const; + + // Looks up a field and verify its consistency with wire type in tag. + const google::protobuf::Field* FindAndVerifyField( + const google::protobuf::Type& type, uint32 tag) const; + + // Renders a field value to the ObjectWriter. + util::Status RenderField(const google::protobuf::Field* field, + StringPiece field_name, ObjectWriter* ow) const; + + // Reads field value according to Field spec in 'field' and returns the read + // value as string. This only works for primitive datatypes (no message + // types). + const string ReadFieldValueAsString( + const google::protobuf::Field& field) const; + + private: ProtoStreamObjectSource(google::protobuf::io::CodedInputStream* stream, const TypeInfo* typeinfo, @@ -138,19 +160,9 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { const google::protobuf::Type&, StringPiece, ObjectWriter*); - // Looks up a field and verify its consistency with wire type in tag. - const google::protobuf::Field* FindAndVerifyField( - const google::protobuf::Type& type, uint32 tag) const; - // TODO(skarvaje): Mark these methods as non-const as they modify internal // state (stream_). // - // Renders a repeating field (packed or unpacked). - // Returns the next tag after reading all sequential repeating elements. The - // caller should use this tag before reading more tags from the stream. - util::StatusOr<uint32> RenderList(const google::protobuf::Field* field, - StringPiece name, uint32 list_tag, - ObjectWriter* ow) const; // Renders a NWP map. // Returns the next tag after reading all map entries. The caller should use // this tag before reading more tags from the stream. @@ -234,10 +246,6 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { static void DeleteRendererMap(); static TypeRenderer* FindTypeRenderer(const string& type_url); - // Renders a field value to the ObjectWriter. - util::Status RenderField(const google::protobuf::Field* field, - StringPiece field_name, ObjectWriter* ow) const; - // Same as above but renders all non-message field types. Callers don't call // this function directly. They just use RenderField. util::Status RenderNonMessageField(const google::protobuf::Field* field, @@ -245,12 +253,6 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { ObjectWriter* ow) const; - // Reads field value according to Field spec in 'field' and returns the read - // value as string. This only works for primitive datatypes (no message - // types). - const string ReadFieldValueAsString( - const google::protobuf::Field& field) const; - // Utility function to detect proto maps. The 'field' MUST be repeated. bool IsMap(const google::protobuf::Field& field) const; @@ -271,6 +273,7 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { // Type information for all the types used in the descriptor. Used to find // google::protobuf::Type of nested messages/enums. const TypeInfo* typeinfo_; + // Whether this class owns the typeinfo_ object. If true the typeinfo_ object // should be deleted in the destructor. bool own_typeinfo_; diff --git a/src/google/protobuf/util/internal/protostream_objectsource_test.cc b/src/google/protobuf/util/internal/protostream_objectsource_test.cc index 3f6fdf97..cac28a06 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource_test.cc @@ -42,15 +42,16 @@ #include <google/protobuf/io/zero_copy_stream_impl_lite.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/util/internal/expecting_objectwriter.h> +#include <google/protobuf/util/internal/testdata/anys.pb.h> #include <google/protobuf/util/internal/testdata/books.pb.h> #include <google/protobuf/util/internal/testdata/field_mask.pb.h> -#include <google/protobuf/util/internal/type_info_test_helper.h> -#include <google/protobuf/util/internal/constants.h> -#include <google/protobuf/stubs/strutil.h> -#include <google/protobuf/util/internal/testdata/anys.pb.h> #include <google/protobuf/util/internal/testdata/maps.pb.h> +#include <google/protobuf/util/internal/testdata/proto3.pb.h> #include <google/protobuf/util/internal/testdata/struct.pb.h> #include <google/protobuf/util/internal/testdata/timestamp_duration.pb.h> +#include <google/protobuf/util/internal/type_info_test_helper.h> +#include <google/protobuf/util/internal/constants.h> +#include <google/protobuf/stubs/strutil.h> #include <gtest/gtest.h> @@ -66,24 +67,24 @@ using google::protobuf::Message; using google::protobuf::io::ArrayInputStream; using google::protobuf::io::CodedInputStream; using util::Status; +using google::protobuf::testing::AnyM; +using google::protobuf::testing::AnyOut; using google::protobuf::testing::Author; using google::protobuf::testing::BadAuthor; using google::protobuf::testing::BadNestedBook; using google::protobuf::testing::Book; -using google::protobuf::testing::Cyclic; using google::protobuf::testing::Book_Label; +using google::protobuf::testing::Cyclic; +using google::protobuf::testing::FieldMaskTest; +using google::protobuf::testing::MapOut; +using google::protobuf::testing::MapOutWireFormat; using google::protobuf::testing::NestedBook; +using google::protobuf::testing::NestedFieldMask; using google::protobuf::testing::PackedPrimitive; using google::protobuf::testing::Primitive; -using google::protobuf::testing::more_author; -using google::protobuf::testing::maps::MapOut; -using google::protobuf::testing::maps::MapOutWireFormat; -using google::protobuf::testing::timestampduration::TimestampDuration; -using google::protobuf::testing::anys::AnyOut; -using google::protobuf::testing::anys::AnyM; -using google::protobuf::testing::FieldMaskTest; -using google::protobuf::testing::NestedFieldMask; -using google::protobuf::testing::structs::StructType; +using google::protobuf::testing::Proto3Message; +using google::protobuf::testing::StructType; +using google::protobuf::testing::TimestampDuration; using ::testing::_; @@ -101,7 +102,7 @@ class ProtostreamObjectSourceTest mock_(), ow_(&mock_), use_lower_camel_for_enums_(false) { - helper_.ResetTypeInfo(Book::descriptor()); + helper_.ResetTypeInfo(Book::descriptor(), Proto3Message::descriptor()); } virtual ~ProtostreamObjectSourceTest() {} @@ -493,6 +494,15 @@ TEST_P(ProtostreamObjectSourceTest, EnumCaseIsUnchangedByDefault) { DoTest(book, Book::descriptor()); } +TEST_P(ProtostreamObjectSourceTest, UnknownEnum) { + Proto3Message message; + message.set_enum_value(static_cast<Proto3Message::NestedEnum>(1234)); + ow_.StartObject("") + ->RenderInt32("enumValue", 1234) + ->EndObject(); + DoTest(message, Proto3Message::descriptor()); +} + TEST_P(ProtostreamObjectSourceTest, CyclicMessageDepthTest) { Cyclic cyclic; cyclic.set_m_int(123); @@ -679,7 +689,7 @@ INSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest, // This is the example expected output. // { // "any": { -// "@type": "type.googleapis.com/google.protobuf.testing.anys.AnyM" +// "@type": "type.googleapis.com/google.protobuf.testing.AnyM" // "foo": "foovalue" // } // } @@ -694,7 +704,7 @@ TEST_P(ProtostreamObjectSourceAnysTest, BasicAny) { ow_.StartObject("") ->StartObject("any") ->RenderString("@type", - "type.googleapis.com/google.protobuf.testing.anys.AnyM") + "type.googleapis.com/google.protobuf.testing.AnyM") ->RenderString("foo", "foovalue") ->EndObject() ->EndObject(); @@ -708,8 +718,7 @@ TEST_P(ProtostreamObjectSourceAnysTest, RecursiveAny) { any->set_type_url("type.googleapis.com/google.protobuf.Any"); ::google::protobuf::Any nested_any; - nested_any.set_type_url( - "type.googleapis.com/google.protobuf.testing.anys.AnyM"); + nested_any.set_type_url("type.googleapis.com/google.protobuf.testing.AnyM"); AnyM m; m.set_foo("foovalue"); @@ -722,7 +731,7 @@ TEST_P(ProtostreamObjectSourceAnysTest, RecursiveAny) { ->RenderString("@type", "type.googleapis.com/google.protobuf.Any") ->StartObject("value") ->RenderString("@type", - "type.googleapis.com/google.protobuf.testing.anys.AnyM") + "type.googleapis.com/google.protobuf.testing.AnyM") ->RenderString("foo", "foovalue") ->EndObject() ->EndObject() @@ -741,7 +750,7 @@ TEST_P(ProtostreamObjectSourceAnysTest, DoubleRecursiveAny) { ::google::protobuf::Any second_nested_any; second_nested_any.set_type_url( - "type.googleapis.com/google.protobuf.testing.anys.AnyM"); + "type.googleapis.com/google.protobuf.testing.AnyM"); AnyM m; m.set_foo("foovalue"); @@ -756,7 +765,7 @@ TEST_P(ProtostreamObjectSourceAnysTest, DoubleRecursiveAny) { ->RenderString("@type", "type.googleapis.com/google.protobuf.Any") ->StartObject("value") ->RenderString("@type", - "type.googleapis.com/google.protobuf.testing.anys.AnyM") + "type.googleapis.com/google.protobuf.testing.AnyM") ->RenderString("foo", "foovalue") ->EndObject() ->EndObject() @@ -1001,6 +1010,19 @@ TEST_P(ProtostreamObjectSourceTimestampTest, InvalidDurationAboveMaxTest) { EXPECT_EQ(util::error::INTERNAL, status.error_code()); } +TEST_P(ProtostreamObjectSourceTimestampTest, TimestampDurationDefaultValue) { + TimestampDuration out; + out.mutable_ts()->set_seconds(0); + out.mutable_dur()->set_seconds(0); + + ow_.StartObject("") + ->RenderString("ts", "1970-01-01T00:00:00Z") + ->RenderString("dur", "0s") + ->EndObject(); + + DoTest(out, TimestampDuration::descriptor()); +} + } // namespace converter } // namespace util } // namespace protobuf diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc index 73e05cfe..6c15e862 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc @@ -65,6 +65,7 @@ ProtoStreamObjectWriter::ProtoStreamObjectWriter( current_(NULL), options_(options) { set_ignore_unknown_fields(options_.ignore_unknown_fields); + set_use_lower_camel_for_enums(options_.use_lower_camel_for_enums); } ProtoStreamObjectWriter::ProtoStreamObjectWriter( @@ -192,17 +193,11 @@ ProtoStreamObjectWriter::AnyWriter::~AnyWriter() {} void ProtoStreamObjectWriter::AnyWriter::StartObject(StringPiece name) { ++depth_; // If an object writer is absent, that means we have not called StartAny() - // before reaching here. This is an invalid state. StartAny() gets called - // whenever we see an "@type" being rendered (see AnyWriter::RenderDataPiece). + // before reaching here, which happens when we have data before the "@type" + // field. if (ow_ == NULL) { - // Make sure we are not already in an invalid state. This avoids making - // multiple unnecessary InvalidValue calls. - if (!invalid_) { - parent_->InvalidValue("Any", - StrCat("Missing or invalid @type for any field in ", - parent_->master_type_.name())); - invalid_ = true; - } + // Save data before the "@type" field for later replay. + uninterpreted_events_.push_back(Event(Event::START_OBJECT, name)); } else if (is_well_known_type_ && depth_ == 1) { // For well-known types, the only other field besides "@type" should be a // "value" field. @@ -222,10 +217,15 @@ void ProtoStreamObjectWriter::AnyWriter::StartObject(StringPiece name) { bool ProtoStreamObjectWriter::AnyWriter::EndObject() { --depth_; - // As long as depth_ >= 0, we know we haven't reached the end of Any. - // Propagate these EndObject() calls to the contained ow_. For regular - // message types, we propagate the end of Any as well. - if (ow_ != NULL && (depth_ >= 0 || !is_well_known_type_)) { + if (ow_ == NULL) { + if (depth_ >= 0) { + // Save data before the "@type" field for later replay. + uninterpreted_events_.push_back(Event(Event::END_OBJECT)); + } + } else if (depth_ >= 0 || !is_well_known_type_) { + // As long as depth_ >= 0, we know we haven't reached the end of Any. + // Propagate these EndObject() calls to the contained ow_. For regular + // message types, we propagate the end of Any as well. ow_->EndObject(); } // A negative depth_ implies that we have reached the end of Any @@ -239,14 +239,9 @@ bool ProtoStreamObjectWriter::AnyWriter::EndObject() { void ProtoStreamObjectWriter::AnyWriter::StartList(StringPiece name) { ++depth_; - // We expect ow_ to be present as this call only makes sense inside an Any. if (ow_ == NULL) { - if (!invalid_) { - parent_->InvalidValue("Any", - StrCat("Missing or invalid @type for any field in ", - parent_->master_type_.name())); - invalid_ = true; - } + // Save data before the "@type" field for later replay. + uninterpreted_events_.push_back(Event(Event::START_LIST, name)); } else if (is_well_known_type_ && depth_ == 1) { if (name != "value" && !invalid_) { parent_->InvalidValue("Any", @@ -265,8 +260,10 @@ void ProtoStreamObjectWriter::AnyWriter::EndList() { GOOGLE_LOG(DFATAL) << "Mismatched EndList found, should not be possible"; depth_ = 0; } - // We don't write an error on the close, only on the open - if (ow_ != NULL) { + if (ow_ == NULL) { + // Save data before the "@type" field for later replay. + uninterpreted_events_.push_back(Event(Event::END_LIST)); + } else { ow_->EndList(); } } @@ -278,12 +275,8 @@ void ProtoStreamObjectWriter::AnyWriter::RenderDataPiece( if (depth_ == 0 && ow_ == NULL && name == "@type") { StartAny(value); } else if (ow_ == NULL) { - if (!invalid_) { - parent_->InvalidValue("Any", - StrCat("Missing or invalid @type for any field in ", - parent_->master_type_.name())); - invalid_ = true; - } + // Save data before the "@type" field. + uninterpreted_events_.push_back(Event(name, value)); } else if (depth_ == 0 && is_well_known_type_) { if (name != "value" && !invalid_) { parent_->InvalidValue("Any", @@ -293,7 +286,7 @@ void ProtoStreamObjectWriter::AnyWriter::RenderDataPiece( if (well_known_type_render_ == NULL) { // Only Any and Struct don't have a special type render but both of // them expect a JSON object (i.e., a StartObject() call). - if (!invalid_) { + if (value.type() != DataPiece::TYPE_NULL && !invalid_) { parent_->InvalidValue("Any", "Expect a JSON object."); invalid_ = true; } @@ -358,13 +351,29 @@ void ProtoStreamObjectWriter::AnyWriter::StartAny(const DataPiece& value) { if (!is_well_known_type_) { ow_->StartObject(""); } + + // Now we know the proto type and can interpret all data fields we gathered + // before the "@type" field. + for (int i = 0; i < uninterpreted_events_.size(); ++i) { + uninterpreted_events_[i].Replay(this); + } } void ProtoStreamObjectWriter::AnyWriter::WriteAny() { if (ow_ == NULL) { - // If we had no object writer, we never got any content, so just return - // immediately, which is equivalent to writing an empty Any. - return; + if (uninterpreted_events_.empty()) { + // We never got any content, so just return immediately, which is + // equivalent to writing an empty Any. + return; + } else { + // There are uninterpreted data, but we never got a "@type" field. + if (!invalid_) { + parent_->InvalidValue("Any", StrCat("Missing @type for any field in ", + parent_->master_type_.name())); + invalid_ = true; + } + return; + } } // Render the type_url and value fields directly to the stream. // type_url has tag 1 and value has tag 2. @@ -374,6 +383,41 @@ void ProtoStreamObjectWriter::AnyWriter::WriteAny() { } } +void ProtoStreamObjectWriter::AnyWriter::Event::Replay( + AnyWriter* writer) const { + switch (type_) { + case START_OBJECT: + writer->StartObject(name_); + break; + case END_OBJECT: + writer->EndObject(); + break; + case START_LIST: + writer->StartList(name_); + break; + case END_LIST: + writer->EndList(); + break; + case RENDER_DATA_PIECE: + writer->RenderDataPiece(name_, value_); + break; + } +} + +void ProtoStreamObjectWriter::AnyWriter::Event::DeepCopy() { + // DataPiece only contains a string reference. To make sure the referenced + // string value stays valid, we make a copy of the string value and update + // DataPiece to reference our own copy. + if (value_.type() == DataPiece::TYPE_STRING) { + value_.str().AppendToString(&value_storage_); + value_ = DataPiece(value_storage_, value_.use_strict_base64_decoding()); + } else if (value_.type() == DataPiece::TYPE_BYTES) { + value_storage_ = value_.ToBytes().ValueOrDie(); + value_ = + DataPiece(value_storage_, true, value_.use_strict_base64_decoding()); + } +} + ProtoStreamObjectWriter::Item::Item(ProtoStreamObjectWriter* enclosing, ItemType item_type, bool is_placeholder, bool is_list) @@ -867,6 +911,7 @@ Status ProtoStreamObjectWriter::RenderStructValue(ProtoStreamObjectWriter* ow, Status ProtoStreamObjectWriter::RenderTimestamp(ProtoStreamObjectWriter* ow, const DataPiece& data) { + if (data.type() == DataPiece::TYPE_NULL) return Status::OK; if (data.type() != DataPiece::TYPE_STRING) { return Status(INVALID_ARGUMENT, StrCat("Invalid data type for timestamp, value is ", @@ -897,6 +942,7 @@ static inline util::Status RenderOneFieldPath(ProtoStreamObjectWriter* ow, Status ProtoStreamObjectWriter::RenderFieldMask(ProtoStreamObjectWriter* ow, const DataPiece& data) { + if (data.type() == DataPiece::TYPE_NULL) return Status::OK; if (data.type() != DataPiece::TYPE_STRING) { return Status(INVALID_ARGUMENT, StrCat("Invalid data type for field mask, value is ", @@ -913,6 +959,7 @@ Status ProtoStreamObjectWriter::RenderFieldMask(ProtoStreamObjectWriter* ow, Status ProtoStreamObjectWriter::RenderDuration(ProtoStreamObjectWriter* ow, const DataPiece& data) { + if (data.type() == DataPiece::TYPE_NULL) return Status::OK; if (data.type() != DataPiece::TYPE_STRING) { return Status(INVALID_ARGUMENT, StrCat("Invalid data type for duration, value is ", @@ -962,6 +1009,7 @@ Status ProtoStreamObjectWriter::RenderDuration(ProtoStreamObjectWriter* ow, Status ProtoStreamObjectWriter::RenderWrapperType(ProtoStreamObjectWriter* ow, const DataPiece& data) { + if (data.type() == DataPiece::TYPE_NULL) return Status::OK; ow->ProtoWriter::RenderDataPiece("value", data); return Status::OK; } @@ -1049,13 +1097,18 @@ ProtoStreamObjectWriter* ProtoStreamObjectWriter::RenderDataPiece( // Check if the field is of special type. Render it accordingly if so. const TypeRenderer* type_renderer = FindTypeRenderer(field->type_url()); if (type_renderer != NULL) { - Push(name, Item::MESSAGE, false, false); - status = (*type_renderer)(this, data); - if (!status.ok()) { - InvalidValue(field->type_url(), - StrCat("Field '", name, "', ", status.error_message())); + // Pass through null value only for google.protobuf.Value. For other + // types we ignore null value just like for regular field types. + if (data.type() != DataPiece::TYPE_NULL || + field->type_url() == kStructValueTypeUrl) { + Push(name, Item::MESSAGE, false, false); + status = (*type_renderer)(this, data); + if (!status.ok()) { + InvalidValue(field->type_url(), + StrCat("Field '", name, "', ", status.error_message())); + } + Pop(); } - Pop(); return this; } diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.h b/src/google/protobuf/util/internal/protostream_objectwriter.h index 2e4d14d1..732971e1 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.h +++ b/src/google/protobuf/util/internal/protostream_objectwriter.h @@ -87,8 +87,14 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { // just ignore it and continue to process the rest. bool ignore_unknown_fields; + // If true, check if enum name in camel case or without underscore matches + // the field name. + bool use_lower_camel_for_enums; + Options() - : struct_integers_as_strings(false), ignore_unknown_fields(false) {} + : struct_integers_as_strings(false), + ignore_unknown_fields(false), + use_lower_camel_for_enums(false) {} // Default instance of Options with all options set to defaults. static const Options& Defaults() { @@ -145,6 +151,57 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { void RenderDataPiece(StringPiece name, const DataPiece& value); private: + // Before the "@type" field is encountered, we store all incoming data + // into this Event struct and replay them after we get the "@type" field. + class LIBPROTOBUF_EXPORT Event { + public: + enum Type { + START_OBJECT = 0, + END_OBJECT = 1, + START_LIST = 2, + END_LIST = 3, + RENDER_DATA_PIECE = 4, + }; + + // Constructor for END_OBJECT and END_LIST events. + explicit Event(Type type) : type_(type), value_(DataPiece::NullData()) {} + + // Constructor for START_OBJECT and START_LIST events. + explicit Event(Type type, StringPiece name) + : type_(type), + name_(name.ToString()), + value_(DataPiece::NullData()) {} + + // Constructor for RENDER_DATA_PIECE events. + explicit Event(StringPiece name, const DataPiece& value) + : type_(RENDER_DATA_PIECE), name_(name.ToString()), value_(value) { + DeepCopy(); + } + + Event(const Event& other) + : type_(other.type_), name_(other.name_), value_(other.value_) { + DeepCopy(); + } + + Event& operator=(const Event& other) { + type_ = other.type_; + name_ = other.name_; + value_ = other.value_; + DeepCopy(); + return *this; + } + + void Replay(AnyWriter* writer) const; + + private: + void DeepCopy(); + + Type type_; + string name_; + DataPiece value_; + string value_storage_; + }; + // Handles starting up the any once we have a type. void StartAny(const DataPiece& value); @@ -180,6 +237,9 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { // } bool is_well_known_type_; TypeRenderer* well_known_type_render_; + + // Store data before the "@type" field. + std::vector<Event> uninterpreted_events_; }; // Represents an item in a stack of items used to keep state between diff --git a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc index 30e58e62..e7b38520 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc @@ -41,18 +41,20 @@ #include <google/protobuf/dynamic_message.h> #include <google/protobuf/message.h> #include <google/protobuf/util/internal/mock_error_listener.h> +#include <google/protobuf/util/internal/testdata/anys.pb.h> #include <google/protobuf/util/internal/testdata/books.pb.h> #include <google/protobuf/util/internal/testdata/field_mask.pb.h> +#include <google/protobuf/util/internal/testdata/maps.pb.h> +#include <google/protobuf/util/internal/testdata/oneofs.pb.h> +#include <google/protobuf/util/internal/testdata/proto3.pb.h> +#include <google/protobuf/util/internal/testdata/struct.pb.h> +#include <google/protobuf/util/internal/testdata/timestamp_duration.pb.h> +#include <google/protobuf/util/internal/testdata/wrappers.pb.h> #include <google/protobuf/util/internal/type_info_test_helper.h> #include <google/protobuf/util/internal/constants.h> #include <google/protobuf/util/message_differencer.h> #include <google/protobuf/stubs/bytestream.h> #include <google/protobuf/stubs/strutil.h> -#include <google/protobuf/util/internal/testdata/anys.pb.h> -#include <google/protobuf/util/internal/testdata/maps.pb.h> -#include <google/protobuf/util/internal/testdata/oneofs.pb.h> -#include <google/protobuf/util/internal/testdata/struct.pb.h> -#include <google/protobuf/util/internal/testdata/timestamp_duration.pb.h> #include <gtest/gtest.h> @@ -61,27 +63,28 @@ namespace protobuf { namespace util { namespace converter { +using google::protobuf::testing::AnyM; +using google::protobuf::testing::AnyOut; using google::protobuf::testing::Author; using google::protobuf::testing::Book; -using google::protobuf::testing::Book_Data; +using google::protobuf::testing::FieldMaskTest; +using google::protobuf::testing::Int32Wrapper; +using google::protobuf::testing::MapIn; using google::protobuf::testing::Primitive; +using google::protobuf::testing::Proto3Message; using google::protobuf::testing::Publisher; +using google::protobuf::testing::StructType; +using google::protobuf::testing::TimestampDuration; +using google::protobuf::testing::ValueWrapper; +using google::protobuf::testing::oneofs::OneOfsRequest; using google::protobuf::Descriptor; using google::protobuf::DescriptorPool; using google::protobuf::DynamicMessageFactory; using google::protobuf::FileDescriptorProto; using google::protobuf::Message; -using google::protobuf::io::ArrayInputStream; using strings::GrowingArrayByteSink; using ::testing::_; using ::testing::Args; -using google::protobuf::testing::anys::AnyM; -using google::protobuf::testing::anys::AnyOut; -using google::protobuf::testing::oneofs::OneOfsRequest; -using google::protobuf::testing::FieldMaskTest; -using google::protobuf::testing::maps::MapIn; -using google::protobuf::testing::structs::StructType; -using google::protobuf::testing::timestampduration::TimestampDuration; namespace { @@ -268,6 +271,84 @@ TEST_P(ProtoStreamObjectWriterTest, CustomJsonName) { CheckOutput(book); } +TEST_P(ProtoStreamObjectWriterTest, IntEnumValuesAreAccepted) { + Book book; + book.set_title("Some Book"); + book.set_type(google::protobuf::testing::Book_Type_KIDS); + Author* robert = book.mutable_author(); + robert->set_name("robert"); + + ow_->StartObject("") + ->RenderString("title", "Some Book") + ->RenderString("type", "2") + ->StartObject("author") + ->RenderString("name", "robert") + ->EndObject() + ->EndObject(); + CheckOutput(book); +} + +TEST_P(ProtoStreamObjectWriterTest, EnumValuesWithoutUnderscoreAreAccepted) { + Book book; + book.set_title("Some Book"); + book.set_type(google::protobuf::testing::Book_Type_ACTION_AND_ADVENTURE); + Author* robert = book.mutable_author(); + robert->set_name("robert"); + + options_.use_lower_camel_for_enums = true; + ResetProtoWriter(); + + ow_->StartObject("") + ->RenderString("title", "Some Book") + ->RenderString("type", "ACTIONANDADVENTURE") + ->StartObject("author") + ->RenderString("name", "robert") + ->EndObject() + ->EndObject(); + CheckOutput(book); +} + +TEST_P(ProtoStreamObjectWriterTest, EnumValuesInCamelCaseAreAccepted) { + Book book; + book.set_title("Some Book"); + book.set_type(google::protobuf::testing::Book_Type_ACTION_AND_ADVENTURE); + Author* robert = book.mutable_author(); + robert->set_name("robert"); + + options_.use_lower_camel_for_enums = true; + ResetProtoWriter(); + + ow_->StartObject("") + ->RenderString("title", "Some Book") + ->RenderString("type", "actionAndAdventure") + ->StartObject("author") + ->RenderString("name", "robert") + ->EndObject() + ->EndObject(); + CheckOutput(book); +} + +TEST_P(ProtoStreamObjectWriterTest, + EnumValuesInCamelCaseWithNameNotUppercaseAreAccepted) { + Book book; + book.set_title("Some Book"); + book.set_type(google::protobuf::testing::Book_Type_arts_and_photography); + Author* robert = book.mutable_author(); + robert->set_name("robert"); + + options_.use_lower_camel_for_enums = true; + ResetProtoWriter(); + + ow_->StartObject("") + ->RenderString("title", "Some Book") + ->RenderString("type", "artsAndPhotography") + ->StartObject("author") + ->RenderString("name", "robert") + ->EndObject() + ->EndObject(); + CheckOutput(book); +} + TEST_P(ProtoStreamObjectWriterTest, PrimitiveFromStringConversion) { Primitive full; full.set_fix32(101); @@ -826,6 +907,19 @@ TEST_P(ProtoStreamObjectWriterTest, IgnoreUnknownListAtPublisher) { CheckOutput(expected); } +TEST_P(ProtoStreamObjectWriterTest, AcceptUnknownEnumValue) { + ResetTypeInfo(Proto3Message::descriptor()); + + Proto3Message expected; + expected.set_enum_value(static_cast<Proto3Message::NestedEnum>(12345)); + + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); + ow_->StartObject("") + ->RenderInt32("enumValue", 12345) + ->EndObject(); + CheckOutput(expected); +} + TEST_P(ProtoStreamObjectWriterTest, MissingRequiredField) { Book expected; expected.set_title("My Title"); @@ -1338,9 +1432,9 @@ TEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidValue( _, StringPiece("type.googleapis.com/google.protobuf.Timestamp"), StringPiece( - "Field 'ts', Invalid data type for timestamp, value is null"))) + "Field 'ts', Invalid data type for timestamp, value is 1"))) .With(Args<0>(HasObjectLocation("ts"))); - ow_->StartObject("")->RenderNull("ts")->EndObject(); + ow_->StartObject("")->RenderInt32("ts", 1)->EndObject(); CheckOutput(timestamp); } @@ -1352,8 +1446,22 @@ TEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidValue( _, StringPiece("type.googleapis.com/google.protobuf.Duration"), StringPiece( - "Field 'dur', Invalid data type for duration, value is null"))) + "Field 'dur', Invalid data type for duration, value is 1"))) .With(Args<0>(HasObjectLocation("dur"))); + ow_->StartObject("")->RenderInt32("dur", 1)->EndObject(); + CheckOutput(duration); +} + +TEST_P(ProtoStreamObjectWriterTimestampDurationTest, TimestampAcceptsNull) { + TimestampDuration timestamp; + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); + ow_->StartObject("")->RenderNull("ts")->EndObject(); + CheckOutput(timestamp); +} + +TEST_P(ProtoStreamObjectWriterTimestampDurationTest, DurationAcceptsNull) { + TimestampDuration duration; + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); ow_->StartObject("")->RenderNull("dur")->EndObject(); CheckOutput(duration); } @@ -1415,6 +1523,28 @@ TEST_P(ProtoStreamObjectWriterStructTest, StructInvalidInputFailure) { CheckOutput(struct_type); } +TEST_P(ProtoStreamObjectWriterStructTest, StructAcceptsNull) { + StructType struct_type; + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); + + ow_->StartObject("")->RenderNull("object")->EndObject(); + CheckOutput(struct_type); +} + +TEST_P(ProtoStreamObjectWriterStructTest, StructValuePreservesNull) { + StructType struct_type; + (*struct_type.mutable_object()->mutable_fields())["key"].set_null_value( + google::protobuf::NULL_VALUE); + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); + + ow_->StartObject("") + ->StartObject("object") + ->RenderNull("key") + ->EndObject() + ->EndObject(); + CheckOutput(struct_type); +} + TEST_P(ProtoStreamObjectWriterStructTest, SimpleRepeatedStructMapKeyTest) { EXPECT_CALL( listener_, @@ -1482,6 +1612,15 @@ TEST_P(ProtoStreamObjectWriterStructTest, OptionStructIntAsStringsTest) { CheckOutput(struct_type); } +TEST_P(ProtoStreamObjectWriterStructTest, ValuePreservesNull) { + ValueWrapper value; + value.mutable_value()->set_null_value(google::protobuf::NULL_VALUE); + + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); + ow_->StartObject("")->RenderNull("value")->EndObject(); + CheckOutput(value); +} + class ProtoStreamObjectWriterMapTest : public BaseProtoStreamObjectWriterTest { protected: ProtoStreamObjectWriterMapTest() @@ -1527,11 +1666,14 @@ class ProtoStreamObjectWriterAnyTest : public BaseProtoStreamObjectWriterTest { ProtoStreamObjectWriterAnyTest() { vector<const Descriptor*> descriptors; descriptors.push_back(AnyOut::descriptor()); + descriptors.push_back(Book::descriptor()); + descriptors.push_back(google::protobuf::Any::descriptor()); descriptors.push_back(google::protobuf::DoubleValue::descriptor()); + descriptors.push_back(google::protobuf::FieldMask::descriptor()); + descriptors.push_back(google::protobuf::Int32Value::descriptor()); + descriptors.push_back(google::protobuf::Struct::descriptor()); descriptors.push_back(google::protobuf::Timestamp::descriptor()); - descriptors.push_back(google::protobuf::Any::descriptor()); descriptors.push_back(google::protobuf::Value::descriptor()); - descriptors.push_back(google::protobuf::Struct::descriptor()); ResetTypeInfo(descriptors); } }; @@ -1564,8 +1706,7 @@ TEST_P(ProtoStreamObjectWriterAnyTest, RecursiveAny) { any->set_type_url("type.googleapis.com/google.protobuf.Any"); ::google::protobuf::Any nested_any; - nested_any.set_type_url( - "type.googleapis.com/google.protobuf.testing.anys.AnyM"); + nested_any.set_type_url("type.googleapis.com/google.protobuf.testing.AnyM"); AnyM m; m.set_foo("foovalue"); @@ -1578,11 +1719,12 @@ TEST_P(ProtoStreamObjectWriterAnyTest, RecursiveAny) { ->RenderString("@type", "type.googleapis.com/google.protobuf.Any") ->StartObject("value") ->RenderString("@type", - "type.googleapis.com/google.protobuf.testing.anys.AnyM") + "type.googleapis.com/google.protobuf.testing.AnyM") ->RenderString("foo", "foovalue") ->EndObject() ->EndObject() ->EndObject(); + CheckOutput(out, 107); } TEST_P(ProtoStreamObjectWriterAnyTest, DoubleRecursiveAny) { @@ -1595,7 +1737,7 @@ TEST_P(ProtoStreamObjectWriterAnyTest, DoubleRecursiveAny) { ::google::protobuf::Any second_nested_any; second_nested_any.set_type_url( - "type.googleapis.com/google.protobuf.testing.anys.AnyM"); + "type.googleapis.com/google.protobuf.testing.AnyM"); AnyM m; m.set_foo("foovalue"); @@ -1611,18 +1753,110 @@ TEST_P(ProtoStreamObjectWriterAnyTest, DoubleRecursiveAny) { ->RenderString("@type", "type.googleapis.com/google.protobuf.Any") ->StartObject("value") ->RenderString("@type", - "type.googleapis.com/google.protobuf.testing.anys.AnyM") + "type.googleapis.com/google.protobuf.testing.AnyM") ->RenderString("foo", "foovalue") ->EndObject() ->EndObject() ->EndObject() ->EndObject(); + CheckOutput(out, 151); +} + +TEST_P(ProtoStreamObjectWriterAnyTest, TypeUrlAtEnd) { + Book book; + book.set_title("C++"); + book.set_length(1234); + book.set_content("Hello World!"); + + ::google::protobuf::Any any; + any.PackFrom(book); + + ::google::protobuf::Any outer_any; + outer_any.PackFrom(any); + + AnyOut out; + out.mutable_any()->PackFrom(outer_any); + + // Put the @type field at the end of each Any message. Parsers should + // be able to accept that. + ow_->StartObject("") + ->StartObject("any") + ->StartObject("value") + ->StartObject("value") + ->RenderString("title", "C++") + ->RenderInt32("length", 1234) + ->RenderBytes("content", "Hello World!") + ->RenderString("@type", + "type.googleapis.com/google.protobuf.testing.Book") + ->EndObject() + ->RenderString("@type", "type.googleapis.com/google.protobuf.Any") + ->EndObject() + ->RenderString("@type", "type.googleapis.com/google.protobuf.Any") + ->EndObject() + ->EndObject(); + CheckOutput(out); +} + +// Same as TypeUrlAtEnd, but use temporary string values to make sure we don't +// mistakenly store StringPiece objects pointing to invalid memory. +TEST_P(ProtoStreamObjectWriterAnyTest, TypeUrlAtEndWithTemporaryStrings) { + Book book; + book.set_title("C++"); + book.set_length(1234); + book.set_content("Hello World!"); + + ::google::protobuf::Any any; + any.PackFrom(book); + + ::google::protobuf::Any outer_any; + outer_any.PackFrom(any); + + AnyOut out; + out.mutable_any()->PackFrom(outer_any); + + string name, value; + // Put the @type field at the end of each Any message. Parsers should + // be able to accept that. + ow_->StartObject("")->StartObject("any"); + { + ow_->StartObject("value"); + { + ow_->StartObject("value"); + { + name = "title"; + value = "C++"; + ow_->RenderString(name, value); + name = "length"; + ow_->RenderInt32(name, 1234); + name = "content"; + value = "Hello World!"; + ow_->RenderBytes(name, value); + name = "@type"; + value = "type.googleapis.com/google.protobuf.testing.Book"; + ow_->RenderString(name, value); + } + ow_->EndObject(); + + name = "@type"; + value = "type.googleapis.com/google.protobuf.Any"; + ow_->RenderString(name, value); + } + ow_->EndObject(); + + name = "@type"; + value = "type.googleapis.com/google.protobuf.Any"; + ow_->RenderString(name, value); + } + ow_->EndObject()->EndObject(); + CheckOutput(out); } TEST_P(ProtoStreamObjectWriterAnyTest, EmptyAnyFromEmptyObject) { AnyOut out; out.mutable_any(); + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); + ow_->StartObject("")->StartObject("any")->EndObject()->EndObject(); CheckOutput(out, 2); @@ -1631,11 +1865,10 @@ TEST_P(ProtoStreamObjectWriterAnyTest, EmptyAnyFromEmptyObject) { TEST_P(ProtoStreamObjectWriterAnyTest, AnyWithoutTypeUrlFails1) { AnyOut any; - EXPECT_CALL( - listener_, - InvalidValue(_, StringPiece("Any"), - StringPiece("Missing or invalid @type for any field in " - "google.protobuf.testing.anys.AnyOut"))); + EXPECT_CALL(listener_, + InvalidValue(_, StringPiece("Any"), + StringPiece("Missing @type for any field in " + "google.protobuf.testing.AnyOut"))); ow_->StartObject("") ->StartObject("any") @@ -1649,11 +1882,10 @@ TEST_P(ProtoStreamObjectWriterAnyTest, AnyWithoutTypeUrlFails1) { TEST_P(ProtoStreamObjectWriterAnyTest, AnyWithoutTypeUrlFails2) { AnyOut any; - EXPECT_CALL( - listener_, - InvalidValue(_, StringPiece("Any"), - StringPiece("Missing or invalid @type for any field in " - "google.protobuf.testing.anys.AnyOut"))); + EXPECT_CALL(listener_, + InvalidValue(_, StringPiece("Any"), + StringPiece("Missing @type for any field in " + "google.protobuf.testing.AnyOut"))); ow_->StartObject("") ->StartObject("any") @@ -1667,11 +1899,10 @@ TEST_P(ProtoStreamObjectWriterAnyTest, AnyWithoutTypeUrlFails2) { TEST_P(ProtoStreamObjectWriterAnyTest, AnyWithoutTypeUrlFails3) { AnyOut any; - EXPECT_CALL( - listener_, - InvalidValue(_, StringPiece("Any"), - StringPiece("Missing or invalid @type for any field in " - "google.protobuf.testing.anys.AnyOut"))); + EXPECT_CALL(listener_, + InvalidValue(_, StringPiece("Any"), + StringPiece("Missing @type for any field in " + "google.protobuf.testing.AnyOut"))); ow_->StartObject("") ->StartObject("any") @@ -1716,9 +1947,21 @@ TEST_P(ProtoStreamObjectWriterAnyTest, AnyWithUnknownTypeFails) { CheckOutput(any); } -TEST_P(ProtoStreamObjectWriterAnyTest, AnyNullInputFails) { +TEST_P(ProtoStreamObjectWriterAnyTest, AnyIncorrectInputTypeFails) { + AnyOut any; + + EXPECT_CALL( + listener_, + InvalidValue(_, StringPiece("type.googleapis.com/google.protobuf.Any"), + StringPiece("1"))); + ow_->StartObject("")->RenderInt32("any", 1)->EndObject(); + CheckOutput(any); +} + +TEST_P(ProtoStreamObjectWriterAnyTest, AnyAcceptsNull) { AnyOut any; + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); ow_->StartObject("")->RenderNull("any")->EndObject(); CheckOutput(any); } @@ -1956,6 +2199,111 @@ TEST_P(ProtoStreamObjectWriterAnyTest, AnyWellKnownTypesExpectObjectForAny) { CheckOutput(any); } +// { +// "any": { +// "@type": "type.googleapis.com/google.protobuf.Any", +// "value": null +// } +// } +TEST_P(ProtoStreamObjectWriterAnyTest, AnyInAnyAcceptsNull) { + AnyOut out; + google::protobuf::Any empty; + out.mutable_any()->PackFrom(empty); + + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); + ow_->StartObject("") + ->StartObject("any") + ->RenderString("@type", "type.googleapis.com/google.protobuf.Any") + ->RenderNull("value") + ->EndObject() + ->EndObject(); + CheckOutput(out); +} + +// { +// "any": { +// "@type": "type.googleapis.com/google.protobuf.Timestamp", +// "value": null +// } +// } +TEST_P(ProtoStreamObjectWriterAnyTest, TimestampInAnyAcceptsNull) { + AnyOut out; + google::protobuf::Timestamp empty; + out.mutable_any()->PackFrom(empty); + + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); + ow_->StartObject("") + ->StartObject("any") + ->RenderString("@type", "type.googleapis.com/google.protobuf.Timestamp") + ->RenderNull("value") + ->EndObject() + ->EndObject(); + CheckOutput(out); +} + +// { +// "any": { +// "@type": "type.googleapis.com/google.protobuf.Duration", +// "value": null +// } +// } +TEST_P(ProtoStreamObjectWriterAnyTest, DurationInAnyAcceptsNull) { + AnyOut out; + google::protobuf::Duration empty; + out.mutable_any()->PackFrom(empty); + + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); + ow_->StartObject("") + ->StartObject("any") + ->RenderString("@type", "type.googleapis.com/google.protobuf.Duration") + ->RenderNull("value") + ->EndObject() + ->EndObject(); + CheckOutput(out); +} + +// { +// "any": { +// "@type": "type.googleapis.com/google.protobuf.FieldMask", +// "value": null +// } +// } +TEST_P(ProtoStreamObjectWriterAnyTest, FieldMaskInAnyAcceptsNull) { + AnyOut out; + google::protobuf::FieldMask empty; + out.mutable_any()->PackFrom(empty); + + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); + ow_->StartObject("") + ->StartObject("any") + ->RenderString("@type", "type.googleapis.com/google.protobuf.FieldMask") + ->RenderNull("value") + ->EndObject() + ->EndObject(); + CheckOutput(out); +} + +// { +// "any": { +// "@type": "type.googleapis.com/google.protobuf.Int32Value", +// "value": null +// } +// } +TEST_P(ProtoStreamObjectWriterAnyTest, WrapperInAnyAcceptsNull) { + AnyOut out; + google::protobuf::Int32Value empty; + out.mutable_any()->PackFrom(empty); + + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); + ow_->StartObject("") + ->StartObject("any") + ->RenderString("@type", "type.googleapis.com/google.protobuf.Int32Value") + ->RenderNull("value") + ->EndObject() + ->EndObject(); + CheckOutput(out); +} + class ProtoStreamObjectWriterFieldMaskTest : public BaseProtoStreamObjectWriterTest { protected: @@ -2201,6 +2549,36 @@ TEST_P(ProtoStreamObjectWriterFieldMaskTest, MapKeyCanContainAnyChars) { CheckOutput(expected); } +TEST_P(ProtoStreamObjectWriterFieldMaskTest, FieldMaskAcceptsNull) { + FieldMaskTest expected; + EXPECT_CALL(listener_, InvalidValue(_, _, _)).Times(0); + ow_->StartObject("")->RenderNull("single_mask")->EndObject(); + CheckOutput(expected); +} + +class ProtoStreamObjectWriterWrappersTest + : public BaseProtoStreamObjectWriterTest { + protected: + ProtoStreamObjectWriterWrappersTest() { + vector<const Descriptor*> descriptors; + descriptors.push_back(Int32Wrapper::descriptor()); + descriptors.push_back(google::protobuf::Int32Value::descriptor()); + ResetTypeInfo(descriptors); + } +}; + +INSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest, + ProtoStreamObjectWriterWrappersTest, + ::testing::Values( + testing::USE_TYPE_RESOLVER)); + +TEST_P(ProtoStreamObjectWriterWrappersTest, WrapperAcceptsNull) { + Int32Wrapper wrapper; + EXPECT_CALL(listener_, InvalidName(_, _, _)).Times(0); + ow_->StartObject("")->RenderNull("int32")->EndObject(); + CheckOutput(wrapper); +} + class ProtoStreamObjectWriterOneOfsTest : public BaseProtoStreamObjectWriterTest { protected: @@ -2368,7 +2746,6 @@ TEST_P(ProtoStreamObjectWriterOneOfsTest, StringPiece("oneof field 'data' is already set. " "Cannot set 'intData'"))); - using google::protobuf::testing::oneofs::OneOfsRequest; // JSON: // { "anyData": // { "@type": diff --git a/src/google/protobuf/util/internal/testdata/anys.proto b/src/google/protobuf/util/internal/testdata/anys.proto index 18c59cbb..a9ebca3d 100644 --- a/src/google/protobuf/util/internal/testdata/anys.proto +++ b/src/google/protobuf/util/internal/testdata/anys.proto @@ -28,16 +28,75 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Proto to test Proto3 Any serialization. syntax = "proto3"; -package google.protobuf.testing.anys; -option java_package = "com.google.protobuf.testing.anys"; +package google.protobuf.testing; import "google/protobuf/any.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/wrappers.proto"; + +// Top-level test cases proto used by MarshallingTest. See description +// at the top of the class MarshallingTest for details on how to write +// test cases. +message AnyTestCases { + AnyWrapper empty_any = 1; + AnyWrapper type_only_any = 2; + AnyWrapper wrapper_any = 3; + AnyWrapper any_with_timestamp_value = 4; + AnyWrapper any_with_duration_value = 5; + AnyWrapper any_with_struct_value = 6; + AnyWrapper recursive_any = 7; + AnyWrapper any_with_message_value = 8; + AnyWrapper any_with_nested_message = 9; + AnyWrapper any_with_message_with_wrapper_type = 10; + AnyWrapper any_with_message_with_timestamp = 11; + AnyWrapper any_with_message_containing_map = 12; + AnyWrapper any_with_message_containing_struct = 13; + AnyWrapper any_with_message_containing_repeated_message = 14; + AnyWrapper recursive_any_with_type_field_at_end = 15; + + google.protobuf.Any top_level_any = 50; + google.protobuf.Any top_level_any_with_type_field_at_end = 51; +} + +message AnyWrapper { + google.protobuf.Any any = 1; +} + +// Hack to make sure the types we put into the any are included in the types. +// Real solution is to add these types to the service config. +message Imports { + google.protobuf.DoubleValue dbl = 1; + google.protobuf.Struct struct = 2; + google.protobuf.Timestamp timestamp = 3; + google.protobuf.Duration duration = 4; + google.protobuf.Int32Value i32 = 5; + Data data = 100; +} + +message Data { + int32 attr = 1; + string str = 2; + repeated string msgs = 3; + Data nested_data = 4; + google.protobuf.Int32Value int_wrapper = 5; + google.protobuf.Timestamp time = 6; + map<string, string> map_data = 7; + google.protobuf.Struct struct_data = 8; + repeated Data repeated_data = 9; +} + +service AnyTestService { + rpc Call(AnyTestCases) returns (AnyTestCases); + rpc Call1(Imports) returns (Imports); +} message AnyIn { string something = 1; + google.protobuf.Any any = 2; } message AnyOut { @@ -47,7 +106,3 @@ message AnyOut { message AnyM { string foo = 1; } - -service TestService { - rpc Call(AnyIn) returns (AnyOut); -} diff --git a/src/google/protobuf/util/internal/testdata/books.proto b/src/google/protobuf/util/internal/testdata/books.proto index 1cbbba47..9fe4f7aa 100644 --- a/src/google/protobuf/util/internal/testdata/books.proto +++ b/src/google/protobuf/util/internal/testdata/books.proto @@ -31,6 +31,10 @@ // Author: sven@google.com (Sven Mawson) // // Sample protos for testing. + +// Some of the older enums don't use CAPITALS_WITH_UNDERSCORES for testing. +// LINT: LEGACY_NAMES + syntax = "proto2"; package google.protobuf.testing; @@ -60,6 +64,7 @@ message Book { FICTION = 1; KIDS = 2; ACTION_AND_ADVENTURE = 3; + arts_and_photography = 4; } optional Type type = 11; diff --git a/src/google/protobuf/util/internal/testdata/maps.proto b/src/google/protobuf/util/internal/testdata/maps.proto index 6475ecdd..0f381b32 100644 --- a/src/google/protobuf/util/internal/testdata/maps.proto +++ b/src/google/protobuf/util/internal/testdata/maps.proto @@ -28,11 +28,76 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Proto to test proto3 maps. syntax = "proto3"; -package google.protobuf.testing.maps; -option java_package = "com.google.protobuf.testing.maps"; +package google.protobuf.testing; + +// Top-level test cases proto used by MarshallingTest. See description +// at the top of the class MarshallingTest for details on how to write +// test cases. +message MapsTestCases { + EmptyMap empty_map = 1; + StringtoInt string_to_int = 2; + IntToString int_to_string = 3; + Mixed1 mixed1 = 4; + Mixed2 mixed2 = 5; + MapOfObjects map_of_objects = 6; + + // Empty key tests + StringtoInt empty_key_string_to_int1 = 7; + StringtoInt empty_key_string_to_int2 = 8; + StringtoInt empty_key_string_to_int3 = 9; + BoolToString empty_key_bool_to_string = 10; + IntToString empty_key_int_to_string = 11; + Mixed1 empty_key_mixed = 12; + MapOfObjects empty_key_map_objects = 13; +} + +message EmptyMap { + map<int32, int32> map = 1; +} + +message StringtoInt { + map<string, int32> map = 1; +} + +message IntToString { + map<int32, string> map = 1; +} + +message BoolToString { + map<bool, string> map = 1; +} + +message Mixed1 { + string msg = 1; + map<string, float> map = 2; +} + +message Mixed2 { + enum E { + E0 = 0; + E1 = 1; + E2 = 2; + E3 = 3; + } + map<int32, bool> map = 1; + E ee = 2; +} + +message MapOfObjects { + message M { + string inner_text = 1; + } + map<string, M> map = 1; +} + +message DummyRequest { +} + +service MapsTestService { + rpc Call(DummyRequest) returns (MapsTestCases); +} message MapIn { string other = 1; @@ -79,8 +144,3 @@ message MapOutWireFormat { message MapM { string foo = 1; } - -service TestService { - rpc Call1(MapIn) returns (MapOut); - rpc Call2(MapIn) returns (MapOut); -} diff --git a/src/google/protobuf/util/internal/testdata/oneofs.proto b/src/google/protobuf/util/internal/testdata/oneofs.proto index 5bc9fa08..c37da083 100644 --- a/src/google/protobuf/util/internal/testdata/oneofs.proto +++ b/src/google/protobuf/util/internal/testdata/oneofs.proto @@ -28,7 +28,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Proto to test oneofs. +// Proto to test proto3 oneofs. syntax = "proto3"; import "google/protobuf/any.proto"; @@ -36,7 +36,6 @@ import "google/protobuf/struct.proto"; import "google/protobuf/timestamp.proto"; package google.protobuf.testing.oneofs; -option java_package = "com.google.protobuf.testing.oneofs"; message OneOfsRequest { string value = 1; @@ -45,24 +44,34 @@ message OneOfsRequest { int32 int_data = 3; // Simple message Data message_data = 4; + MoreData more_data = 5; // Well known types - google.protobuf.Struct struct_data = 5; - google.protobuf.Value value_data = 6; - google.protobuf.ListValue list_value_data = 7; - google.protobuf.Timestamp ts_data = 8; + google.protobuf.Struct struct_data = 6; + google.protobuf.Value value_data = 7; + google.protobuf.ListValue list_value_data = 8; + google.protobuf.Timestamp ts_data = 9; } google.protobuf.Any any_data = 19; } +message RequestWithSimpleOneof { + string value = 1; + oneof data { + string str_data = 2; + int32 int_data = 3; + Data message_data = 4; + MoreData more_data = 5; + } +} + message Data { int32 data_value = 1; } -message Response { - string value = 1; +message MoreData { + string str_value = 1; } -service TestService { - // Test call. - rpc Call(OneOfsRequest) returns (Response); +message Response { + string value = 1; } diff --git a/src/google/protobuf/util/internal/testdata/proto3.proto b/src/google/protobuf/util/internal/testdata/proto3.proto new file mode 100644 index 00000000..c013cee3 --- /dev/null +++ b/src/google/protobuf/util/internal/testdata/proto3.proto @@ -0,0 +1,42 @@ +// 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. + +syntax = "proto3"; + +package google.protobuf.testing; + +message Proto3Message { + enum NestedEnum { + FOO = 0; + BAR = 1; + BAZ = 2; + } + NestedEnum enum_value = 1; +} diff --git a/src/google/protobuf/util/internal/testdata/struct.proto b/src/google/protobuf/util/internal/testdata/struct.proto index c15aba0d..7b1cc1b9 100644 --- a/src/google/protobuf/util/internal/testdata/struct.proto +++ b/src/google/protobuf/util/internal/testdata/struct.proto @@ -28,18 +28,90 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Proto to test proto3 struct. syntax = "proto3"; -package google.protobuf.testing.structs; -option java_package = "com.google.protobuf.testing.structs"; +package google.protobuf.testing; import "google/protobuf/struct.proto"; -message StructType { - google.protobuf.Struct object = 1; +message StructTestCases { + StructWrapper empty_value = 1; + StructWrapper empty_value2 = 2; + StructWrapper null_value = 3; + StructWrapper simple_struct = 4; + StructWrapper longer_struct = 5; + StructWrapper struct_with_nested_struct = 6; + StructWrapper struct_with_nested_list = 7; + StructWrapper struct_with_list_of_nulls = 8; + StructWrapper struct_with_list_of_lists = 9; + StructWrapper struct_with_list_of_structs = 10; + StructWrapper struct_with_empty_list = 11; + StructWrapper struct_with_list_with_empty_struct = 12; + google.protobuf.Struct top_level_struct = 13; + google.protobuf.Struct top_level_struct_with_empty_list = 14; + google.protobuf.Struct top_level_struct_with_list_with_empty_struct = 15; + ValueWrapper value_wrapper_simple = 16; + ValueWrapper value_wrapper_with_struct = 17; + ValueWrapper value_wrapper_with_list = 18; + ValueWrapper value_wrapper_with_empty_list = 19; + ValueWrapper value_wrapper_with_list_with_empty_struct = 20; + ListValueWrapper list_value_wrapper = 21; + ListValueWrapper list_value_wrapper_with_empty_list = 22; + ListValueWrapper list_value_wrapper_with_list_with_empty_struct = 23; + google.protobuf.Value top_level_value_simple = 24; + google.protobuf.Value top_level_value_with_struct = 25; + google.protobuf.Value top_level_value_with_list = 26; + google.protobuf.Value top_level_value_with_empty_list = 27; + google.protobuf.Value top_level_value_with_list_with_empty_struct = 28; + google.protobuf.ListValue top_level_listvalue = 29; + google.protobuf.ListValue top_level_empty_listvalue = 30; + google.protobuf.ListValue top_level_listvalue_with_empty_struct = 31; + RepeatedValueWrapper repeated_value = 32; + RepeatedValueWrapper repeated_value_nested_list = 33; + RepeatedValueWrapper repeated_value_nested_list2 = 34; + RepeatedValueWrapper repeated_value_nested_list3 = 35; + RepeatedListValueWrapper repeated_listvalue = 36; + MapOfStruct map_of_struct = 37; + MapOfStruct map_of_struct_value = 38; + MapOfStruct map_of_listvalue = 39; +} + +message StructWrapper { + google.protobuf.Struct struct = 1; +} + +message ValueWrapper { + google.protobuf.Value value = 1; +} + +message RepeatedValueWrapper { + repeated google.protobuf.Value values = 1; +} + +message ListValueWrapper { + google.protobuf.ListValue shopping_list = 1; } -service TestService { - rpc Call(StructType) returns (StructType); +message RepeatedListValueWrapper { + repeated google.protobuf.ListValue dimensions = 1; +} + +message MapOfStruct { + map<string, google.protobuf.Struct> struct_map = 1; + map<string, google.protobuf.Value> value_map = 2; + map<string, google.protobuf.ListValue> listvalue_map = 3; +} + +// Hack to test return types with Struct as top-level message. Struct typers +// cannot be directly used in API requests. Hence using Dummy as request type. +message Dummy { + string text = 1; +} + +service StructTestService { + rpc Call(Dummy) returns (StructTestCases); +} + +message StructType { + google.protobuf.Struct object = 1; } diff --git a/src/google/protobuf/util/internal/testdata/timestamp_duration.proto b/src/google/protobuf/util/internal/testdata/timestamp_duration.proto index 56351f16..b74484ce 100644 --- a/src/google/protobuf/util/internal/testdata/timestamp_duration.proto +++ b/src/google/protobuf/util/internal/testdata/timestamp_duration.proto @@ -28,20 +28,53 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Proto to test proto3 Timestamp and Duration. syntax = "proto3"; -package google.protobuf.testing.timestampduration; -option java_package = "com.google.protobuf.testing.timestampduration"; +package google.protobuf.testing; import "google/protobuf/timestamp.proto"; import "google/protobuf/duration.proto"; +message TimestampDurationTestCases { + // Timestamp tests + TimeStampType epoch = 1; + TimeStampType epoch2 = 2; + TimeStampType mintime = 3; + TimeStampType maxtime = 4; + TimeStampType timeval1 = 5; + TimeStampType timeval2 = 6; + TimeStampType timeval3 = 7; + TimeStampType timeval4 = 8; + TimeStampType timeval5 = 9; + TimeStampType timeval6 = 10; + TimeStampType timeval7 = 11; + google.protobuf.Timestamp timeval8 = 12; + + // Duration tests + DurationType zero_duration = 101; + DurationType min_duration = 102; + DurationType max_duration = 103; + DurationType duration1 = 104; + DurationType duration2 = 105; + DurationType duration3 = 106; + DurationType duration4 = 107; + google.protobuf.Duration duration5 = 108; +} + +message TimeStampType { + google.protobuf.Timestamp timestamp = 1; +} + +message DurationType { + google.protobuf.Duration duration = 1; +} + +service TimestampDurationTestService { + rpc Call(TimestampDurationTestCases) returns (TimestampDurationTestCases); +} + message TimestampDuration { google.protobuf.Timestamp ts = 1; google.protobuf.Duration dur = 2; -} - -service TestService { - rpc Call(TimestampDuration) returns (TimestampDuration); + repeated google.protobuf.Timestamp rep_ts = 3; } diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc index 5f613e77..9aab3481 100644 --- a/src/google/protobuf/util/internal/utility.cc +++ b/src/google/protobuf/util/internal/utility.cc @@ -41,6 +41,8 @@ #include <google/protobuf/stubs/map_util.h> #include <google/protobuf/stubs/mathlimits.h> +#include <algorithm> + namespace google { namespace protobuf { namespace util { @@ -178,6 +180,19 @@ const google::protobuf::Field* FindJsonFieldInTypeOrNull( return NULL; } +const google::protobuf::Field* FindFieldInTypeByNumberOrNull( + const google::protobuf::Type* type, int32 number) { + if (type != NULL) { + for (int i = 0; i < type->fields_size(); ++i) { + const google::protobuf::Field& field = type->fields(i); + if (field.number() == number) { + return &field; + } + } + } + return NULL; +} + const google::protobuf::EnumValue* FindEnumValueByNameOrNull( const google::protobuf::Enum* enum_type, StringPiece enum_name) { if (enum_type != NULL) { @@ -204,6 +219,32 @@ const google::protobuf::EnumValue* FindEnumValueByNumberOrNull( return NULL; } +const google::protobuf::EnumValue* FindEnumValueByNameWithoutUnderscoreOrNull( + const google::protobuf::Enum* enum_type, StringPiece enum_name) { + if (enum_type != NULL) { + for (int i = 0; i < enum_type->enumvalue_size(); ++i) { + const google::protobuf::EnumValue& enum_value = enum_type->enumvalue(i); + string enum_name_without_underscore = enum_value.name(); + + // Remove underscore from the name. + enum_name_without_underscore.erase( + std::remove(enum_name_without_underscore.begin(), + enum_name_without_underscore.end(), '_'), + enum_name_without_underscore.end()); + // Make the name uppercase. + for (string::iterator it = enum_name_without_underscore.begin(); + it != enum_name_without_underscore.end(); ++it) { + *it = ascii_toupper(*it); + } + + if (enum_name_without_underscore == enum_name) { + return &enum_value; + } + } + } + return NULL; +} + string ToCamelCase(const StringPiece input) { bool capitalize_next = false; bool was_cap = true; diff --git a/src/google/protobuf/util/internal/utility.h b/src/google/protobuf/util/internal/utility.h index 26fed444..667e660c 100644 --- a/src/google/protobuf/util/internal/utility.h +++ b/src/google/protobuf/util/internal/utility.h @@ -136,6 +136,10 @@ const google::protobuf::Field* FindFieldInTypeOrNull( const google::protobuf::Field* FindJsonFieldInTypeOrNull( const google::protobuf::Type* type, StringPiece json_name); +// Similar to FindFieldInTypeOrNull, but this looks up fields by number. +const google::protobuf::Field* FindFieldInTypeByNumberOrNull( + const google::protobuf::Type* type, int32 number); + // Finds and returns the EnumValue identified by enum_name in the passed tech // Enum object. Returns NULL if none found. const google::protobuf::EnumValue* FindEnumValueByNameOrNull( @@ -146,6 +150,13 @@ const google::protobuf::EnumValue* FindEnumValueByNameOrNull( const google::protobuf::EnumValue* FindEnumValueByNumberOrNull( const google::protobuf::Enum* enum_type, int32 value); +// Finds and returns the EnumValue identified by enum_name without underscore in +// the passed tech Enum object. Returns NULL if none found. +// For Ex. if enum_name is ACTIONANDADVENTURE it can get accepted if +// EnumValue's name is action_and_adventure or ACTION_AND_ADVENTURE. +const google::protobuf::EnumValue* FindEnumValueByNameWithoutUnderscoreOrNull( + const google::protobuf::Enum* enum_type, StringPiece enum_name); + // Converts input to camel-case and returns it. LIBPROTOBUF_EXPORT string ToCamelCase(const StringPiece input); diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h index 654d1a67..fde37cf9 100644 --- a/src/google/protobuf/util/message_differencer.h +++ b/src/google/protobuf/util/message_differencer.h @@ -221,19 +221,19 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // Reports that a field has been added into Message2. virtual void ReportAdded( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) = 0; + const std::vector<SpecificField>& field_path) = 0; // Reports that a field has been deleted from Message1. virtual void ReportDeleted( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) = 0; + const std::vector<SpecificField>& field_path) = 0; // Reports that the value of a field has been modified. virtual void ReportModified( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) = 0; + const std::vector<SpecificField>& field_path) = 0; // Reports that a repeated field has been moved to another location. This // only applies when using TreatAsSet or TreatAsMap() -- see below. Also @@ -243,7 +243,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { virtual void ReportMoved( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { } + const std::vector<SpecificField>& field_path) { } // Reports that two fields match. Useful for doing side-by-side diffs. // This function is mutually exclusive with ReportModified and ReportMoved. @@ -252,7 +252,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { virtual void ReportMatched( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { } + const std::vector<SpecificField>& field_path) { } // Reports that two fields would have been compared, but the // comparison has been skipped because the field was marked as @@ -276,14 +276,14 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { virtual void ReportIgnored( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { } + const std::vector<SpecificField>& field_path) { } // Report that an unknown field is ignored. (see comment above). // Note this is a different function since the last SpecificField in field // path has a null field. This could break existing Reporter. virtual void ReportUnknownFieldIgnored( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) {} + const std::vector<SpecificField>& field_path) {} private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reporter); @@ -296,9 +296,10 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { MapKeyComparator(); virtual ~MapKeyComparator(); - virtual bool IsMatch(const Message& message1, - const Message& message2, - const vector<SpecificField>& parent_fields) const { + virtual bool IsMatch( + const Message& message1, + const Message& message2, + const std::vector<SpecificField>& parent_fields) const { GOOGLE_CHECK(false) << "IsMatch() is not implemented."; return false; } @@ -323,7 +324,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { const Message& message1, const Message& message2, const FieldDescriptor* field, - const vector<SpecificField>& parent_fields) = 0; + const std::vector<SpecificField>& parent_fields) = 0; // Returns true if the unknown field should be ignored. // Note: This will be called for unknown fields as well in which case @@ -331,7 +332,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { virtual bool IsUnknownFieldIgnored( const Message& message1, const Message& message2, const SpecificField& field, - const vector<SpecificField>& parent_fields) { + const std::vector<SpecificField>& parent_fields) { return false; } }; @@ -440,7 +441,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // size of each element. void TreatAsMapWithMultipleFieldsAsKey( const FieldDescriptor* field, - const vector<const FieldDescriptor*>& key_fields); + const std::vector<const FieldDescriptor*>& key_fields); // Same as TreatAsMapWithMultipleFieldsAsKey, except that each of the field // do not necessarily need to be a direct subfield. Each element in // key_field_paths indicate a path from the message being compared, listing @@ -456,7 +457,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // !key_field_path[i]->is_repeated() void TreatAsMapWithMultipleFieldPathsAsKey( const FieldDescriptor* field, - const vector<vector<const FieldDescriptor*> >& key_field_paths); + const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths); // Uses a custom MapKeyComparator to determine if two elements have the same // key when comparing a repeated field as a map. @@ -549,9 +550,10 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // Same as above, except comparing only the list of fields specified by the // two vectors of FieldDescriptors. - bool CompareWithFields(const Message& message1, const Message& message2, - const vector<const FieldDescriptor*>& message1_fields, - const vector<const FieldDescriptor*>& message2_fields); + bool CompareWithFields( + const Message& message1, const Message& message2, + const std::vector<const FieldDescriptor*>& message1_fields, + const std::vector<const FieldDescriptor*>& message2_fields); // Automatically creates a reporter that will output the differences // found (if any) to the specified output string pointer. Note that this @@ -591,35 +593,35 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // The following are implementations of the methods described above. virtual void ReportAdded(const Message& message1, const Message& message2, - const vector<SpecificField>& field_path); + const std::vector<SpecificField>& field_path); virtual void ReportDeleted(const Message& message1, const Message& message2, - const vector<SpecificField>& field_path); + const std::vector<SpecificField>& field_path); virtual void ReportModified(const Message& message1, const Message& message2, - const vector<SpecificField>& field_path); + const std::vector<SpecificField>& field_path); virtual void ReportMoved(const Message& message1, const Message& message2, - const vector<SpecificField>& field_path); + const std::vector<SpecificField>& field_path); virtual void ReportMatched(const Message& message1, const Message& message2, - const vector<SpecificField>& field_path); + const std::vector<SpecificField>& field_path); virtual void ReportIgnored(const Message& message1, const Message& message2, - const vector<SpecificField>& field_path); + const std::vector<SpecificField>& field_path); virtual void ReportUnknownFieldIgnored( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path); + const std::vector<SpecificField>& field_path); protected: // Prints the specified path of fields to the buffer. - virtual void PrintPath(const vector<SpecificField>& field_path, + virtual void PrintPath(const std::vector<SpecificField>& field_path, bool left_side); // Prints the value of fields to the buffer. left_side is true if the @@ -628,7 +630,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // unknown_field_index1 or unknown_field_index2 when an unknown field // is encountered in field_path. virtual void PrintValue(const Message& message, - const vector<SpecificField>& field_path, + const std::vector<SpecificField>& field_path, bool left_side); // Prints the specified path of unknown fields to the buffer. @@ -659,11 +661,11 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // All fields present in both lists will always be included in the combined // list. Fields only present in one of the lists will only appear in the // combined list if the corresponding fields_scope option is set to FULL. - void CombineFields(const vector<const FieldDescriptor*>& fields1, + void CombineFields(const std::vector<const FieldDescriptor*>& fields1, Scope fields1_scope, - const vector<const FieldDescriptor*>& fields2, + const std::vector<const FieldDescriptor*>& fields2, Scope fields2_scope, - vector<const FieldDescriptor*>* combined_fields); + std::vector<const FieldDescriptor*>* combined_fields); // Internal version of the Compare method which performs the actual // comparison. The parent_fields vector is a vector containing field @@ -671,34 +673,34 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // (i.e. if the current message is an embedded message, the parent_fields // vector will contain the field that has this embedded message). bool Compare(const Message& message1, const Message& message2, - vector<SpecificField>* parent_fields); + std::vector<SpecificField>* parent_fields); // Compares all the unknown fields in two messages. bool CompareUnknownFields(const Message& message1, const Message& message2, const google::protobuf::UnknownFieldSet&, const google::protobuf::UnknownFieldSet&, - vector<SpecificField>* parent_fields); + std::vector<SpecificField>* parent_fields); // Compares the specified messages for the requested field lists. The field // lists are modified depending on comparison settings, and then passed to // CompareWithFieldsInternal. bool CompareRequestedFieldsUsingSettings( const Message& message1, const Message& message2, - const vector<const FieldDescriptor*>& message1_fields, - const vector<const FieldDescriptor*>& message2_fields, - vector<SpecificField>* parent_fields); + const std::vector<const FieldDescriptor*>& message1_fields, + const std::vector<const FieldDescriptor*>& message2_fields, + std::vector<SpecificField>* parent_fields); // Compares the specified messages with the specified field lists. bool CompareWithFieldsInternal( const Message& message1, const Message& message2, - const vector<const FieldDescriptor*>& message1_fields, - const vector<const FieldDescriptor*>& message2_fields, - vector<SpecificField>* parent_fields); + const std::vector<const FieldDescriptor*>& message1_fields, + const std::vector<const FieldDescriptor*>& message2_fields, + std::vector<SpecificField>* parent_fields); // Compares the repeated fields, and report the error. bool CompareRepeatedField(const Message& message1, const Message& message2, const FieldDescriptor* field, - vector<SpecificField>* parent_fields); + std::vector<SpecificField>* parent_fields); // Shorthand for CompareFieldValueUsingParentFields with NULL parent_fields. bool CompareFieldValue(const Message& message1, @@ -716,12 +718,13 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // list of parent messages if it needs to recursively compare the given field. // To avoid confusing users you should not set it to NULL unless you modified // Reporter to handle the change of parent_fields correctly. - bool CompareFieldValueUsingParentFields(const Message& message1, - const Message& message2, - const FieldDescriptor* field, - int index1, - int index2, - vector<SpecificField>* parent_fields); + bool CompareFieldValueUsingParentFields( + const Message& message1, + const Message& message2, + const FieldDescriptor* field, + int index1, + int index2, + std::vector<SpecificField>* parent_fields); // Compares the specified field on the two messages, returning comparison // result, as returned by appropriate FieldComparator. @@ -736,7 +739,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { bool IsMatch(const FieldDescriptor* repeated_field, const MapKeyComparator* key_comparator, const Message* message1, const Message* message2, - const vector<SpecificField>& parent_fields, + const std::vector<SpecificField>& parent_fields, int index1, int index2); // Returns true when this repeated field has been configured to be treated @@ -754,13 +757,13 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { const Message& message1, const Message& message2, const FieldDescriptor* field, - const vector<SpecificField>& parent_fields); + const std::vector<SpecificField>& parent_fields); // Returns true if this unknown field is to be ignored when this // MessageDifferencer compares messages. bool IsUnknownFieldIgnored(const Message& message1, const Message& message2, const SpecificField& field, - const vector<SpecificField>& parent_fields); + const std::vector<SpecificField>& parent_fields); // Returns MapKeyComparator* when this field has been configured to // be treated as a map. If not, returns NULL. @@ -773,28 +776,29 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // This method returns false if the match failed. However, it doesn't mean // that the comparison succeeds when this method returns true (you need to // double-check in this case). - bool MatchRepeatedFieldIndices(const Message& message1, - const Message& message2, - const FieldDescriptor* repeated_field, - const vector<SpecificField>& parent_fields, - vector<int>* match_list1, - vector<int>* match_list2); + bool MatchRepeatedFieldIndices( + const Message& message1, + const Message& message2, + const FieldDescriptor* repeated_field, + const std::vector<SpecificField>& parent_fields, + std::vector<int>* match_list1, + std::vector<int>* match_list2); // If "any" is of type google.protobuf.Any, extract its payload using // DynamicMessageFactory and store in "data". bool UnpackAny(const Message& any, google::protobuf::scoped_ptr<Message>* data); // Checks if index is equal to new_index in all the specific fields. - static bool CheckPathChanged(const vector<SpecificField>& parent_fields); + static bool CheckPathChanged(const std::vector<SpecificField>& parent_fields); // Defines a map between field descriptors and their MapKeyComparators. // Used for repeated fields when they are configured as TreatAsMap. - typedef map<const FieldDescriptor*, + typedef std::map<const FieldDescriptor*, const MapKeyComparator*> FieldKeyComparatorMap; // Defines a set to store field descriptors. Used for repeated fields when // they are configured as TreatAsSet. - typedef set<const FieldDescriptor*> FieldSet; + typedef std::set<const FieldDescriptor*> FieldSet; Reporter* reporter_; DefaultFieldComparator default_field_comparator_; @@ -811,9 +815,9 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // When TreatAsMap or TreatAsMapWithMultipleFieldsAsKey is called, we don't // store the supplied FieldDescriptors directly. Instead, a new // MapKeyComparator is created for comparison purpose. - vector<MapKeyComparator*> owned_key_comparators_; + std::vector<MapKeyComparator*> owned_key_comparators_; FieldKeyComparatorMap map_field_key_comparator_; - vector<IgnoreCriteria*> ignore_criteria_; + std::vector<IgnoreCriteria*> ignore_criteria_; FieldSet ignored_fields_; @@ -831,15 +835,15 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { class LIBPROTOBUF_EXPORT FieldContext { public: explicit FieldContext( - vector<MessageDifferencer::SpecificField>* parent_fields) + std::vector<MessageDifferencer::SpecificField>* parent_fields) : parent_fields_(parent_fields) {} - vector<MessageDifferencer::SpecificField>* parent_fields() const { + std::vector<MessageDifferencer::SpecificField>* parent_fields() const { return parent_fields_; } private: - vector<MessageDifferencer::SpecificField>* parent_fields_; + std::vector<MessageDifferencer::SpecificField>* parent_fields_; }; } diff --git a/src/google/protobuf/wire_format.cc b/src/google/protobuf/wire_format.cc index 5ee4e25d..147478be 100644 --- a/src/google/protobuf/wire_format.cc +++ b/src/google/protobuf/wire_format.cc @@ -307,9 +307,9 @@ uint8* WireFormat::SerializeUnknownMessageSetItemsToArray( return target; } -int WireFormat::ComputeUnknownFieldsSize( +size_t WireFormat::ComputeUnknownFieldsSize( const UnknownFieldSet& unknown_fields) { - int size = 0; + size_t size = 0; for (int i = 0; i < unknown_fields.field_count(); i++) { const UnknownField& field = unknown_fields.field(i); @@ -355,9 +355,9 @@ int WireFormat::ComputeUnknownFieldsSize( return size; } -int WireFormat::ComputeUnknownMessageSetItemsSize( +size_t WireFormat::ComputeUnknownMessageSetItemsSize( const UnknownFieldSet& unknown_fields) { - int size = 0; + size_t size = 0; for (int i = 0; i < unknown_fields.field_count(); i++) { const UnknownField& field = unknown_fields.field(i); @@ -838,7 +838,7 @@ void WireFormat::SerializeFieldWithCachedSizes( if (is_packed && count > 0) { WireFormatLite::WriteTag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); - const int data_size = FieldDataOnlyByteSize(field, message); + const size_t data_size = FieldDataOnlyByteSize(field, message); output->WriteVarint32(data_size); } @@ -964,11 +964,11 @@ void WireFormat::SerializeMessageSetItemWithCachedSizes( // =================================================================== -int WireFormat::ByteSize(const Message& message) { +size_t WireFormat::ByteSize(const Message& message) { const Descriptor* descriptor = message.GetDescriptor(); const Reflection* message_reflection = message.GetReflection(); - int our_size = 0; + size_t our_size = 0; vector<const FieldDescriptor*> fields; message_reflection->ListFields(message, &fields); @@ -987,7 +987,7 @@ int WireFormat::ByteSize(const Message& message) { return our_size; } -int WireFormat::FieldByteSize( +size_t WireFormat::FieldByteSize( const FieldDescriptor* field, const Message& message) { const Reflection* message_reflection = message.GetReflection(); @@ -999,15 +999,15 @@ int WireFormat::FieldByteSize( return MessageSetItemByteSize(field, message); } - int count = 0; + size_t count = 0; if (field->is_repeated()) { - count = message_reflection->FieldSize(message, field); + count = FromIntSize(message_reflection->FieldSize(message, field)); } else if (message_reflection->HasField(message, field)) { count = 1; } - const int data_size = FieldDataOnlyByteSize(field, message); - int our_size = data_size; + const size_t data_size = FieldDataOnlyByteSize(field, message); + size_t our_size = data_size; if (field->is_packed()) { if (data_size > 0) { // Packed fields get serialized like a string, not their native type. @@ -1022,19 +1022,20 @@ int WireFormat::FieldByteSize( return our_size; } -int WireFormat::FieldDataOnlyByteSize( +size_t WireFormat::FieldDataOnlyByteSize( const FieldDescriptor* field, const Message& message) { const Reflection* message_reflection = message.GetReflection(); - int count = 0; + size_t count = 0; if (field->is_repeated()) { - count = message_reflection->FieldSize(message, field); + count = + internal::FromIntSize(message_reflection->FieldSize(message, field)); } else if (message_reflection->HasField(message, field)) { count = 1; } - int data_size = 0; + size_t data_size = 0; switch (field->type()) { #define HANDLE_TYPE(TYPE, TYPE_METHOD, CPPTYPE_METHOD) \ case FieldDescriptor::TYPE_##TYPE: \ @@ -1108,19 +1109,19 @@ int WireFormat::FieldDataOnlyByteSize( return data_size; } -int WireFormat::MessageSetItemByteSize( +size_t WireFormat::MessageSetItemByteSize( const FieldDescriptor* field, const Message& message) { const Reflection* message_reflection = message.GetReflection(); - int our_size = WireFormatLite::kMessageSetItemTagsSize; + size_t our_size = WireFormatLite::kMessageSetItemTagsSize; // type_id our_size += io::CodedOutputStream::VarintSize32(field->number()); // message const Message& sub_message = message_reflection->GetMessage(message, field); - int message_size = sub_message.ByteSize(); + size_t message_size = sub_message.ByteSizeLong(); our_size += io::CodedOutputStream::VarintSize32(message_size); our_size += message_size; diff --git a/src/google/protobuf/wire_format.h b/src/google/protobuf/wire_format.h index aaee21f0..de8ea574 100644 --- a/src/google/protobuf/wire_format.h +++ b/src/google/protobuf/wire_format.h @@ -85,7 +85,7 @@ class LIBPROTOBUF_EXPORT WireFormat { // Compute the byte size of a tag. For groups, this includes both the start // and end tags. - static inline int TagSize(int field_number, FieldDescriptor::Type type); + static inline size_t TagSize(int field_number, FieldDescriptor::Type type); // These procedures can be used to implement the methods of Message which // handle parsing and serialization of the protocol buffer wire format @@ -122,7 +122,7 @@ class LIBPROTOBUF_EXPORT WireFormat { // will have their ByteSize() methods called, so their sizes will be cached. // Therefore, calling this method is sufficient to allow you to call // WireFormat::SerializeWithCachedSizes() on the same object. - static int ByteSize(const Message& message); + static size_t ByteSize(const Message& message); // ----------------------------------------------------------------- // Helpers for dealing with unknown fields @@ -173,11 +173,11 @@ class LIBPROTOBUF_EXPORT WireFormat { uint8* target); // Compute the size of the UnknownFieldSet on the wire. - static int ComputeUnknownFieldsSize(const UnknownFieldSet& unknown_fields); + static size_t ComputeUnknownFieldsSize(const UnknownFieldSet& unknown_fields); // Same thing except for messages that have the message_set_wire_format // option. - static int ComputeUnknownMessageSetItemsSize( + static size_t ComputeUnknownMessageSetItemsSize( const UnknownFieldSet& unknown_fields); @@ -205,7 +205,7 @@ class LIBPROTOBUF_EXPORT WireFormat { // Compute size of a single field. If the field is a message type, this // will call ByteSize() for the embedded message, insuring that it caches // its size. - static int FieldByteSize( + static size_t FieldByteSize( const FieldDescriptor* field, // Cannot be NULL const Message& message); @@ -218,7 +218,7 @@ class LIBPROTOBUF_EXPORT WireFormat { const FieldDescriptor* field, const Message& message, io::CodedOutputStream* output); - static int MessageSetItemByteSize( + static size_t MessageSetItemByteSize( const FieldDescriptor* field, const Message& message); @@ -226,7 +226,7 @@ class LIBPROTOBUF_EXPORT WireFormat { // only includes the size of the raw data, and not the size of the total // length, but for other length-delimited types, the size of the length is // included. - static int FieldDataOnlyByteSize( + static size_t FieldDataOnlyByteSize( const FieldDescriptor* field, // Cannot be NULL const Message& message); @@ -301,7 +301,8 @@ inline uint32 WireFormat::MakeTag(const FieldDescriptor* field) { return WireFormatLite::MakeTag(field->number(), WireTypeForField(field)); } -inline int WireFormat::TagSize(int field_number, FieldDescriptor::Type type) { +inline size_t WireFormat::TagSize(int field_number, + FieldDescriptor::Type type) { // Some compilers don't like enum -> enum casts, so we implicit_cast to // int first. return WireFormatLite::TagSize(field_number, diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc index 05cc0854..5bed7af4 100644 --- a/src/google/protobuf/wire_format_lite.cc +++ b/src/google/protobuf/wire_format_lite.cc @@ -61,7 +61,7 @@ const int WireFormatLite::kMessageSetMessageTag; #endif // IBM xlC requires prefixing constants with WireFormatLite:: -const int WireFormatLite::kMessageSetItemTagsSize = +const size_t WireFormatLite::kMessageSetItemTagsSize = io::CodedOutputStream::StaticVarintSize32< WireFormatLite::kMessageSetItemStartTag>::value + io::CodedOutputStream::StaticVarintSize32< diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index 580d4db0..eeb3650f 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -155,7 +155,8 @@ class LIBPROTOBUF_EXPORT WireFormatLite { // Compute the byte size of a tag. For groups, this includes both the start // and end tags. - static inline int TagSize(int field_number, WireFormatLite::FieldType type); + static inline size_t TagSize(int field_number, + WireFormatLite::FieldType type); // Skips a field value with the given tag. The input should start // positioned immediately after the tag. Skipped values are simply discarded, @@ -212,7 +213,7 @@ class LIBPROTOBUF_EXPORT WireFormatLite { WireFormatLite::WIRETYPE_LENGTH_DELIMITED); // Byte size of all tags of a MessageSet::Item combined. - static const int kMessageSetItemTagsSize; + static const size_t kMessageSetItemTagsSize; // Helper functions for converting between floats/doubles and IEEE-754 // uint32s/uint64s so that they can be written. (Assumes your platform @@ -510,40 +511,40 @@ class LIBPROTOBUF_EXPORT WireFormatLite { // the tag, so you must also call TagSize(). (This is because, for repeated // fields, you should only call TagSize() once and multiply it by the element // count, but you may have to call XxSize() for each individual element.) - static inline int Int32Size ( int32 value); - static inline int Int64Size ( int64 value); - static inline int UInt32Size (uint32 value); - static inline int UInt64Size (uint64 value); - static inline int SInt32Size ( int32 value); - static inline int SInt64Size ( int64 value); - static inline int EnumSize ( int value); + static inline size_t Int32Size ( int32 value); + static inline size_t Int64Size ( int64 value); + static inline size_t UInt32Size (uint32 value); + static inline size_t UInt64Size (uint64 value); + static inline size_t SInt32Size ( int32 value); + static inline size_t SInt64Size ( int64 value); + static inline size_t EnumSize ( int value); // These types always have the same size. - static const int kFixed32Size = 4; - static const int kFixed64Size = 8; - static const int kSFixed32Size = 4; - static const int kSFixed64Size = 8; - static const int kFloatSize = 4; - static const int kDoubleSize = 8; - static const int kBoolSize = 1; + static const size_t kFixed32Size = 4; + static const size_t kFixed64Size = 8; + static const size_t kSFixed32Size = 4; + static const size_t kSFixed64Size = 8; + static const size_t kFloatSize = 4; + static const size_t kDoubleSize = 8; + static const size_t kBoolSize = 1; - static inline int StringSize(const string& value); - static inline int BytesSize (const string& value); + static inline size_t StringSize(const string& value); + static inline size_t BytesSize (const string& value); - static inline int GroupSize (const MessageLite& value); - static inline int MessageSize(const MessageLite& value); + static inline size_t GroupSize (const MessageLite& value); + static inline size_t MessageSize(const MessageLite& value); // Like above, but de-virtualize the call to ByteSize(). The // pointer must point at an instance of MessageType, *not* a subclass (or // the subclass must not override ByteSize()). template<typename MessageType> - static inline int GroupSizeNoVirtual (const MessageType& value); + static inline size_t GroupSizeNoVirtual (const MessageType& value); template<typename MessageType> - static inline int MessageSizeNoVirtual(const MessageType& value); + static inline size_t MessageSizeNoVirtual(const MessageType& value); // Given the length of data, calculate the byte size of the data on the // wire if we encode the data as a length delimited field. - static inline int LengthDelimitedSize(int length); + static inline size_t LengthDelimitedSize(size_t length); private: // A helper method for the repeated primitive reader. This method has @@ -626,9 +627,9 @@ inline int WireFormatLite::GetTagFieldNumber(uint32 tag) { return static_cast<int>(tag >> kTagTypeBits); } -inline int WireFormatLite::TagSize(int field_number, - WireFormatLite::FieldType type) { - int result = io::CodedOutputStream::VarintSize32( +inline size_t WireFormatLite::TagSize(int field_number, + WireFormatLite::FieldType type) { + size_t result = io::CodedOutputStream::VarintSize32( field_number << kTagTypeBits); if (type == TYPE_GROUP) { // Groups have both a start and an end tag. diff --git a/src/google/protobuf/wire_format_lite_inl.h b/src/google/protobuf/wire_format_lite_inl.h index 93d7c824..fbad965e 100644 --- a/src/google/protobuf/wire_format_lite_inl.h +++ b/src/google/protobuf/wire_format_lite_inl.h @@ -810,62 +810,58 @@ inline uint8* WireFormatLite::InternalWriteMessageNoVirtualToArray( // =================================================================== -inline int WireFormatLite::Int32Size(int32 value) { +inline size_t WireFormatLite::Int32Size(int32 value) { return io::CodedOutputStream::VarintSize32SignExtended(value); } -inline int WireFormatLite::Int64Size(int64 value) { +inline size_t WireFormatLite::Int64Size(int64 value) { return io::CodedOutputStream::VarintSize64(static_cast<uint64>(value)); } -inline int WireFormatLite::UInt32Size(uint32 value) { +inline size_t WireFormatLite::UInt32Size(uint32 value) { return io::CodedOutputStream::VarintSize32(value); } -inline int WireFormatLite::UInt64Size(uint64 value) { +inline size_t WireFormatLite::UInt64Size(uint64 value) { return io::CodedOutputStream::VarintSize64(value); } -inline int WireFormatLite::SInt32Size(int32 value) { +inline size_t WireFormatLite::SInt32Size(int32 value) { return io::CodedOutputStream::VarintSize32(ZigZagEncode32(value)); } -inline int WireFormatLite::SInt64Size(int64 value) { +inline size_t WireFormatLite::SInt64Size(int64 value) { return io::CodedOutputStream::VarintSize64(ZigZagEncode64(value)); } -inline int WireFormatLite::EnumSize(int value) { +inline size_t WireFormatLite::EnumSize(int value) { return io::CodedOutputStream::VarintSize32SignExtended(value); } -inline int WireFormatLite::StringSize(const string& value) { - return static_cast<int>( - io::CodedOutputStream::VarintSize32(static_cast<uint32>(value.size())) + - value.size()); +inline size_t WireFormatLite::StringSize(const string& value) { + return LengthDelimitedSize(value.size()); } -inline int WireFormatLite::BytesSize(const string& value) { - return static_cast<int>( - io::CodedOutputStream::VarintSize32(static_cast<uint32>(value.size())) + - value.size()); +inline size_t WireFormatLite::BytesSize(const string& value) { + return LengthDelimitedSize(value.size()); } -inline int WireFormatLite::GroupSize(const MessageLite& value) { - return value.ByteSize(); +inline size_t WireFormatLite::GroupSize(const MessageLite& value) { + return value.ByteSizeLong(); } -inline int WireFormatLite::MessageSize(const MessageLite& value) { - return LengthDelimitedSize(value.ByteSize()); +inline size_t WireFormatLite::MessageSize(const MessageLite& value) { + return LengthDelimitedSize(value.ByteSizeLong()); } // See comment on ReadGroupNoVirtual to understand the need for this template // parameter name. template<typename MessageType_WorkAroundCppLookupDefect> -inline int WireFormatLite::GroupSizeNoVirtual( +inline size_t WireFormatLite::GroupSizeNoVirtual( const MessageType_WorkAroundCppLookupDefect& value) { - return value.MessageType_WorkAroundCppLookupDefect::ByteSize(); + return value.MessageType_WorkAroundCppLookupDefect::ByteSizeLong(); } template<typename MessageType_WorkAroundCppLookupDefect> -inline int WireFormatLite::MessageSizeNoVirtual( +inline size_t WireFormatLite::MessageSizeNoVirtual( const MessageType_WorkAroundCppLookupDefect& value) { return LengthDelimitedSize( - value.MessageType_WorkAroundCppLookupDefect::ByteSize()); + value.MessageType_WorkAroundCppLookupDefect::ByteSizeLong()); } -inline int WireFormatLite::LengthDelimitedSize(int length) { +inline size_t WireFormatLite::LengthDelimitedSize(size_t length) { return io::CodedOutputStream::VarintSize32(length) + length; } diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index 627b556e..41f1a271 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -67,14 +67,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() { DoubleValue_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( DoubleValue_descriptor_, - DoubleValue::default_instance_, + DoubleValue::internal_default_instance(), DoubleValue_offsets_, -1, -1, -1, sizeof(DoubleValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, _internal_metadata_)); FloatValue_descriptor_ = file->message_type(1); static const int FloatValue_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, value_), @@ -82,14 +81,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() { FloatValue_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FloatValue_descriptor_, - FloatValue::default_instance_, + FloatValue::internal_default_instance(), FloatValue_offsets_, -1, -1, -1, sizeof(FloatValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, _internal_metadata_)); Int64Value_descriptor_ = file->message_type(2); static const int Int64Value_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, value_), @@ -97,14 +95,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() { Int64Value_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Int64Value_descriptor_, - Int64Value::default_instance_, + Int64Value::internal_default_instance(), Int64Value_offsets_, -1, -1, -1, sizeof(Int64Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, _internal_metadata_)); UInt64Value_descriptor_ = file->message_type(3); static const int UInt64Value_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, value_), @@ -112,14 +109,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() { UInt64Value_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( UInt64Value_descriptor_, - UInt64Value::default_instance_, + UInt64Value::internal_default_instance(), UInt64Value_offsets_, -1, -1, -1, sizeof(UInt64Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, _internal_metadata_)); Int32Value_descriptor_ = file->message_type(4); static const int Int32Value_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, value_), @@ -127,14 +123,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() { Int32Value_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Int32Value_descriptor_, - Int32Value::default_instance_, + Int32Value::internal_default_instance(), Int32Value_offsets_, -1, -1, -1, sizeof(Int32Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, _internal_metadata_)); UInt32Value_descriptor_ = file->message_type(5); static const int UInt32Value_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, value_), @@ -142,14 +137,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() { UInt32Value_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( UInt32Value_descriptor_, - UInt32Value::default_instance_, + UInt32Value::internal_default_instance(), UInt32Value_offsets_, -1, -1, -1, sizeof(UInt32Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, _internal_metadata_)); BoolValue_descriptor_ = file->message_type(6); static const int BoolValue_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, value_), @@ -157,14 +151,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() { BoolValue_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( BoolValue_descriptor_, - BoolValue::default_instance_, + BoolValue::internal_default_instance(), BoolValue_offsets_, -1, -1, -1, sizeof(BoolValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, _internal_metadata_)); StringValue_descriptor_ = file->message_type(7); static const int StringValue_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, value_), @@ -172,14 +165,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() { StringValue_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( StringValue_descriptor_, - StringValue::default_instance_, + StringValue::internal_default_instance(), StringValue_offsets_, -1, -1, -1, sizeof(StringValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, _internal_metadata_)); BytesValue_descriptor_ = file->message_type(8); static const int BytesValue_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, value_), @@ -187,20 +179,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() { BytesValue_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( BytesValue_descriptor_, - BytesValue::default_instance_, + BytesValue::internal_default_instance(), BytesValue_offsets_, -1, -1, -1, sizeof(BytesValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, _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_2fwrappers_2eproto); } @@ -209,55 +200,73 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DoubleValue_descriptor_, &DoubleValue::default_instance()); + DoubleValue_descriptor_, DoubleValue::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FloatValue_descriptor_, &FloatValue::default_instance()); + FloatValue_descriptor_, FloatValue::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Int64Value_descriptor_, &Int64Value::default_instance()); + Int64Value_descriptor_, Int64Value::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UInt64Value_descriptor_, &UInt64Value::default_instance()); + UInt64Value_descriptor_, UInt64Value::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Int32Value_descriptor_, &Int32Value::default_instance()); + Int32Value_descriptor_, Int32Value::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UInt32Value_descriptor_, &UInt32Value::default_instance()); + UInt32Value_descriptor_, UInt32Value::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - BoolValue_descriptor_, &BoolValue::default_instance()); + BoolValue_descriptor_, BoolValue::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - StringValue_descriptor_, &StringValue::default_instance()); + StringValue_descriptor_, StringValue::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - BytesValue_descriptor_, &BytesValue::default_instance()); + BytesValue_descriptor_, BytesValue::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto() { - delete DoubleValue::default_instance_; delete DoubleValue_reflection_; - delete FloatValue::default_instance_; delete FloatValue_reflection_; - delete Int64Value::default_instance_; delete Int64Value_reflection_; - delete UInt64Value::default_instance_; delete UInt64Value_reflection_; - delete Int32Value::default_instance_; delete Int32Value_reflection_; - delete UInt32Value::default_instance_; delete UInt32Value_reflection_; - delete BoolValue::default_instance_; delete BoolValue_reflection_; - delete StringValue::default_instance_; delete StringValue_reflection_; - delete BytesValue::default_instance_; delete BytesValue_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + DoubleValue::default_instance_.DefaultConstruct(); + FloatValue::default_instance_.DefaultConstruct(); + Int64Value::default_instance_.DefaultConstruct(); + UInt64Value::default_instance_.DefaultConstruct(); + Int32Value::default_instance_.DefaultConstruct(); + UInt32Value::default_instance_.DefaultConstruct(); + BoolValue::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + StringValue::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + BytesValue::default_instance_.DefaultConstruct(); + DoubleValue::default_instance_.get_mutable()->InitAsDefaultInstance(); + FloatValue::default_instance_.get_mutable()->InitAsDefaultInstance(); + Int64Value::default_instance_.get_mutable()->InitAsDefaultInstance(); + UInt64Value::default_instance_.get_mutable()->InitAsDefaultInstance(); + Int32Value::default_instance_.get_mutable()->InitAsDefaultInstance(); + UInt32Value::default_instance_.get_mutable()->InitAsDefaultInstance(); + BoolValue::default_instance_.get_mutable()->InitAsDefaultInstance(); + StringValue::default_instance_.get_mutable()->InitAsDefaultInstance(); + BytesValue::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\036google/protobuf/wrappers.proto\022\017google" ".protobuf\"\034\n\013DoubleValue\022\r\n\005value\030\001 \001(\001\"" @@ -266,34 +275,21 @@ void protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto() { "e\030\001 \001(\004\"\033\n\nInt32Value\022\r\n\005value\030\001 \001(\005\"\034\n\013" "UInt32Value\022\r\n\005value\030\001 \001(\r\"\032\n\tBoolValue\022" "\r\n\005value\030\001 \001(\010\"\034\n\013StringValue\022\r\n\005value\030\001" - " \001(\t\"\033\n\nBytesValue\022\r\n\005value\030\001 \001(\014B\177\n\023com" + " \001(\t\"\033\n\nBytesValue\022\r\n\005value\030\001 \001(\014B|\n\023com" ".google.protobufB\rWrappersProtoP\001Z*githu" - "b.com/golang/protobuf/ptypes/wrappers\240\001\001" - "\370\001\001\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTyp" - "esb\006proto3", 450); + "b.com/golang/protobuf/ptypes/wrappers\370\001\001" + "\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb" + "\006proto3", 447); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/wrappers.proto", &protobuf_RegisterTypes); - DoubleValue::default_instance_ = new DoubleValue(); - FloatValue::default_instance_ = new FloatValue(); - Int64Value::default_instance_ = new Int64Value(); - UInt64Value::default_instance_ = new UInt64Value(); - Int32Value::default_instance_ = new Int32Value(); - UInt32Value::default_instance_ = new UInt32Value(); - BoolValue::default_instance_ = new BoolValue(); - StringValue::default_instance_ = new StringValue(); - BytesValue::default_instance_ = new BytesValue(); - DoubleValue::default_instance_->InitAsDefaultInstance(); - FloatValue::default_instance_->InitAsDefaultInstance(); - Int64Value::default_instance_->InitAsDefaultInstance(); - UInt64Value::default_instance_->InitAsDefaultInstance(); - Int32Value::default_instance_->InitAsDefaultInstance(); - UInt32Value::default_instance_->InitAsDefaultInstance(); - BoolValue::default_instance_->InitAsDefaultInstance(); - StringValue::default_instance_->InitAsDefaultInstance(); - BytesValue::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fwrappers_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fwrappers_2eproto() { @@ -301,6 +297,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fwrappers_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fwrappers_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 @@ -309,34 +315,35 @@ const int DoubleValue::kValueFieldNumber; DoubleValue::DoubleValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DoubleValue) } - DoubleValue::DoubleValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.DoubleValue) } void DoubleValue::InitAsDefaultInstance() { - _is_default_instance_ = true; } DoubleValue::DoubleValue(const DoubleValue& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.DoubleValue) } void DoubleValue::SharedCtor() { - _is_default_instance_ = false; - _cached_size_ = 0; value_ = 0; + _cached_size_ = 0; } DoubleValue::~DoubleValue() { @@ -345,12 +352,11 @@ DoubleValue::~DoubleValue() { } void DoubleValue::SharedDtor() { - if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { return; } - if (this != default_instance_) { - } } void DoubleValue::ArenaDtor(void* object) { @@ -370,11 +376,11 @@ const ::google::protobuf::Descriptor* DoubleValue::descriptor() { } const DoubleValue& DoubleValue::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + return *internal_default_instance(); } -DoubleValue* DoubleValue::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> DoubleValue::default_instance_; DoubleValue* DoubleValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<DoubleValue>(arena); @@ -398,10 +404,10 @@ bool DoubleValue::MergePartialFromCodedStream( // optional double value = 1; case 1: { if (tag == 9) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( input, &value_))); - } else { goto handle_unusual; } @@ -454,27 +460,26 @@ void DoubleValue::SerializeWithCachedSizes( return target; } -int DoubleValue::ByteSize() const { +size_t DoubleValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DoubleValue) - int total_size = 0; + size_t total_size = 0; // optional double value = 1; if (this->value() != 0) { total_size += 1 + 8; } + 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 DoubleValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DoubleValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const DoubleValue* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const DoubleValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const DoubleValue>( &from); if (source == NULL) { @@ -482,15 +487,21 @@ void DoubleValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DoubleValue) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void DoubleValue::MergeFrom(const DoubleValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DoubleValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void DoubleValue::UnsafeMergeFrom(const DoubleValue& from) { + GOOGLE_DCHECK(&from != this); if (from.value() != 0) { set_value(from.value()); } @@ -507,7 +518,7 @@ void DoubleValue::CopyFrom(const DoubleValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DoubleValue) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool DoubleValue::IsInitialized() const { @@ -521,7 +532,7 @@ void DoubleValue::Swap(DoubleValue* other) { InternalSwap(other); } else { DoubleValue temp; - temp.MergeFrom(*this); + temp.UnsafeMergeFrom(*this); CopyFrom(*other); other->CopyFrom(temp); } @@ -552,11 +563,11 @@ void DoubleValue::InternalSwap(DoubleValue* other) { void DoubleValue::clear_value() { value_ = 0; } - double DoubleValue::value() const { +double DoubleValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.DoubleValue.value) return value_; } - void DoubleValue::set_value(double value) { +void DoubleValue::set_value(double value) { value_ = value; // @@protoc_insertion_point(field_set:google.protobuf.DoubleValue.value) @@ -572,34 +583,35 @@ const int FloatValue::kValueFieldNumber; FloatValue::FloatValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FloatValue) } - FloatValue::FloatValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.FloatValue) } void FloatValue::InitAsDefaultInstance() { - _is_default_instance_ = true; } FloatValue::FloatValue(const FloatValue& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.FloatValue) } void FloatValue::SharedCtor() { - _is_default_instance_ = false; - _cached_size_ = 0; value_ = 0; + _cached_size_ = 0; } FloatValue::~FloatValue() { @@ -608,12 +620,11 @@ FloatValue::~FloatValue() { } void FloatValue::SharedDtor() { - if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { return; } - if (this != default_instance_) { - } } void FloatValue::ArenaDtor(void* object) { @@ -633,11 +644,11 @@ const ::google::protobuf::Descriptor* FloatValue::descriptor() { } const FloatValue& FloatValue::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + return *internal_default_instance(); } -FloatValue* FloatValue::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<FloatValue> FloatValue::default_instance_; FloatValue* FloatValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<FloatValue>(arena); @@ -661,10 +672,10 @@ bool FloatValue::MergePartialFromCodedStream( // optional float value = 1; case 1: { if (tag == 13) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &value_))); - } else { goto handle_unusual; } @@ -717,27 +728,26 @@ void FloatValue::SerializeWithCachedSizes( return target; } -int FloatValue::ByteSize() const { +size_t FloatValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FloatValue) - int total_size = 0; + size_t total_size = 0; // optional float value = 1; if (this->value() != 0) { total_size += 1 + 4; } + 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 FloatValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FloatValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const FloatValue* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FloatValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const FloatValue>( &from); if (source == NULL) { @@ -745,15 +755,21 @@ void FloatValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FloatValue) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void FloatValue::MergeFrom(const FloatValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FloatValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void FloatValue::UnsafeMergeFrom(const FloatValue& from) { + GOOGLE_DCHECK(&from != this); if (from.value() != 0) { set_value(from.value()); } @@ -770,7 +786,7 @@ void FloatValue::CopyFrom(const FloatValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FloatValue) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FloatValue::IsInitialized() const { @@ -784,7 +800,7 @@ void FloatValue::Swap(FloatValue* other) { InternalSwap(other); } else { FloatValue temp; - temp.MergeFrom(*this); + temp.UnsafeMergeFrom(*this); CopyFrom(*other); other->CopyFrom(temp); } @@ -815,11 +831,11 @@ void FloatValue::InternalSwap(FloatValue* other) { void FloatValue::clear_value() { value_ = 0; } - float FloatValue::value() const { +float FloatValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.FloatValue.value) return value_; } - void FloatValue::set_value(float value) { +void FloatValue::set_value(float value) { value_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FloatValue.value) @@ -835,34 +851,35 @@ const int Int64Value::kValueFieldNumber; Int64Value::Int64Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Int64Value) } - Int64Value::Int64Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Int64Value) } void Int64Value::InitAsDefaultInstance() { - _is_default_instance_ = true; } Int64Value::Int64Value(const Int64Value& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Int64Value) } void Int64Value::SharedCtor() { - _is_default_instance_ = false; - _cached_size_ = 0; value_ = GOOGLE_LONGLONG(0); + _cached_size_ = 0; } Int64Value::~Int64Value() { @@ -871,12 +888,11 @@ Int64Value::~Int64Value() { } void Int64Value::SharedDtor() { - if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { return; } - if (this != default_instance_) { - } } void Int64Value::ArenaDtor(void* object) { @@ -896,11 +912,11 @@ const ::google::protobuf::Descriptor* Int64Value::descriptor() { } const Int64Value& Int64Value::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + return *internal_default_instance(); } -Int64Value* Int64Value::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<Int64Value> Int64Value::default_instance_; Int64Value* Int64Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Int64Value>(arena); @@ -924,10 +940,10 @@ bool Int64Value::MergePartialFromCodedStream( // optional int64 value = 1; case 1: { if (tag == 8) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( input, &value_))); - } else { goto handle_unusual; } @@ -980,9 +996,9 @@ void Int64Value::SerializeWithCachedSizes( return target; } -int Int64Value::ByteSize() const { +size_t Int64Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int64Value) - int total_size = 0; + size_t total_size = 0; // optional int64 value = 1; if (this->value() != 0) { @@ -991,18 +1007,17 @@ int Int64Value::ByteSize() const { this->value()); } + 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 Int64Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Int64Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Int64Value* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Int64Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const Int64Value>( &from); if (source == NULL) { @@ -1010,15 +1025,21 @@ void Int64Value::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Int64Value) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Int64Value::MergeFrom(const Int64Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int64Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Int64Value::UnsafeMergeFrom(const Int64Value& from) { + GOOGLE_DCHECK(&from != this); if (from.value() != 0) { set_value(from.value()); } @@ -1035,7 +1056,7 @@ void Int64Value::CopyFrom(const Int64Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Int64Value) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Int64Value::IsInitialized() const { @@ -1049,7 +1070,7 @@ void Int64Value::Swap(Int64Value* other) { InternalSwap(other); } else { Int64Value temp; - temp.MergeFrom(*this); + temp.UnsafeMergeFrom(*this); CopyFrom(*other); other->CopyFrom(temp); } @@ -1080,11 +1101,11 @@ void Int64Value::InternalSwap(Int64Value* other) { void Int64Value::clear_value() { value_ = GOOGLE_LONGLONG(0); } - ::google::protobuf::int64 Int64Value::value() const { +::google::protobuf::int64 Int64Value::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Int64Value.value) return value_; } - void Int64Value::set_value(::google::protobuf::int64 value) { +void Int64Value::set_value(::google::protobuf::int64 value) { value_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Int64Value.value) @@ -1100,34 +1121,35 @@ const int UInt64Value::kValueFieldNumber; UInt64Value::UInt64Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UInt64Value) } - UInt64Value::UInt64Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt64Value) } void UInt64Value::InitAsDefaultInstance() { - _is_default_instance_ = true; } UInt64Value::UInt64Value(const UInt64Value& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.UInt64Value) } void UInt64Value::SharedCtor() { - _is_default_instance_ = false; - _cached_size_ = 0; value_ = GOOGLE_ULONGLONG(0); + _cached_size_ = 0; } UInt64Value::~UInt64Value() { @@ -1136,12 +1158,11 @@ UInt64Value::~UInt64Value() { } void UInt64Value::SharedDtor() { - if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { return; } - if (this != default_instance_) { - } } void UInt64Value::ArenaDtor(void* object) { @@ -1161,11 +1182,11 @@ const ::google::protobuf::Descriptor* UInt64Value::descriptor() { } const UInt64Value& UInt64Value::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + return *internal_default_instance(); } -UInt64Value* UInt64Value::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> UInt64Value::default_instance_; UInt64Value* UInt64Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<UInt64Value>(arena); @@ -1189,10 +1210,10 @@ bool UInt64Value::MergePartialFromCodedStream( // optional uint64 value = 1; case 1: { if (tag == 8) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( input, &value_))); - } else { goto handle_unusual; } @@ -1245,9 +1266,9 @@ void UInt64Value::SerializeWithCachedSizes( return target; } -int UInt64Value::ByteSize() const { +size_t UInt64Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt64Value) - int total_size = 0; + size_t total_size = 0; // optional uint64 value = 1; if (this->value() != 0) { @@ -1256,18 +1277,17 @@ int UInt64Value::ByteSize() const { this->value()); } + 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 UInt64Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UInt64Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const UInt64Value* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const UInt64Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const UInt64Value>( &from); if (source == NULL) { @@ -1275,15 +1295,21 @@ void UInt64Value::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UInt64Value) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void UInt64Value::MergeFrom(const UInt64Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt64Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void UInt64Value::UnsafeMergeFrom(const UInt64Value& from) { + GOOGLE_DCHECK(&from != this); if (from.value() != 0) { set_value(from.value()); } @@ -1300,7 +1326,7 @@ void UInt64Value::CopyFrom(const UInt64Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UInt64Value) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool UInt64Value::IsInitialized() const { @@ -1314,7 +1340,7 @@ void UInt64Value::Swap(UInt64Value* other) { InternalSwap(other); } else { UInt64Value temp; - temp.MergeFrom(*this); + temp.UnsafeMergeFrom(*this); CopyFrom(*other); other->CopyFrom(temp); } @@ -1345,11 +1371,11 @@ void UInt64Value::InternalSwap(UInt64Value* other) { void UInt64Value::clear_value() { value_ = GOOGLE_ULONGLONG(0); } - ::google::protobuf::uint64 UInt64Value::value() const { +::google::protobuf::uint64 UInt64Value::value() const { // @@protoc_insertion_point(field_get:google.protobuf.UInt64Value.value) return value_; } - void UInt64Value::set_value(::google::protobuf::uint64 value) { +void UInt64Value::set_value(::google::protobuf::uint64 value) { value_ = value; // @@protoc_insertion_point(field_set:google.protobuf.UInt64Value.value) @@ -1365,34 +1391,35 @@ const int Int32Value::kValueFieldNumber; Int32Value::Int32Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Int32Value) } - Int32Value::Int32Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Int32Value) } void Int32Value::InitAsDefaultInstance() { - _is_default_instance_ = true; } Int32Value::Int32Value(const Int32Value& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Int32Value) } void Int32Value::SharedCtor() { - _is_default_instance_ = false; - _cached_size_ = 0; value_ = 0; + _cached_size_ = 0; } Int32Value::~Int32Value() { @@ -1401,12 +1428,11 @@ Int32Value::~Int32Value() { } void Int32Value::SharedDtor() { - if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { return; } - if (this != default_instance_) { - } } void Int32Value::ArenaDtor(void* object) { @@ -1426,11 +1452,11 @@ const ::google::protobuf::Descriptor* Int32Value::descriptor() { } const Int32Value& Int32Value::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + return *internal_default_instance(); } -Int32Value* Int32Value::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<Int32Value> Int32Value::default_instance_; Int32Value* Int32Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Int32Value>(arena); @@ -1454,10 +1480,10 @@ bool Int32Value::MergePartialFromCodedStream( // optional int32 value = 1; case 1: { if (tag == 8) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &value_))); - } else { goto handle_unusual; } @@ -1510,9 +1536,9 @@ void Int32Value::SerializeWithCachedSizes( return target; } -int Int32Value::ByteSize() const { +size_t Int32Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int32Value) - int total_size = 0; + size_t total_size = 0; // optional int32 value = 1; if (this->value() != 0) { @@ -1521,18 +1547,17 @@ int Int32Value::ByteSize() const { this->value()); } + 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 Int32Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Int32Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Int32Value* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Int32Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const Int32Value>( &from); if (source == NULL) { @@ -1540,15 +1565,21 @@ void Int32Value::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Int32Value) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Int32Value::MergeFrom(const Int32Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int32Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Int32Value::UnsafeMergeFrom(const Int32Value& from) { + GOOGLE_DCHECK(&from != this); if (from.value() != 0) { set_value(from.value()); } @@ -1565,7 +1596,7 @@ void Int32Value::CopyFrom(const Int32Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Int32Value) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Int32Value::IsInitialized() const { @@ -1579,7 +1610,7 @@ void Int32Value::Swap(Int32Value* other) { InternalSwap(other); } else { Int32Value temp; - temp.MergeFrom(*this); + temp.UnsafeMergeFrom(*this); CopyFrom(*other); other->CopyFrom(temp); } @@ -1610,11 +1641,11 @@ void Int32Value::InternalSwap(Int32Value* other) { void Int32Value::clear_value() { value_ = 0; } - ::google::protobuf::int32 Int32Value::value() const { +::google::protobuf::int32 Int32Value::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Int32Value.value) return value_; } - void Int32Value::set_value(::google::protobuf::int32 value) { +void Int32Value::set_value(::google::protobuf::int32 value) { value_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Int32Value.value) @@ -1630,34 +1661,35 @@ const int UInt32Value::kValueFieldNumber; UInt32Value::UInt32Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UInt32Value) } - UInt32Value::UInt32Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt32Value) } void UInt32Value::InitAsDefaultInstance() { - _is_default_instance_ = true; } UInt32Value::UInt32Value(const UInt32Value& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.UInt32Value) } void UInt32Value::SharedCtor() { - _is_default_instance_ = false; - _cached_size_ = 0; value_ = 0u; + _cached_size_ = 0; } UInt32Value::~UInt32Value() { @@ -1666,12 +1698,11 @@ UInt32Value::~UInt32Value() { } void UInt32Value::SharedDtor() { - if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { return; } - if (this != default_instance_) { - } } void UInt32Value::ArenaDtor(void* object) { @@ -1691,11 +1722,11 @@ const ::google::protobuf::Descriptor* UInt32Value::descriptor() { } const UInt32Value& UInt32Value::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + return *internal_default_instance(); } -UInt32Value* UInt32Value::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> UInt32Value::default_instance_; UInt32Value* UInt32Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<UInt32Value>(arena); @@ -1719,10 +1750,10 @@ bool UInt32Value::MergePartialFromCodedStream( // optional uint32 value = 1; case 1: { if (tag == 8) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &value_))); - } else { goto handle_unusual; } @@ -1775,9 +1806,9 @@ void UInt32Value::SerializeWithCachedSizes( return target; } -int UInt32Value::ByteSize() const { +size_t UInt32Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt32Value) - int total_size = 0; + size_t total_size = 0; // optional uint32 value = 1; if (this->value() != 0) { @@ -1786,18 +1817,17 @@ int UInt32Value::ByteSize() const { this->value()); } + 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 UInt32Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UInt32Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const UInt32Value* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const UInt32Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const UInt32Value>( &from); if (source == NULL) { @@ -1805,15 +1835,21 @@ void UInt32Value::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UInt32Value) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void UInt32Value::MergeFrom(const UInt32Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt32Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void UInt32Value::UnsafeMergeFrom(const UInt32Value& from) { + GOOGLE_DCHECK(&from != this); if (from.value() != 0) { set_value(from.value()); } @@ -1830,7 +1866,7 @@ void UInt32Value::CopyFrom(const UInt32Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UInt32Value) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool UInt32Value::IsInitialized() const { @@ -1844,7 +1880,7 @@ void UInt32Value::Swap(UInt32Value* other) { InternalSwap(other); } else { UInt32Value temp; - temp.MergeFrom(*this); + temp.UnsafeMergeFrom(*this); CopyFrom(*other); other->CopyFrom(temp); } @@ -1875,11 +1911,11 @@ void UInt32Value::InternalSwap(UInt32Value* other) { void UInt32Value::clear_value() { value_ = 0u; } - ::google::protobuf::uint32 UInt32Value::value() const { +::google::protobuf::uint32 UInt32Value::value() const { // @@protoc_insertion_point(field_get:google.protobuf.UInt32Value.value) return value_; } - void UInt32Value::set_value(::google::protobuf::uint32 value) { +void UInt32Value::set_value(::google::protobuf::uint32 value) { value_ = value; // @@protoc_insertion_point(field_set:google.protobuf.UInt32Value.value) @@ -1895,34 +1931,35 @@ const int BoolValue::kValueFieldNumber; BoolValue::BoolValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.BoolValue) } - BoolValue::BoolValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.BoolValue) } void BoolValue::InitAsDefaultInstance() { - _is_default_instance_ = true; } BoolValue::BoolValue(const BoolValue& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.BoolValue) } void BoolValue::SharedCtor() { - _is_default_instance_ = false; - _cached_size_ = 0; value_ = false; + _cached_size_ = 0; } BoolValue::~BoolValue() { @@ -1931,12 +1968,11 @@ BoolValue::~BoolValue() { } void BoolValue::SharedDtor() { - if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { return; } - if (this != default_instance_) { - } } void BoolValue::ArenaDtor(void* object) { @@ -1956,11 +1992,11 @@ const ::google::protobuf::Descriptor* BoolValue::descriptor() { } const BoolValue& BoolValue::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + return *internal_default_instance(); } -BoolValue* BoolValue::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<BoolValue> BoolValue::default_instance_; BoolValue* BoolValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<BoolValue>(arena); @@ -1984,10 +2020,10 @@ bool BoolValue::MergePartialFromCodedStream( // optional bool value = 1; case 1: { if (tag == 8) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &value_))); - } else { goto handle_unusual; } @@ -2040,27 +2076,26 @@ void BoolValue::SerializeWithCachedSizes( return target; } -int BoolValue::ByteSize() const { +size_t BoolValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.BoolValue) - int total_size = 0; + size_t total_size = 0; // optional bool value = 1; if (this->value() != 0) { total_size += 1 + 1; } + 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 BoolValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.BoolValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const BoolValue* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const BoolValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const BoolValue>( &from); if (source == NULL) { @@ -2068,15 +2103,21 @@ void BoolValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.BoolValue) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void BoolValue::MergeFrom(const BoolValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BoolValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void BoolValue::UnsafeMergeFrom(const BoolValue& from) { + GOOGLE_DCHECK(&from != this); if (from.value() != 0) { set_value(from.value()); } @@ -2093,7 +2134,7 @@ void BoolValue::CopyFrom(const BoolValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.BoolValue) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool BoolValue::IsInitialized() const { @@ -2107,7 +2148,7 @@ void BoolValue::Swap(BoolValue* other) { InternalSwap(other); } else { BoolValue temp; - temp.MergeFrom(*this); + temp.UnsafeMergeFrom(*this); CopyFrom(*other); other->CopyFrom(temp); } @@ -2138,11 +2179,11 @@ void BoolValue::InternalSwap(BoolValue* other) { void BoolValue::clear_value() { value_ = false; } - bool BoolValue::value() const { +bool BoolValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.BoolValue.value) return value_; } - void BoolValue::set_value(bool value) { +void BoolValue::set_value(bool value) { value_ = value; // @@protoc_insertion_point(field_set:google.protobuf.BoolValue.value) @@ -2158,35 +2199,35 @@ const int StringValue::kValueFieldNumber; StringValue::StringValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.StringValue) } - StringValue::StringValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.StringValue) } void StringValue::InitAsDefaultInstance() { - _is_default_instance_ = true; } StringValue::StringValue(const StringValue& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue) } void StringValue::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + _cached_size_ = 0; } StringValue::~StringValue() { @@ -2195,13 +2236,12 @@ StringValue::~StringValue() { } void StringValue::SharedDtor() { - if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { return; } - value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - if (this != default_instance_) { - } + value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); } void StringValue::ArenaDtor(void* object) { @@ -2221,11 +2261,11 @@ const ::google::protobuf::Descriptor* StringValue::descriptor() { } const StringValue& StringValue::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + return *internal_default_instance(); } -StringValue* StringValue::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<StringValue> StringValue::default_instance_; StringValue* StringValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<StringValue>(arena); @@ -2318,9 +2358,9 @@ void StringValue::SerializeWithCachedSizes( return target; } -int StringValue::ByteSize() const { +size_t StringValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.StringValue) - int total_size = 0; + size_t total_size = 0; // optional string value = 1; if (this->value().size() > 0) { @@ -2329,18 +2369,17 @@ int StringValue::ByteSize() const { this->value()); } + 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 StringValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.StringValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const StringValue* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const StringValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const StringValue>( &from); if (source == NULL) { @@ -2348,15 +2387,21 @@ void StringValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.StringValue) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void StringValue::MergeFrom(const StringValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.StringValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void StringValue::UnsafeMergeFrom(const StringValue& from) { + GOOGLE_DCHECK(&from != this); if (from.value().size() > 0) { set_value(from.value()); } @@ -2373,7 +2418,7 @@ void StringValue::CopyFrom(const StringValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.StringValue) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool StringValue::IsInitialized() const { @@ -2387,7 +2432,7 @@ void StringValue::Swap(StringValue* other) { InternalSwap(other); } else { StringValue temp; - temp.MergeFrom(*this); + temp.UnsafeMergeFrom(*this); CopyFrom(*other); other->CopyFrom(temp); } @@ -2418,46 +2463,46 @@ void StringValue::InternalSwap(StringValue* other) { void StringValue::clear_value() { value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& StringValue::value() const { +const ::std::string& StringValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.StringValue.value) return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void StringValue::set_value(const ::std::string& value) { +void StringValue::set_value(const ::std::string& value) { value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.StringValue.value) } - void StringValue::set_value(const char* value) { +void StringValue::set_value(const char* value) { value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.StringValue.value) } - void StringValue::set_value(const char* value, +void StringValue::set_value(const char* value, size_t size) { value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.StringValue.value) } - ::std::string* StringValue::mutable_value() { +::std::string* StringValue::mutable_value() { // @@protoc_insertion_point(field_mutable:google.protobuf.StringValue.value) return value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* StringValue::release_value() { +::std::string* StringValue::release_value() { // @@protoc_insertion_point(field_release:google.protobuf.StringValue.value) return value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* StringValue::unsafe_arena_release_value() { +::std::string* StringValue::unsafe_arena_release_value() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.StringValue.value) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - void StringValue::set_allocated_value(::std::string* value) { +void StringValue::set_allocated_value(::std::string* value) { if (value != NULL) { } else { @@ -2467,7 +2512,7 @@ void StringValue::clear_value() { GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value) } - void StringValue::unsafe_arena_set_allocated_value( +void StringValue::unsafe_arena_set_allocated_value( ::std::string* value) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (value != NULL) { @@ -2490,35 +2535,35 @@ const int BytesValue::kValueFieldNumber; BytesValue::BytesValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.BytesValue) } - BytesValue::BytesValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.BytesValue) } void BytesValue::InitAsDefaultInstance() { - _is_default_instance_ = true; } BytesValue::BytesValue(const BytesValue& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue) } void BytesValue::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + _cached_size_ = 0; } BytesValue::~BytesValue() { @@ -2527,13 +2572,12 @@ BytesValue::~BytesValue() { } void BytesValue::SharedDtor() { - if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { return; } - value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - if (this != default_instance_) { - } + value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); } void BytesValue::ArenaDtor(void* object) { @@ -2553,11 +2597,11 @@ const ::google::protobuf::Descriptor* BytesValue::descriptor() { } const BytesValue& BytesValue::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + return *internal_default_instance(); } -BytesValue* BytesValue::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed<BytesValue> BytesValue::default_instance_; BytesValue* BytesValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<BytesValue>(arena); @@ -2638,9 +2682,9 @@ void BytesValue::SerializeWithCachedSizes( return target; } -int BytesValue::ByteSize() const { +size_t BytesValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.BytesValue) - int total_size = 0; + size_t total_size = 0; // optional bytes value = 1; if (this->value().size() > 0) { @@ -2649,18 +2693,17 @@ int BytesValue::ByteSize() const { this->value()); } + 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 BytesValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.BytesValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const BytesValue* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const BytesValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const BytesValue>( &from); if (source == NULL) { @@ -2668,15 +2711,21 @@ void BytesValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.BytesValue) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void BytesValue::MergeFrom(const BytesValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BytesValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void BytesValue::UnsafeMergeFrom(const BytesValue& from) { + GOOGLE_DCHECK(&from != this); if (from.value().size() > 0) { set_value(from.value()); } @@ -2693,7 +2742,7 @@ void BytesValue::CopyFrom(const BytesValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.BytesValue) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool BytesValue::IsInitialized() const { @@ -2707,7 +2756,7 @@ void BytesValue::Swap(BytesValue* other) { InternalSwap(other); } else { BytesValue temp; - temp.MergeFrom(*this); + temp.UnsafeMergeFrom(*this); CopyFrom(*other); other->CopyFrom(temp); } @@ -2738,46 +2787,46 @@ void BytesValue::InternalSwap(BytesValue* other) { void BytesValue::clear_value() { value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& BytesValue::value() const { +const ::std::string& BytesValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value) return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void BytesValue::set_value(const ::std::string& value) { +void BytesValue::set_value(const ::std::string& value) { value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value) } - void BytesValue::set_value(const char* value) { +void BytesValue::set_value(const char* value) { value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.BytesValue.value) } - void BytesValue::set_value(const void* value, +void BytesValue::set_value(const void* value, size_t size) { value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.BytesValue.value) } - ::std::string* BytesValue::mutable_value() { +::std::string* BytesValue::mutable_value() { // @@protoc_insertion_point(field_mutable:google.protobuf.BytesValue.value) return value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* BytesValue::release_value() { +::std::string* BytesValue::release_value() { // @@protoc_insertion_point(field_release:google.protobuf.BytesValue.value) return value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* BytesValue::unsafe_arena_release_value() { +::std::string* BytesValue::unsafe_arena_release_value() { // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.BytesValue.value) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - void BytesValue::set_allocated_value(::std::string* value) { +void BytesValue::set_allocated_value(::std::string* value) { if (value != NULL) { } else { @@ -2787,7 +2836,7 @@ void BytesValue::clear_value() { GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value) } - void BytesValue::unsafe_arena_set_allocated_value( +void BytesValue::unsafe_arena_set_allocated_value( ::std::string* value) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (value != NULL) { diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index 73f8ff62..ee99bc26 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -34,6 +34,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); @@ -68,6 +69,10 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const DoubleValue& default_instance(); + static inline const DoubleValue* internal_default_instance() { + return &default_instance_.get(); + } + void UnsafeArenaSwap(DoubleValue* other); void Swap(DoubleValue* other); @@ -83,7 +88,7 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -99,6 +104,7 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(DoubleValue* other); + void UnsafeMergeFrom(const DoubleValue& from); protected: explicit DoubleValue(::google::protobuf::Arena* arena); private: @@ -132,15 +138,15 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool _is_default_instance_; double value_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); void InitAsDefaultInstance(); - static DoubleValue* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> default_instance_; }; // ------------------------------------------------------------------- @@ -163,6 +169,10 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr static const ::google::protobuf::Descriptor* descriptor(); static const FloatValue& default_instance(); + static inline const FloatValue* internal_default_instance() { + return &default_instance_.get(); + } + void UnsafeArenaSwap(FloatValue* other); void Swap(FloatValue* other); @@ -178,7 +188,7 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -194,6 +204,7 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(FloatValue* other); + void UnsafeMergeFrom(const FloatValue& from); protected: explicit FloatValue(::google::protobuf::Arena* arena); private: @@ -227,15 +238,15 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool _is_default_instance_; float value_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); void InitAsDefaultInstance(); - static FloatValue* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<FloatValue> default_instance_; }; // ------------------------------------------------------------------- @@ -258,6 +269,10 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr static const ::google::protobuf::Descriptor* descriptor(); static const Int64Value& default_instance(); + static inline const Int64Value* internal_default_instance() { + return &default_instance_.get(); + } + void UnsafeArenaSwap(Int64Value* other); void Swap(Int64Value* other); @@ -273,7 +288,7 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -289,6 +304,7 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Int64Value* other); + void UnsafeMergeFrom(const Int64Value& from); protected: explicit Int64Value(::google::protobuf::Arena* arena); private: @@ -322,15 +338,15 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool _is_default_instance_; ::google::protobuf::int64 value_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); void InitAsDefaultInstance(); - static Int64Value* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Int64Value> default_instance_; }; // ------------------------------------------------------------------- @@ -353,6 +369,10 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const UInt64Value& default_instance(); + static inline const UInt64Value* internal_default_instance() { + return &default_instance_.get(); + } + void UnsafeArenaSwap(UInt64Value* other); void Swap(UInt64Value* other); @@ -368,7 +388,7 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -384,6 +404,7 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(UInt64Value* other); + void UnsafeMergeFrom(const UInt64Value& from); protected: explicit UInt64Value(::google::protobuf::Arena* arena); private: @@ -417,15 +438,15 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool _is_default_instance_; ::google::protobuf::uint64 value_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); void InitAsDefaultInstance(); - static UInt64Value* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> default_instance_; }; // ------------------------------------------------------------------- @@ -448,6 +469,10 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr static const ::google::protobuf::Descriptor* descriptor(); static const Int32Value& default_instance(); + static inline const Int32Value* internal_default_instance() { + return &default_instance_.get(); + } + void UnsafeArenaSwap(Int32Value* other); void Swap(Int32Value* other); @@ -463,7 +488,7 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -479,6 +504,7 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Int32Value* other); + void UnsafeMergeFrom(const Int32Value& from); protected: explicit Int32Value(::google::protobuf::Arena* arena); private: @@ -512,15 +538,15 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool _is_default_instance_; ::google::protobuf::int32 value_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); void InitAsDefaultInstance(); - static Int32Value* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<Int32Value> default_instance_; }; // ------------------------------------------------------------------- @@ -543,6 +569,10 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const UInt32Value& default_instance(); + static inline const UInt32Value* internal_default_instance() { + return &default_instance_.get(); + } + void UnsafeArenaSwap(UInt32Value* other); void Swap(UInt32Value* other); @@ -558,7 +588,7 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -574,6 +604,7 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(UInt32Value* other); + void UnsafeMergeFrom(const UInt32Value& from); protected: explicit UInt32Value(::google::protobuf::Arena* arena); private: @@ -607,15 +638,15 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool _is_default_instance_; ::google::protobuf::uint32 value_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); void InitAsDefaultInstance(); - static UInt32Value* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> default_instance_; }; // ------------------------------------------------------------------- @@ -638,6 +669,10 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro static const ::google::protobuf::Descriptor* descriptor(); static const BoolValue& default_instance(); + static inline const BoolValue* internal_default_instance() { + return &default_instance_.get(); + } + void UnsafeArenaSwap(BoolValue* other); void Swap(BoolValue* other); @@ -653,7 +688,7 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -669,6 +704,7 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(BoolValue* other); + void UnsafeMergeFrom(const BoolValue& from); protected: explicit BoolValue(::google::protobuf::Arena* arena); private: @@ -702,15 +738,15 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool _is_default_instance_; bool value_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); void InitAsDefaultInstance(); - static BoolValue* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<BoolValue> default_instance_; }; // ------------------------------------------------------------------- @@ -733,6 +769,10 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const StringValue& default_instance(); + static inline const StringValue* internal_default_instance() { + return &default_instance_.get(); + } + void UnsafeArenaSwap(StringValue* other); void Swap(StringValue* other); @@ -748,7 +788,7 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -764,6 +804,7 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(StringValue* other); + void UnsafeMergeFrom(const StringValue& from); protected: explicit StringValue(::google::protobuf::Arena* arena); private: @@ -805,15 +846,15 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool _is_default_instance_; ::google::protobuf::internal::ArenaStringPtr value_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); void InitAsDefaultInstance(); - static StringValue* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<StringValue> default_instance_; }; // ------------------------------------------------------------------- @@ -836,6 +877,10 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr static const ::google::protobuf::Descriptor* descriptor(); static const BytesValue& default_instance(); + static inline const BytesValue* internal_default_instance() { + return &default_instance_.get(); + } + void UnsafeArenaSwap(BytesValue* other); void Swap(BytesValue* other); @@ -851,7 +896,7 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -867,6 +912,7 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(BytesValue* other); + void UnsafeMergeFrom(const BytesValue& from); protected: explicit BytesValue(::google::protobuf::Arena* arena); private: @@ -908,15 +954,15 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool _is_default_instance_; ::google::protobuf::internal::ArenaStringPtr value_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); void InitAsDefaultInstance(); - static BytesValue* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/wrappers.proto b/src/google/protobuf/wrappers.proto index 4828ad9a..01947639 100644 --- a/src/google/protobuf/wrappers.proto +++ b/src/google/protobuf/wrappers.proto @@ -43,7 +43,6 @@ option go_package = "github.com/golang/protobuf/ptypes/wrappers"; option java_package = "com.google.protobuf"; option java_outer_classname = "WrappersProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; // Wrapper message for `double`. |