diff options
author | Adam Cozzette <acozzette@gmail.com> | 2016-11-23 11:26:31 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-23 11:26:31 -0800 |
commit | 39f9b43219bc5718b659ed72a2130a7b2ce66108 (patch) | |
tree | e48fe16afc2e1d868408e9453fff521d6ddcd4ae /src/google | |
parent | c9504715634948c9f8f306330449f296d926b74e (diff) | |
parent | 65479cb7b1f99ab957da68abce17feb68a9e1cf0 (diff) | |
download | protobuf-39f9b43219bc5718b659ed72a2130a7b2ce66108.tar.gz protobuf-39f9b43219bc5718b659ed72a2130a7b2ce66108.tar.bz2 protobuf-39f9b43219bc5718b659ed72a2130a7b2ce66108.zip |
Merge pull request #2403 from google/down-integrate-with-msvc-fix
Integrated internal changes from Google
Diffstat (limited to 'src/google')
217 files changed, 13197 insertions, 12817 deletions
diff --git a/src/google/protobuf/any.cc b/src/google/protobuf/any.cc index f7b1d310..83edba57 100644 --- a/src/google/protobuf/any.cc +++ b/src/google/protobuf/any.cc @@ -30,6 +30,8 @@ #include <google/protobuf/any.h> +#include <google/protobuf/generated_message_util.h> + namespace google { namespace protobuf { namespace internal { @@ -70,13 +72,11 @@ bool AnyMetadata::UnpackTo(Message* message) const { if (!InternalIs(message->GetDescriptor())) { return false; } - return message->ParseFromString( - value_->GetNoArena(&::google::protobuf::internal::GetEmptyString())); + return message->ParseFromString(value_->GetNoArena()); } bool AnyMetadata::InternalIs(const Descriptor* descriptor) const { - const string type_url = type_url_->GetNoArena( - &::google::protobuf::internal::GetEmptyString()); + const string type_url = type_url_->GetNoArena(); string full_name; if (!ParseAnyTypeUrl(type_url, &full_name)) { return false; diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index 0df8d168..e73ebffd 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -19,86 +19,88 @@ namespace google { namespace protobuf { +class AnyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Any> {}; +AnyDefaultTypeInternal _Any_default_instance_; namespace { -const ::google::protobuf::Descriptor* Any_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Any_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/any.proto"); - GOOGLE_CHECK(file != NULL); - Any_descriptor_ = file->message_type(0); - static const int Any_offsets_[2] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fany_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fany_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, type_url_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, value_), }; - Any_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Any_descriptor_, - Any::internal_default_instance(), - Any_offsets_, - -1, - -1, - -1, - sizeof(Any), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Any)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Any_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/any.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fany_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Any_descriptor_, Any::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto() { - Any_default_instance_.Shutdown(); - delete Any_reflection_; + _Any_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } 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::internal::InitProtobufDefaults(); + _Any_default_instance_.DefaultConstruct(); } -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); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&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(); + static const char descriptor[] = { + "\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(\014Bo\n\023com.google.protobufB\010AnyProtoP\001Z" + "%github.com/golang/protobuf/ptypes/any\242\002" + "\003GPB\252\002\036Google.Protobuf.WellKnownTypesb\006p" + "roto3" + }; ::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(\014Bo\n\023com.google.protobufB\010AnyProtoP\001Z" - "%github.com/golang/protobuf/ptypes/any\242\002" - "\003GPB\252\002\036Google.Protobuf.WellKnownTypesb\006p" - "roto3", 205); + descriptor, 205); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/any.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto); @@ -116,16 +118,6 @@ 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) { @@ -148,20 +140,26 @@ 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(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Any) } - -void Any::InitAsDefaultInstance() { -} - Any::Any(const Any& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL), - _any_metadata_(&type_url_, &value_) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0), + _any_metadata_(&type_url_, &value_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.type_url().size() > 0) { + type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_); + } + value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.value().size() > 0) { + value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value_); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.Any) } @@ -188,7 +186,7 @@ void Any::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Any::descriptor() { protobuf_AssignDescriptorsOnce(); - return Any_descriptor_; + return file_level_metadata[0].descriptor; } const Any& Any::default_instance() { @@ -196,8 +194,6 @@ const Any& Any::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Any> Any_default_instance_; - Any* Any::New(::google::protobuf::Arena* arena) const { Any* n = new Any; if (arena != NULL) { @@ -218,13 +214,13 @@ bool Any::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Any) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string type_url = 1; + // string type_url = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -234,20 +230,17 @@ bool Any::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_value; break; } - // optional bytes value = 2; + // bytes value = 2; case 2: { - if (tag == 18) { - parse_value: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_value())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -275,7 +268,7 @@ failure: void Any::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Any) - // optional string type_url = 1; + // string type_url = 1; if (this->type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->type_url().data(), this->type_url().length(), @@ -285,7 +278,7 @@ void Any::SerializeWithCachedSizes( 1, this->type_url(), output); } - // optional bytes value = 2; + // bytes value = 2; if (this->value().size() > 0) { ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased( 2, this->value(), output); @@ -298,7 +291,7 @@ void Any::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Any) - // optional string type_url = 1; + // string type_url = 1; if (this->type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->type_url().data(), this->type_url().length(), @@ -309,7 +302,7 @@ void Any::SerializeWithCachedSizes( 1, this->type_url(), target); } - // optional bytes value = 2; + // bytes value = 2; if (this->value().size() > 0) { target = ::google::protobuf::internal::WireFormatLite::WriteBytesToArray( @@ -324,14 +317,14 @@ size_t Any::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Any) size_t total_size = 0; - // optional string type_url = 1; + // string type_url = 1; if (this->type_url().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->type_url()); } - // optional bytes value = 2; + // bytes value = 2; if (this->value().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::BytesSize( @@ -347,7 +340,7 @@ size_t Any::ByteSizeLong() const { void Any::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Any) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Any* source = ::google::protobuf::internal::DynamicCastToGenerated<const Any>( &from); @@ -356,21 +349,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Any::MergeFrom(const Any& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Any::UnsafeMergeFrom(const Any& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.type_url().size() > 0) { type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_); @@ -392,11 +378,10 @@ void Any::CopyFrom(const Any& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Any) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Any::IsInitialized() const { - return true; } @@ -407,28 +392,24 @@ void Any::Swap(Any* other) { void Any::InternalSwap(Any* other) { type_url_.Swap(&other->type_url_); value_.Swap(&other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Any::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Any_descriptor_; - metadata.reflection = Any_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Any -// optional string type_url = 1; +// string type_url = 1; void Any::clear_type_url() { type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } 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()); + return type_url_.GetNoArena(); } void Any::set_type_url(const ::std::string& value) { @@ -466,13 +447,13 @@ void Any::set_allocated_type_url(::std::string* type_url) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url) } -// optional bytes value = 2; +// bytes value = 2; void Any::clear_value() { value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Any::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.value) - return value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return value_.GetNoArena(); } void Any::set_value(const ::std::string& value) { @@ -510,9 +491,6 @@ void Any::set_allocated_value(::std::string* value) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value) } -inline const Any* Any::internal_default_instance() { - return &Any_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 0641e244..482db72f 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -24,11 +24,18 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/any.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class Any; +class AnyDefaultTypeInternal; +extern AnyDefaultTypeInternal _Any_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -36,10 +43,6 @@ 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(); - -class Any; // =================================================================== @@ -58,7 +61,10 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in static const ::google::protobuf::Descriptor* descriptor(); static const Any& default_instance(); - static const Any* internal_default_instance(); + static inline const Any* internal_default_instance() { + return reinterpret_cast<const Any*>( + &_Any_default_instance_); + } // implements Any ----------------------------------------------- @@ -74,49 +80,49 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in // implements Message ---------------------------------------------- - inline Any* New() const { return New(NULL); } + inline Any* New() const PROTOBUF_FINAL { return New(NULL); } - Any* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Any* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Any& from); void MergeFrom(const Any& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Any* other); - void UnsafeMergeFrom(const Any& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string type_url = 1; + // string type_url = 1; void clear_type_url(); static const int kTypeUrlFieldNumber = 1; const ::std::string& type_url() const; @@ -127,7 +133,7 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in ::std::string* release_type_url(); void set_allocated_type_url(::std::string* type_url); - // optional bytes value = 2; + // bytes value = 2; void clear_value(); static const int kValueFieldNumber = 2; const ::std::string& value() const; @@ -148,13 +154,10 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in ::google::protobuf::internal::AnyMetadata _any_metadata_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fany_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Any> Any_default_instance_; - // =================================================================== @@ -163,13 +166,13 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Any> Any_default_inst #if !PROTOBUF_INLINE_NOT_IN_HEADERS // Any -// optional string type_url = 1; +// string type_url = 1; inline void Any::clear_type_url() { type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline 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()); + return type_url_.GetNoArena(); } inline void Any::set_type_url(const ::std::string& value) { @@ -207,13 +210,13 @@ inline void Any::set_allocated_type_url(::std::string* type_url) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url) } -// optional bytes value = 2; +// bytes value = 2; inline void Any::clear_value() { value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Any::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.value) - return value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return value_.GetNoArena(); } inline void Any::set_value(const ::std::string& value) { @@ -251,13 +254,11 @@ inline void Any::set_allocated_value(::std::string* value) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value) } -inline const Any* Any::internal_default_instance() { - return &Any_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index 35139faf..2bc6153a 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -19,31 +19,27 @@ namespace google { namespace protobuf { +class ApiDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Api> {}; +ApiDefaultTypeInternal _Api_default_instance_; +class MethodDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Method> {}; +MethodDefaultTypeInternal _Method_default_instance_; +class MixinDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Mixin> {}; +MixinDefaultTypeInternal _Mixin_default_instance_; namespace { -const ::google::protobuf::Descriptor* Api_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Api_reflection_ = NULL; -const ::google::protobuf::Descriptor* Method_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Method_reflection_ = NULL; -const ::google::protobuf::Descriptor* Mixin_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Mixin_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[3]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/api.proto"); - GOOGLE_CHECK(file != NULL); - Api_descriptor_ = file->message_type(0); - static const int Api_offsets_[7] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, methods_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, options_), @@ -51,19 +47,10 @@ void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, source_context_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, mixins_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, syntax_), - }; - Api_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Api_descriptor_, - Api::internal_default_instance(), - Api_offsets_, - -1, - -1, - -1, - sizeof(Api), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_)); - Method_descriptor_ = file->message_type(1); - static const int Method_offsets_[7] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_type_url_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_streaming_), @@ -71,62 +58,58 @@ void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_streaming_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, syntax_), - }; - Method_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Method_descriptor_, - Method::internal_default_instance(), - Method_offsets_, - -1, - -1, - -1, - sizeof(Method), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_)); - Mixin_descriptor_ = file->message_type(2); - static const int Mixin_offsets_[2] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, root_), }; - Mixin_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Mixin_descriptor_, - Mixin::internal_default_instance(), - Mixin_offsets_, - -1, - -1, - -1, - sizeof(Mixin), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Api)}, + { 11, -1, sizeof(Method)}, + { 22, -1, sizeof(Mixin)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Api_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Method_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Mixin_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/api.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fapi_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Api_descriptor_, Api::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Method_descriptor_, Method::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Mixin_descriptor_, Mixin::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 3); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto() { - Api_default_instance_.Shutdown(); - delete Api_reflection_; - Method_default_instance_.Shutdown(); - delete Method_reflection_; - Mixin_default_instance_.Shutdown(); - delete Mixin_reflection_; + _Api_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; + _Method_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; + _Mixin_default_instance_.Shutdown(); + delete file_level_metadata[2].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl() { @@ -134,45 +117,43 @@ void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl() { ::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_); + ::google::protobuf::internal::InitProtobufDefaults(); + _Api_default_instance_.DefaultConstruct(); + _Method_default_instance_.DefaultConstruct(); + _Mixin_default_instance_.DefaultConstruct(); + _Api_default_instance_.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); +} + void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&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(); + static const char descriptor[] = { + "\n\031google/protobuf/api.proto\022\017google.prot" + "obuf\032$google/protobuf/source_context.pro" + "to\032\032google/protobuf/type.proto\"\201\002\n\003Api\022\014" + "\n\004name\030\001 \001(\t\022(\n\007methods\030\002 \003(\0132\027.google.p" + "rotobuf.Method\022(\n\007options\030\003 \003(\0132\027.google" + ".protobuf.Option\022\017\n\007version\030\004 \001(\t\0226\n\016sou" + "rce_context\030\005 \001(\0132\036.google.protobuf.Sour" + "ceContext\022&\n\006mixins\030\006 \003(\0132\026.google.proto" + "buf.Mixin\022\'\n\006syntax\030\007 \001(\0162\027.google.proto" + "buf.Syntax\"\325\001\n\006Method\022\014\n\004name\030\001 \001(\t\022\030\n\020r" + "equest_type_url\030\002 \001(\t\022\031\n\021request_streami" + "ng\030\003 \001(\010\022\031\n\021response_type_url\030\004 \001(\t\022\032\n\022r" + "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(\tBu\n\023com.google.pr" + "otobufB\010ApiProtoP\001Z+google.golang.org/ge" + "nproto/protobuf/api;api\242\002\003GPB\252\002\036Google.P" + "rotobuf.WellKnownTypesb\006proto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\031google/protobuf/api.proto\022\017google.prot" - "obuf\032$google/protobuf/source_context.pro" - "to\032\032google/protobuf/type.proto\"\201\002\n\003Api\022\014" - "\n\004name\030\001 \001(\t\022(\n\007methods\030\002 \003(\0132\027.google.p" - "rotobuf.Method\022(\n\007options\030\003 \003(\0132\027.google" - ".protobuf.Option\022\017\n\007version\030\004 \001(\t\0226\n\016sou" - "rce_context\030\005 \001(\0132\036.google.protobuf.Sour" - "ceContext\022&\n\006mixins\030\006 \003(\0132\026.google.proto" - "buf.Mixin\022\'\n\006syntax\030\007 \001(\0162\027.google.proto" - "buf.Syntax\"\325\001\n\006Method\022\014\n\004name\030\001 \001(\t\022\030\n\020r" - "equest_type_url\030\002 \001(\t\022\031\n\021request_streami" - "ng\030\003 \001(\010\022\031\n\021response_type_url\030\004 \001(\t\022\032\n\022r" - "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(\tBH\n\023com.google.pr" - "otobufB\010ApiProtoP\001\242\002\003GPB\252\002\036Google.Protob" - "uf.WellKnownTypesb\006proto3", 705); + descriptor, 750); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/api.proto", &protobuf_RegisterTypes); ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); @@ -192,16 +173,6 @@ 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 @@ -216,29 +187,42 @@ const int Api::kSyntaxFieldNumber; Api::Api() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Api) } - -void Api::InitAsDefaultInstance() { - 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(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + methods_(from.methods_), + options_(from.options_), + mixins_(from.mixins_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + version_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.version().size() > 0) { + version_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.version_); + } + if (from.has_source_context()) { + source_context_ = new ::google::protobuf::SourceContext(*from.source_context_); + } else { + source_context_ = NULL; + } + syntax_ = from.syntax_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Api) } void Api::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); version_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - source_context_ = NULL; - syntax_ = 0; + ::memset(&source_context_, 0, reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&source_context_) + sizeof(syntax_)); _cached_size_ = 0; } @@ -250,7 +234,7 @@ Api::~Api() { void Api::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); version_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &Api_default_instance_.get()) { + if (this != internal_default_instance()) { delete source_context_; } } @@ -262,7 +246,7 @@ void Api::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Api::descriptor() { protobuf_AssignDescriptorsOnce(); - return Api_descriptor_; + return file_level_metadata[0].descriptor; } const Api& Api::default_instance() { @@ -270,8 +254,6 @@ const Api& Api::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Api> Api_default_instance_; - Api* Api::New(::google::protobuf::Arena* arena) const { Api* n = new Api; if (arena != NULL) { @@ -282,14 +264,16 @@ Api* Api::New(::google::protobuf::Arena* arena) const { void Api::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Api) + methods_.Clear(); + options_.Clear(); + mixins_.Clear(); name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; + if (GetArenaNoVirtual() == NULL && source_context_ != NULL) { + delete source_context_; + } source_context_ = NULL; syntax_ = 0; - methods_.Clear(); - options_.Clear(); - mixins_.Clear(); } bool Api::MergePartialFromCodedStream( @@ -298,13 +282,13 @@ bool Api::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Api) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -314,47 +298,38 @@ bool Api::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_methods; break; } // repeated .google.protobuf.Method methods = 2; case 2: { - if (tag == 18) { - parse_methods: + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_methods: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_methods())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_methods; - if (input->ExpectTag(26)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.Option options = 3; case 3: { - if (tag == 26) { + if (tag == 26u) { DO_(input->IncrementRecursionDepth()); - parse_loop_options: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(34)) goto parse_version; break; } - // optional string version = 4; + // string version = 4; case 4: { - if (tag == 34) { - parse_version: + if (tag == 34u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_version())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -364,44 +339,36 @@ bool Api::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(42)) goto parse_source_context; break; } - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; case 5: { - if (tag == 42) { - parse_source_context: + if (tag == 42u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_source_context())); } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_mixins; break; } // repeated .google.protobuf.Mixin mixins = 6; case 6: { - if (tag == 50) { - parse_mixins: + if (tag == 50u) { DO_(input->IncrementRecursionDepth()); - parse_loop_mixins: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_mixins())); } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_loop_mixins; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(56)) goto parse_syntax; break; } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; case 7: { - if (tag == 56) { - parse_syntax: + if (tag == 56u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -410,7 +377,6 @@ bool Api::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -438,7 +404,7 @@ failure: void Api::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Api) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -460,7 +426,7 @@ void Api::SerializeWithCachedSizes( 3, this->options(i), output); } - // optional string version = 4; + // string version = 4; if (this->version().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->version().data(), this->version().length(), @@ -470,7 +436,7 @@ void Api::SerializeWithCachedSizes( 4, this->version(), output); } - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 5, *this->source_context_, output); @@ -482,7 +448,7 @@ void Api::SerializeWithCachedSizes( 6, this->mixins(i), output); } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; if (this->syntax() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 7, this->syntax(), output); @@ -495,7 +461,7 @@ void Api::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Api) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -520,7 +486,7 @@ void Api::SerializeWithCachedSizes( 3, this->options(i), false, target); } - // optional string version = 4; + // string version = 4; if (this->version().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->version().data(), this->version().length(), @@ -531,7 +497,7 @@ void Api::SerializeWithCachedSizes( 4, this->version(), target); } - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( @@ -545,7 +511,7 @@ void Api::SerializeWithCachedSizes( 6, this->mixins(i), false, target); } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; if (this->syntax() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 7, this->syntax(), target); @@ -559,33 +525,6 @@ size_t Api::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Api) size_t total_size = 0; - // optional string name = 1; - if (this->name().size() > 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional string version = 4; - if (this->version().size() > 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->version()); - } - - // optional .google.protobuf.SourceContext source_context = 5; - if (this->has_source_context()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->source_context_); - } - - // optional .google.protobuf.Syntax syntax = 7; - if (this->syntax() != 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); - } - // repeated .google.protobuf.Method methods = 2; { unsigned int count = this->methods_size(); @@ -619,6 +558,33 @@ size_t Api::ByteSizeLong() const { } } + // string name = 1; + if (this->name().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + // string version = 4; + if (this->version().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->version()); + } + + // .google.protobuf.SourceContext source_context = 5; + if (this->has_source_context()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->source_context_); + } + + // .google.protobuf.Syntax syntax = 7; + if (this->syntax() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); + } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -628,7 +594,7 @@ size_t Api::ByteSizeLong() const { void Api::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Api) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Api* source = ::google::protobuf::internal::DynamicCastToGenerated<const Api>( &from); @@ -637,21 +603,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Api::MergeFrom(const Api& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Api) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Api::UnsafeMergeFrom(const Api& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); methods_.MergeFrom(from.methods_); options_.MergeFrom(from.options_); mixins_.MergeFrom(from.mixins_); @@ -682,11 +641,10 @@ void Api::CopyFrom(const Api& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Api) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Api::IsInitialized() const { - return true; } @@ -695,35 +653,31 @@ void Api::Swap(Api* other) { InternalSwap(other); } void Api::InternalSwap(Api* other) { - name_.Swap(&other->name_); methods_.UnsafeArenaSwap(&other->methods_); options_.UnsafeArenaSwap(&other->options_); + mixins_.UnsafeArenaSwap(&other->mixins_); + name_.Swap(&other->name_); version_.Swap(&other->version_); std::swap(source_context_, other->source_context_); - mixins_.UnsafeArenaSwap(&other->mixins_); std::swap(syntax_, other->syntax_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Api::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Api_descriptor_; - metadata.reflection = Api_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Api -// optional string name = 1; +// string name = 1; void Api::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Api::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void Api::set_name(const ::std::string& value) { @@ -821,13 +775,13 @@ Api::options() const { return options_; } -// optional string version = 4; +// string version = 4; void Api::clear_version() { version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Api::version() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.version) - return version_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return version_.GetNoArena(); } void Api::set_version(const ::std::string& value) { @@ -865,7 +819,7 @@ void Api::set_allocated_version(::std::string* version) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version) } -// optional .google.protobuf.SourceContext source_context = 5; +// .google.protobuf.SourceContext source_context = 5; bool Api::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } @@ -934,7 +888,7 @@ Api::mixins() const { return mixins_; } -// optional .google.protobuf.Syntax syntax = 7; +// .google.protobuf.Syntax syntax = 7; void Api::clear_syntax() { syntax_ = 0; } @@ -948,9 +902,6 @@ void Api::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Api.syntax) } -inline const Api* Api::internal_default_instance() { - return &Api_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -967,19 +918,33 @@ const int Method::kSyntaxFieldNumber; Method::Method() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Method) } - -void Method::InitAsDefaultInstance() { -} - Method::Method(const Method& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + options_(from.options_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + request_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.request_type_url().size() > 0) { + request_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.request_type_url_); + } + response_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.response_type_url().size() > 0) { + response_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.response_type_url_); + } + ::memcpy(&request_streaming_, &from.request_streaming_, + reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&request_streaming_) + sizeof(syntax_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Method) } @@ -1010,7 +975,7 @@ void Method::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Method::descriptor() { protobuf_AssignDescriptorsOnce(); - return Method_descriptor_; + return file_level_metadata[1].descriptor; } const Method& Method::default_instance() { @@ -1018,8 +983,6 @@ const Method& Method::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Method> Method_default_instance_; - Method* Method::New(::google::protobuf::Arena* arena) const { Method* n = new Method; if (arena != NULL) { @@ -1030,31 +993,12 @@ Method* Method::New(::google::protobuf::Arena* arena) const { void Method::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Method) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(Method, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<Method*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(request_streaming_, syntax_); + options_.Clear(); name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - -#undef ZR_HELPER_ -#undef ZR_ - - options_.Clear(); + ::memset(&request_streaming_, 0, reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&request_streaming_) + sizeof(syntax_)); } bool Method::MergePartialFromCodedStream( @@ -1063,13 +1007,13 @@ bool Method::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Method) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1079,14 +1023,12 @@ bool Method::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_request_type_url; break; } - // optional string request_type_url = 2; + // string request_type_url = 2; case 2: { - if (tag == 18) { - parse_request_type_url: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_request_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1096,14 +1038,12 @@ bool Method::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_request_streaming; break; } - // optional bool request_streaming = 3; + // bool request_streaming = 3; case 3: { - if (tag == 24) { - parse_request_streaming: + if (tag == 24u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1111,14 +1051,12 @@ bool Method::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_response_type_url; break; } - // optional string response_type_url = 4; + // string response_type_url = 4; case 4: { - if (tag == 34) { - parse_response_type_url: + if (tag == 34u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_response_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1128,14 +1066,12 @@ bool Method::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(40)) goto parse_response_streaming; break; } - // optional bool response_streaming = 5; + // bool response_streaming = 5; case 5: { - if (tag == 40) { - parse_response_streaming: + if (tag == 40u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1143,31 +1079,25 @@ bool Method::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_options; break; } // repeated .google.protobuf.Option options = 6; case 6: { - if (tag == 50) { - parse_options: + if (tag == 50u) { DO_(input->IncrementRecursionDepth()); - parse_loop_options: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(56)) goto parse_syntax; break; } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; case 7: { - if (tag == 56) { - parse_syntax: + if (tag == 56u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1176,7 +1106,6 @@ bool Method::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1204,7 +1133,7 @@ failure: void Method::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Method) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -1214,7 +1143,7 @@ void Method::SerializeWithCachedSizes( 1, this->name(), output); } - // optional string request_type_url = 2; + // string request_type_url = 2; if (this->request_type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->request_type_url().data(), this->request_type_url().length(), @@ -1224,12 +1153,12 @@ void Method::SerializeWithCachedSizes( 2, this->request_type_url(), output); } - // optional bool request_streaming = 3; + // bool request_streaming = 3; if (this->request_streaming() != 0) { ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->request_streaming(), output); } - // optional string response_type_url = 4; + // string response_type_url = 4; if (this->response_type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->response_type_url().data(), this->response_type_url().length(), @@ -1239,7 +1168,7 @@ void Method::SerializeWithCachedSizes( 4, this->response_type_url(), output); } - // optional bool response_streaming = 5; + // bool response_streaming = 5; if (this->response_streaming() != 0) { ::google::protobuf::internal::WireFormatLite::WriteBool(5, this->response_streaming(), output); } @@ -1250,7 +1179,7 @@ void Method::SerializeWithCachedSizes( 6, this->options(i), output); } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; if (this->syntax() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 7, this->syntax(), output); @@ -1263,7 +1192,7 @@ void Method::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Method) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -1274,7 +1203,7 @@ void Method::SerializeWithCachedSizes( 1, this->name(), target); } - // optional string request_type_url = 2; + // string request_type_url = 2; if (this->request_type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->request_type_url().data(), this->request_type_url().length(), @@ -1285,12 +1214,12 @@ void Method::SerializeWithCachedSizes( 2, this->request_type_url(), target); } - // optional bool request_streaming = 3; + // bool request_streaming = 3; if (this->request_streaming() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->request_streaming(), target); } - // optional string response_type_url = 4; + // string response_type_url = 4; if (this->response_type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->response_type_url().data(), this->response_type_url().length(), @@ -1301,7 +1230,7 @@ void Method::SerializeWithCachedSizes( 4, this->response_type_url(), target); } - // optional bool response_streaming = 5; + // bool response_streaming = 5; if (this->response_streaming() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->response_streaming(), target); } @@ -1313,7 +1242,7 @@ void Method::SerializeWithCachedSizes( 6, this->options(i), false, target); } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; if (this->syntax() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 7, this->syntax(), target); @@ -1327,54 +1256,54 @@ size_t Method::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Method) size_t total_size = 0; - // optional string name = 1; + // repeated .google.protobuf.Option options = 6; + { + 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)); + } + } + + // string name = 1; if (this->name().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->name()); } - // optional string request_type_url = 2; + // string request_type_url = 2; if (this->request_type_url().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->request_type_url()); } - // optional bool request_streaming = 3; - if (this->request_streaming() != 0) { - total_size += 1 + 1; - } - - // optional string response_type_url = 4; + // string response_type_url = 4; if (this->response_type_url().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->response_type_url()); } - // optional bool response_streaming = 5; + // bool request_streaming = 3; + if (this->request_streaming() != 0) { + total_size += 1 + 1; + } + + // bool response_streaming = 5; if (this->response_streaming() != 0) { total_size += 1 + 1; } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; if (this->syntax() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); } - // repeated .google.protobuf.Option options = 6; - { - 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_ = cached_size; @@ -1384,7 +1313,7 @@ size_t Method::ByteSizeLong() const { void Method::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Method) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Method* source = ::google::protobuf::internal::DynamicCastToGenerated<const Method>( &from); @@ -1393,21 +1322,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Method::MergeFrom(const Method& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Method) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Method::UnsafeMergeFrom(const Method& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { @@ -1417,13 +1339,13 @@ void Method::UnsafeMergeFrom(const Method& from) { request_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.request_type_url_); } - if (from.request_streaming() != 0) { - set_request_streaming(from.request_streaming()); - } if (from.response_type_url().size() > 0) { response_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.response_type_url_); } + if (from.request_streaming() != 0) { + set_request_streaming(from.request_streaming()); + } if (from.response_streaming() != 0) { set_response_streaming(from.response_streaming()); } @@ -1443,11 +1365,10 @@ void Method::CopyFrom(const Method& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Method) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Method::IsInitialized() const { - return true; } @@ -1456,35 +1377,31 @@ void Method::Swap(Method* other) { InternalSwap(other); } void Method::InternalSwap(Method* other) { + options_.UnsafeArenaSwap(&other->options_); name_.Swap(&other->name_); request_type_url_.Swap(&other->request_type_url_); - std::swap(request_streaming_, other->request_streaming_); response_type_url_.Swap(&other->response_type_url_); + std::swap(request_streaming_, other->request_streaming_); std::swap(response_streaming_, other->response_streaming_); - options_.UnsafeArenaSwap(&other->options_); std::swap(syntax_, other->syntax_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Method::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Method_descriptor_; - metadata.reflection = Method_reflection_; - return metadata; + return file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Method -// optional string name = 1; +// string name = 1; void Method::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Method::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void Method::set_name(const ::std::string& value) { @@ -1522,13 +1439,13 @@ void Method::set_allocated_name(::std::string* name) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name) } -// optional string request_type_url = 2; +// string request_type_url = 2; void Method::clear_request_type_url() { request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } 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()); + return request_type_url_.GetNoArena(); } void Method::set_request_type_url(const ::std::string& value) { @@ -1566,7 +1483,7 @@ void Method::set_allocated_request_type_url(::std::string* request_type_url) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url) } -// optional bool request_streaming = 3; +// bool request_streaming = 3; void Method::clear_request_streaming() { request_streaming_ = false; } @@ -1580,13 +1497,13 @@ void Method::set_request_streaming(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming) } -// optional string response_type_url = 4; +// string response_type_url = 4; void Method::clear_response_type_url() { response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } 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()); + return response_type_url_.GetNoArena(); } void Method::set_response_type_url(const ::std::string& value) { @@ -1624,7 +1541,7 @@ void Method::set_allocated_response_type_url(::std::string* response_type_url) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url) } -// optional bool response_streaming = 5; +// bool response_streaming = 5; void Method::clear_response_streaming() { response_streaming_ = false; } @@ -1668,7 +1585,7 @@ Method::options() const { return options_; } -// optional .google.protobuf.Syntax syntax = 7; +// .google.protobuf.Syntax syntax = 7; void Method::clear_syntax() { syntax_ = 0; } @@ -1682,9 +1599,6 @@ void Method::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Method.syntax) } -inline const Method* Method::internal_default_instance() { - return &Method_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1696,19 +1610,25 @@ const int Mixin::kRootFieldNumber; Mixin::Mixin() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Mixin) } - -void Mixin::InitAsDefaultInstance() { -} - Mixin::Mixin(const Mixin& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + root_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.root().size() > 0) { + root_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.root_); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin) } @@ -1735,7 +1655,7 @@ void Mixin::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Mixin::descriptor() { protobuf_AssignDescriptorsOnce(); - return Mixin_descriptor_; + return file_level_metadata[2].descriptor; } const Mixin& Mixin::default_instance() { @@ -1743,8 +1663,6 @@ const Mixin& Mixin::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Mixin> Mixin_default_instance_; - Mixin* Mixin::New(::google::protobuf::Arena* arena) const { Mixin* n = new Mixin; if (arena != NULL) { @@ -1765,13 +1683,13 @@ bool Mixin::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Mixin) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1781,14 +1699,12 @@ bool Mixin::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_root; break; } - // optional string root = 2; + // string root = 2; case 2: { - if (tag == 18) { - parse_root: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_root())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1798,7 +1714,6 @@ bool Mixin::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1826,7 +1741,7 @@ failure: void Mixin::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Mixin) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -1836,7 +1751,7 @@ void Mixin::SerializeWithCachedSizes( 1, this->name(), output); } - // optional string root = 2; + // string root = 2; if (this->root().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->root().data(), this->root().length(), @@ -1853,7 +1768,7 @@ void Mixin::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Mixin) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -1864,7 +1779,7 @@ void Mixin::SerializeWithCachedSizes( 1, this->name(), target); } - // optional string root = 2; + // string root = 2; if (this->root().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->root().data(), this->root().length(), @@ -1883,14 +1798,14 @@ size_t Mixin::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Mixin) size_t total_size = 0; - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->name()); } - // optional string root = 2; + // string root = 2; if (this->root().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( @@ -1906,7 +1821,7 @@ size_t Mixin::ByteSizeLong() const { void Mixin::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Mixin) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Mixin* source = ::google::protobuf::internal::DynamicCastToGenerated<const Mixin>( &from); @@ -1915,21 +1830,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Mixin::MergeFrom(const Mixin& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Mixin) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Mixin::UnsafeMergeFrom(const Mixin& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.name().size() > 0) { name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -1951,11 +1859,10 @@ void Mixin::CopyFrom(const Mixin& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Mixin) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Mixin::IsInitialized() const { - return true; } @@ -1966,28 +1873,24 @@ void Mixin::Swap(Mixin* other) { void Mixin::InternalSwap(Mixin* other) { name_.Swap(&other->name_); root_.Swap(&other->root_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Mixin::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Mixin_descriptor_; - metadata.reflection = Mixin_reflection_; - return metadata; + return file_level_metadata[2]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Mixin -// optional string name = 1; +// string name = 1; void Mixin::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Mixin::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void Mixin::set_name(const ::std::string& value) { @@ -2025,13 +1928,13 @@ void Mixin::set_allocated_name(::std::string* name) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name) } -// optional string root = 2; +// string root = 2; void Mixin::clear_root() { root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Mixin::root() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root) - return root_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return root_.GetNoArena(); } void Mixin::set_root(const ::std::string& value) { @@ -2069,9 +1972,6 @@ void Mixin::set_allocated_root(::std::string* root) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root) } -inline const Mixin* Mixin::internal_default_instance() { - return &Mixin_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 94102863..255eb4e3 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -24,12 +24,43 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/source_context.pb.h> #include <google/protobuf/type.pb.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class Api; +class ApiDefaultTypeInternal; +extern ApiDefaultTypeInternal _Api_default_instance_; +class Enum; +class EnumDefaultTypeInternal; +extern EnumDefaultTypeInternal _Enum_default_instance_; +class EnumValue; +class EnumValueDefaultTypeInternal; +extern EnumValueDefaultTypeInternal _EnumValue_default_instance_; +class Field; +class FieldDefaultTypeInternal; +extern FieldDefaultTypeInternal _Field_default_instance_; +class Method; +class MethodDefaultTypeInternal; +extern MethodDefaultTypeInternal _Method_default_instance_; +class Mixin; +class MixinDefaultTypeInternal; +extern MixinDefaultTypeInternal _Mixin_default_instance_; +class Option; +class OptionDefaultTypeInternal; +extern OptionDefaultTypeInternal _Option_default_instance_; +class SourceContext; +class SourceContextDefaultTypeInternal; +extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; +class Type; +class TypeDefaultTypeInternal; +extern TypeDefaultTypeInternal _Type_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -37,12 +68,6 @@ 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(); - -class Api; -class Method; -class Mixin; // =================================================================== @@ -61,55 +86,58 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in static const ::google::protobuf::Descriptor* descriptor(); static const Api& default_instance(); - static const Api* internal_default_instance(); + static inline const Api* internal_default_instance() { + return reinterpret_cast<const Api*>( + &_Api_default_instance_); + } void Swap(Api* other); // implements Message ---------------------------------------------- - inline Api* New() const { return New(NULL); } + inline Api* New() const PROTOBUF_FINAL { return New(NULL); } - Api* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Api* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Api& from); void MergeFrom(const Api& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Api* other); - void UnsafeMergeFrom(const Api& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -144,7 +172,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; - // optional string version = 4; + // string version = 4; void clear_version(); static const int kVersionFieldNumber = 4; const ::std::string& version() const; @@ -155,7 +183,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in ::std::string* release_version(); void set_allocated_version(::std::string* version); - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; bool has_source_context() const; void clear_source_context(); static const int kSourceContextFieldNumber = 5; @@ -176,7 +204,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >& mixins() const; - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; void clear_syntax(); static const int kSyntaxFieldNumber = 7; ::google::protobuf::Syntax syntax() const; @@ -196,13 +224,10 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Api> Api_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ { @@ -220,55 +245,58 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc static const ::google::protobuf::Descriptor* descriptor(); static const Method& default_instance(); - static const Method* internal_default_instance(); + static inline const Method* internal_default_instance() { + return reinterpret_cast<const Method*>( + &_Method_default_instance_); + } void Swap(Method* other); // implements Message ---------------------------------------------- - inline Method* New() const { return New(NULL); } + inline Method* New() const PROTOBUF_FINAL { return New(NULL); } - Method* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Method* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Method& from); void MergeFrom(const Method& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Method* other); - void UnsafeMergeFrom(const Method& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -279,7 +307,7 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc ::std::string* release_name(); void set_allocated_name(::std::string* name); - // optional string request_type_url = 2; + // string request_type_url = 2; void clear_request_type_url(); static const int kRequestTypeUrlFieldNumber = 2; const ::std::string& request_type_url() const; @@ -290,13 +318,13 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc ::std::string* release_request_type_url(); void set_allocated_request_type_url(::std::string* request_type_url); - // optional bool request_streaming = 3; + // bool request_streaming = 3; void clear_request_streaming(); static const int kRequestStreamingFieldNumber = 3; bool request_streaming() const; void set_request_streaming(bool value); - // optional string response_type_url = 4; + // string response_type_url = 4; void clear_response_type_url(); static const int kResponseTypeUrlFieldNumber = 4; const ::std::string& response_type_url() const; @@ -307,7 +335,7 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc ::std::string* release_response_type_url(); void set_allocated_response_type_url(::std::string* response_type_url); - // optional bool response_streaming = 5; + // bool response_streaming = 5; void clear_response_streaming(); static const int kResponseStreamingFieldNumber = 5; bool response_streaming() const; @@ -325,7 +353,7 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; void clear_syntax(); static const int kSyntaxFieldNumber = 7; ::google::protobuf::Syntax syntax() const; @@ -345,13 +373,10 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Method> Method_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ { @@ -369,55 +394,58 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ static const ::google::protobuf::Descriptor* descriptor(); static const Mixin& default_instance(); - static const Mixin* internal_default_instance(); + static inline const Mixin* internal_default_instance() { + return reinterpret_cast<const Mixin*>( + &_Mixin_default_instance_); + } void Swap(Mixin* other); // implements Message ---------------------------------------------- - inline Mixin* New() const { return New(NULL); } + inline Mixin* New() const PROTOBUF_FINAL { return New(NULL); } - Mixin* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Mixin* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Mixin& from); void MergeFrom(const Mixin& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Mixin* other); - void UnsafeMergeFrom(const Mixin& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -428,7 +456,7 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ ::std::string* release_name(); void set_allocated_name(::std::string* name); - // optional string root = 2; + // string root = 2; void clear_root(); static const int kRootFieldNumber = 2; const ::std::string& root() const; @@ -448,13 +476,10 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Mixin> Mixin_default_instance_; - // =================================================================== @@ -463,13 +488,13 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Mixin> Mixin_default_ #if !PROTOBUF_INLINE_NOT_IN_HEADERS // Api -// optional string name = 1; +// string name = 1; inline void Api::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Api::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void Api::set_name(const ::std::string& value) { @@ -567,13 +592,13 @@ Api::options() const { return options_; } -// optional string version = 4; +// string version = 4; inline void Api::clear_version() { version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Api::version() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.version) - return version_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return version_.GetNoArena(); } inline void Api::set_version(const ::std::string& value) { @@ -611,7 +636,7 @@ inline void Api::set_allocated_version(::std::string* version) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version) } -// optional .google.protobuf.SourceContext source_context = 5; +// .google.protobuf.SourceContext source_context = 5; inline bool Api::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } @@ -680,7 +705,7 @@ Api::mixins() const { return mixins_; } -// optional .google.protobuf.Syntax syntax = 7; +// .google.protobuf.Syntax syntax = 7; inline void Api::clear_syntax() { syntax_ = 0; } @@ -694,20 +719,17 @@ inline void Api::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Api.syntax) } -inline const Api* Api::internal_default_instance() { - return &Api_default_instance_.get(); -} // ------------------------------------------------------------------- // Method -// optional string name = 1; +// string name = 1; inline void Method::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Method::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void Method::set_name(const ::std::string& value) { @@ -745,13 +767,13 @@ inline void Method::set_allocated_name(::std::string* name) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name) } -// optional string request_type_url = 2; +// string request_type_url = 2; inline void Method::clear_request_type_url() { request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline 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()); + return request_type_url_.GetNoArena(); } inline void Method::set_request_type_url(const ::std::string& value) { @@ -789,7 +811,7 @@ inline void Method::set_allocated_request_type_url(::std::string* request_type_u // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url) } -// optional bool request_streaming = 3; +// bool request_streaming = 3; inline void Method::clear_request_streaming() { request_streaming_ = false; } @@ -803,13 +825,13 @@ inline void Method::set_request_streaming(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming) } -// optional string response_type_url = 4; +// string response_type_url = 4; inline void Method::clear_response_type_url() { response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline 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()); + return response_type_url_.GetNoArena(); } inline void Method::set_response_type_url(const ::std::string& value) { @@ -847,7 +869,7 @@ inline void Method::set_allocated_response_type_url(::std::string* response_type // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url) } -// optional bool response_streaming = 5; +// bool response_streaming = 5; inline void Method::clear_response_streaming() { response_streaming_ = false; } @@ -891,7 +913,7 @@ Method::options() const { return options_; } -// optional .google.protobuf.Syntax syntax = 7; +// .google.protobuf.Syntax syntax = 7; inline void Method::clear_syntax() { syntax_ = 0; } @@ -905,20 +927,17 @@ inline void Method::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Method.syntax) } -inline const Method* Method::internal_default_instance() { - return &Method_default_instance_.get(); -} // ------------------------------------------------------------------- // Mixin -// optional string name = 1; +// string name = 1; inline void Mixin::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Mixin::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void Mixin::set_name(const ::std::string& value) { @@ -956,13 +975,13 @@ inline void Mixin::set_allocated_name(::std::string* name) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name) } -// optional string root = 2; +// string root = 2; inline void Mixin::clear_root() { root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Mixin::root() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root) - return root_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return root_.GetNoArena(); } inline void Mixin::set_root(const ::std::string& value) { @@ -1000,9 +1019,6 @@ inline void Mixin::set_allocated_root(::std::string* root) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root) } -inline const Mixin* Mixin::internal_default_instance() { - return &Mixin_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- @@ -1011,6 +1027,7 @@ inline const Mixin* Mixin::internal_default_instance() { // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/api.proto b/src/google/protobuf/api.proto index bbbe9833..7c30e8b7 100644 --- a/src/google/protobuf/api.proto +++ b/src/google/protobuf/api.proto @@ -40,6 +40,7 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "ApiProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; +option go_package = "google.golang.org/genproto/protobuf/api;api"; // Api is a light-weight descriptor for a protocol buffer service. message Api { diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index aa4e587c..21fd1be6 100755 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc @@ -36,7 +36,7 @@ #ifdef ADDRESS_SANITIZER #include <sanitizer/asan_interface.h> -#endif +#endif // ADDRESS_SANITIZER namespace google { namespace protobuf { @@ -141,7 +141,7 @@ Arena::Block* Arena::NewBlock(void* me, Block* my_last_block, size_t n, // malloc but it's not yet usable until we return it as part of an allocation. ASAN_POISON_MEMORY_REGION( reinterpret_cast<char*>(b) + b->pos, b->size - b->pos); -#endif +#endif // ADDRESS_SANITIZER return b; } @@ -205,7 +205,7 @@ void* Arena::AllocFromBlock(Block* b, size_t n) { b->pos = p + n; #ifdef ADDRESS_SANITIZER ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b) + p, n); -#endif +#endif // ADDRESS_SANITIZER return reinterpret_cast<char*>(b) + p; } @@ -244,7 +244,7 @@ uint64 Arena::SpaceUsed() const { return space_used; } -pair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const { +std::pair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const { uint64 allocated = 0; uint64 used = 0; @@ -265,9 +265,19 @@ uint64 Arena::FreeBlocks() { space_allocated += (b->size); Block* next = b->next; if (next != NULL) { +#ifdef ADDRESS_SANITIZER + // This memory was provided by the underlying allocator as unpoisoned, so + // return it in an unpoisoned state. + ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b), b->size); +#endif // ADDRESS_SANITIZER options_.block_dealloc(b, b->size); } else { if (owns_first_block_) { +#ifdef ADDRESS_SANITIZER + // This memory was provided by the underlying allocator as unpoisoned, + // so return it in an unpoisoned state. + ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b), b->size); +#endif // ADDRESS_SANITIZER options_.block_dealloc(b, b->size); } else { // User passed in the first block, skip free'ing the memory. diff --git a/src/google/protobuf/arena_test_util.h b/src/google/protobuf/arena_test_util.h index 690cc706..8c9f7698 100644 --- a/src/google/protobuf/arena_test_util.h +++ b/src/google/protobuf/arena_test_util.h @@ -31,9 +31,40 @@ #ifndef GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__ #define GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__ +#include <google/protobuf/stubs/logging.h> +#include <google/protobuf/stubs/common.h> +#include <google/protobuf/arena.h> namespace google { namespace protobuf { + +template <typename T, bool use_arena> +void TestParseCorruptedString(const T& message) { + int success_count = 0; + string s = message.SerializeAsString(); + const int kMaxIters = 900; + const int stride = s.size() <= kMaxIters ? 1 : s.size() / kMaxIters; + const int start = stride == 1 || use_arena ? 0 : (stride + 1) / 2; + for (int i = start; i < s.size(); i += stride) { + for (int c = 1 + (i % 17); c < 256; c += 2 * c + (i & 3)) { + s[i] ^= c; + google::protobuf::Arena arena; + T* message = + google::protobuf::Arena::CreateMessage<T>(use_arena ? &arena : NULL); + if (message->ParseFromString(s)) { + ++success_count; + } + if (!use_arena) { + delete message; + } + s[i] ^= c; // Restore s to its original state. + } + } + // This next line is a low bar. But getting through the test without crashing + // due to use-after-free or other bugs is a big part of what we're checking. + GOOGLE_CHECK_GT(success_count, 0); +} + namespace internal { class NoHeapChecker { diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc index 35d00463..4f9571db 100644 --- a/src/google/protobuf/arena_unittest.cc +++ b/src/google/protobuf/arena_unittest.cc @@ -249,7 +249,7 @@ TEST(ArenaTest, Parsing) { arena_message->ParseFromString(original.SerializeAsString()); TestUtil::ExpectAllFieldsSet(*arena_message); - // Test that string fields have null terminator bytes (earlier bug). + // Test that string fields have nul terminator bytes (earlier bug). EXPECT_EQ(strlen(original.optional_string().c_str()), strlen(arena_message->optional_string().c_str())); } @@ -1154,6 +1154,13 @@ TEST(ArenaTest, NoHeapAllocationsTest) { arena.Reset(); } +TEST(ArenaTest, ParseCorruptedString) { + TestAllTypes message; + TestUtil::SetAllFields(&message); + TestParseCorruptedString<TestAllTypes, true>(message); + TestParseCorruptedString<TestAllTypes, false>(message); +} + #ifndef GOOGLE_PROTOBUF_NO_RTTI // Test construction on an arena via generic MessageLite interface. We should be // able to successfully deserialize on the arena without incurring heap diff --git a/src/google/protobuf/arenastring.cc b/src/google/protobuf/arenastring.cc index cce61d74..f10732c0 100644 --- a/src/google/protobuf/arenastring.cc +++ b/src/google/protobuf/arenastring.cc @@ -44,7 +44,7 @@ void ArenaStringPtr::AssignWithDefault(const ::std::string* default_value, const ::std::string* other = *value.UnsafeRawStringPointer(); // If the pointers are the same then do nothing. if (me != other) { - SetNoArena(default_value, value.GetNoArena(default_value)); + SetNoArena(default_value, value.GetNoArena()); } } diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index 590ffce9..b60ee379 100755 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -37,7 +37,6 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/fastmem.h> #include <google/protobuf/arena.h> -#include <google/protobuf/generated_message_util.h> @@ -64,9 +63,7 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { } // Basic accessors. - inline const ::std::string& Get(const ::std::string* /* default_value */) const { - return *ptr_; - } + inline const ::std::string& Get() const { return *ptr_; } inline ::std::string* Mutable(const ::std::string* default_value, ::google::protobuf::Arena* arena) { @@ -150,13 +147,12 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { std::swap(ptr_, other->ptr_); } - // Frees storage (if not on an arena) and sets field to default value. + // Frees storage (if not on an arena). inline void Destroy(const ::std::string* default_value, ::google::protobuf::Arena* arena) { if (arena == NULL && ptr_ != default_value) { delete ptr_; } - ptr_ = const_cast< ::std::string* >(default_value); } // Clears content, but keeps allocated string if arena != NULL, to avoid the @@ -216,9 +212,7 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { void AssignWithDefault(const ::std::string* default_value, ArenaStringPtr value); - inline const ::std::string& GetNoArena(const ::std::string* /* default_value */) const { - return *ptr_; - } + inline const ::std::string& GetNoArena() const { return *ptr_; } inline ::std::string* MutableNoArena(const ::std::string* default_value) { if (ptr_ == default_value) { @@ -253,7 +247,6 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { if (ptr_ != default_value) { delete ptr_; } - ptr_ = NULL; } inline void ClearToEmptyNoArena(const ::std::string* default_value) { @@ -281,6 +274,10 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { return &ptr_; } + inline bool IsDefault(const ::std::string* default_value) const { + return ptr_ == default_value; + } + private: ::std::string* ptr_; diff --git a/src/google/protobuf/arenastring_unittest.cc b/src/google/protobuf/arenastring_unittest.cc index ea405d7d..e5afe42d 100644 --- a/src/google/protobuf/arenastring_unittest.cc +++ b/src/google/protobuf/arenastring_unittest.cc @@ -59,11 +59,11 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnHeap) { ArenaStringPtr field; ::std::string default_value = "default"; field.UnsafeSetDefault(&default_value); - EXPECT_EQ(string("default"), field.Get(&default_value)); + EXPECT_EQ(string("default"), field.Get()); field.Set(&default_value, WrapString("Test short"), NULL); - EXPECT_EQ(string("Test short"), field.Get(&default_value)); + EXPECT_EQ(string("Test short"), field.Get()); field.Set(&default_value, WrapString("Test long long long long value"), NULL); - EXPECT_EQ(string("Test long long long long value"), field.Get(&default_value)); + EXPECT_EQ(string("Test long long long long value"), field.Get()); field.Set(&default_value, string(""), NULL); field.Destroy(&default_value, NULL); @@ -71,11 +71,11 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnHeap) { field2.UnsafeSetDefault(&default_value); ::std::string* mut = field2.Mutable(&default_value, NULL); EXPECT_EQ(mut, field2.Mutable(&default_value, NULL)); - EXPECT_EQ(mut, &field2.Get(&default_value)); + EXPECT_EQ(mut, &field2.Get()); EXPECT_NE(&default_value, mut); EXPECT_EQ(string("default"), *mut); *mut = "Test long long long long value"; // ensure string allocates storage - EXPECT_EQ(string("Test long long long long value"), field2.Get(&default_value)); + EXPECT_EQ(string("Test long long long long value"), field2.Get()); field2.Destroy(&default_value, NULL); } @@ -84,12 +84,11 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnArena) { ArenaStringPtr field; ::std::string default_value = "default"; field.UnsafeSetDefault(&default_value); - EXPECT_EQ(string("default"), field.Get(&default_value)); + EXPECT_EQ(string("default"), field.Get()); field.Set(&default_value, WrapString("Test short"), &arena); - EXPECT_EQ(string("Test short"), field.Get(&default_value)); + EXPECT_EQ(string("Test short"), field.Get()); field.Set(&default_value, WrapString("Test long long long long value"), &arena); - EXPECT_EQ(string("Test long long long long value"), - field.Get(&default_value)); + EXPECT_EQ(string("Test long long long long value"), field.Get()); field.Set(&default_value, string(""), &arena); field.Destroy(&default_value, &arena); @@ -97,12 +96,11 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnArena) { field2.UnsafeSetDefault(&default_value); ::std::string* mut = field2.Mutable(&default_value, &arena); EXPECT_EQ(mut, field2.Mutable(&default_value, &arena)); - EXPECT_EQ(mut, &field2.Get(&default_value)); + EXPECT_EQ(mut, &field2.Get()); EXPECT_NE(&default_value, mut); EXPECT_EQ(string("default"), *mut); *mut = "Test long long long long value"; // ensure string allocates storage - EXPECT_EQ(string("Test long long long long value"), - field2.Get(&default_value)); + EXPECT_EQ(string("Test long long long long value"), field2.Get()); field2.Destroy(&default_value, &arena); } diff --git a/src/google/protobuf/compiler/code_generator.cc b/src/google/protobuf/compiler/code_generator.cc index f6ff1e5d..6bf101c3 100644 --- a/src/google/protobuf/compiler/code_generator.cc +++ b/src/google/protobuf/compiler/code_generator.cc @@ -46,7 +46,7 @@ namespace compiler { CodeGenerator::~CodeGenerator() {} bool CodeGenerator::GenerateAll( - const vector<const FileDescriptor*>& files, + const std::vector<const FileDescriptor*>& files, const string& parameter, GeneratorContext* generator_context, string* error) const { @@ -85,18 +85,18 @@ io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert( } void GeneratorContext::ListParsedFiles( - vector<const FileDescriptor*>* output) { + std::vector<const FileDescriptor*>* output) { GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles"; } // Parses a set of comma-delimited name/value pairs. void ParseGeneratorParameter(const string& text, - vector<pair<string, string> >* output) { - vector<string> parts = Split(text, ",", true); + std::vector<std::pair<string, string> >* output) { + std::vector<string> parts = Split(text, ",", true); for (int i = 0; i < parts.size(); i++) { string::size_type equals_pos = parts[i].find_first_of('='); - pair<string, string> value; + std::pair<string, string> value; if (equals_pos == string::npos) { value.first = parts[i]; value.second = ""; diff --git a/src/google/protobuf/compiler/code_generator.h b/src/google/protobuf/compiler/code_generator.h index 642bbfad..b8a5584c 100644 --- a/src/google/protobuf/compiler/code_generator.h +++ b/src/google/protobuf/compiler/code_generator.h @@ -90,7 +90,7 @@ class LIBPROTOC_EXPORT CodeGenerator { // // Returns true if successful. Otherwise, sets *error to a description of // the problem (e.g. "invalid parameter") and returns false. - virtual bool GenerateAll(const vector<const FileDescriptor*>& files, + virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files, const string& parameter, GeneratorContext* generator_context, string* error) const; @@ -141,7 +141,7 @@ class LIBPROTOC_EXPORT GeneratorContext { // Returns a vector of FileDescriptors for all the files being compiled // in this run. Useful for languages, such as Go, that treat files // differently when compiled as a set rather than individually. - virtual void ListParsedFiles(vector<const FileDescriptor*>* output); + virtual void ListParsedFiles(std::vector<const FileDescriptor*>* output); private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext); @@ -158,7 +158,7 @@ typedef GeneratorContext OutputDirectory; // parses to the pairs: // ("foo", "bar"), ("baz", ""), ("qux", "corge") extern void ParseGeneratorParameter(const string&, - vector<pair<string, string> >*); + std::vector<std::pair<string, string> >*); } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 8ab69d02..78ceb68c 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -173,7 +173,8 @@ bool VerifyDirectoryExists(const string& path) { // directories listed in |filename|. bool TryCreateParentDirectory(const string& prefix, const string& filename) { // Recursively create parent directories to the output file. - vector<string> parts = Split(filename, "/", true); + std::vector<string> parts = + Split(filename, "/", true); string path_so_far = prefix; for (int i = 0; i < parts.size() - 1; i++) { path_so_far += parts[i]; @@ -344,7 +345,7 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector, // them all to disk on demand. class CommandLineInterface::GeneratorContextImpl : public GeneratorContext { public: - GeneratorContextImpl(const vector<const FileDescriptor*>& parsed_files); + GeneratorContextImpl(const std::vector<const FileDescriptor*>& parsed_files); ~GeneratorContextImpl(); // Write all files in the directory to disk at the given output location, @@ -360,14 +361,14 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext { void AddJarManifest(); // Get name of all output files. - void GetOutputFilenames(vector<string>* output_filenames); + void GetOutputFilenames(std::vector<string>* output_filenames); // implements GeneratorContext -------------------------------------- io::ZeroCopyOutputStream* Open(const string& filename); io::ZeroCopyOutputStream* OpenForAppend(const string& filename); io::ZeroCopyOutputStream* OpenForInsert( const string& filename, const string& insertion_point); - void ListParsedFiles(vector<const FileDescriptor*>* output) { + void ListParsedFiles(std::vector<const FileDescriptor*>* output) { *output = parsed_files_; } @@ -376,8 +377,8 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext { // map instead of hash_map so that files are written in order (good when // writing zips). - map<string, string*> files_; - const vector<const FileDescriptor*>& parsed_files_; + std::map<string, string*> files_; + const std::vector<const FileDescriptor*>& parsed_files_; bool had_error_; }; @@ -414,7 +415,7 @@ class CommandLineInterface::MemoryOutputStream // ------------------------------------------------------------------- CommandLineInterface::GeneratorContextImpl::GeneratorContextImpl( - const vector<const FileDescriptor*>& parsed_files) + const std::vector<const FileDescriptor*>& parsed_files) : parsed_files_(parsed_files), had_error_(false) { } @@ -433,7 +434,7 @@ bool CommandLineInterface::GeneratorContextImpl::WriteAllToDisk( return false; } - for (map<string, string*>::const_iterator iter = files_.begin(); + for (std::map<string, string*>::const_iterator iter = files_.begin(); iter != files_.end(); ++iter) { const string& relative_filename = iter->first; const char* data = iter->second->data(); @@ -521,7 +522,7 @@ bool CommandLineInterface::GeneratorContextImpl::WriteAllToZip( io::FileOutputStream stream(file_descriptor); ZipWriter zip_writer(&stream); - for (map<string, string*>::const_iterator iter = files_.begin(); + for (std::map<string, string*>::const_iterator iter = files_.begin(); iter != files_.end(); ++iter) { zip_writer.Write(iter->first, *iter->second); } @@ -550,8 +551,8 @@ void CommandLineInterface::GeneratorContextImpl::AddJarManifest() { } void CommandLineInterface::GeneratorContextImpl::GetOutputFilenames( - vector<string>* output_filenames) { - for (map<string, string*>::iterator iter = files_.begin(); + std::vector<string>* output_filenames) { + for (std::map<string, string*>::iterator iter = files_.begin(); iter != files_.end(); ++iter) { output_filenames->push_back(iter->first); } @@ -774,7 +775,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { ErrorPrinter error_collector(error_format_, &source_tree); Importer importer(&source_tree, &error_collector); - vector<const FileDescriptor*> parsed_files; + std::vector<const FileDescriptor*> parsed_files; // Parse each file. for (int i = 0; i < input_files_.size(); i++) { @@ -984,7 +985,7 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { executable_name_ = argv[0]; - vector<string> arguments; + std::vector<string> arguments; for (int i = 1; i < argc; ++i) { arguments.push_back(argv[i]); } @@ -1030,7 +1031,7 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { // Don't use make_pair as the old/default standard library on Solaris // doesn't support it without explicit template parameters, which are // incompatible with C++0x's make_pair. - proto_path_.push_back(pair<string, string>("", ".")); + proto_path_.push_back(std::pair<string, string>("", ".")); } // Check some errror cases. @@ -1153,7 +1154,7 @@ CommandLineInterface::InterpretArgument(const string& name, // Java's -classpath (and some other languages) delimits path components // with colons. Let's accept that syntax too just to make things more // intuitive. - vector<string> parts = Split( + std::vector<string> parts = Split( value, kPathSeparator, true); for (int i = 0; i < parts.size(); i++) { @@ -1190,19 +1191,21 @@ CommandLineInterface::InterpretArgument(const string& name, // Don't use make_pair as the old/default standard library on Solaris // doesn't support it without explicit template parameters, which are // incompatible with C++0x's make_pair. - proto_path_.push_back(pair<string, string>(virtual_path, disk_path)); + proto_path_.push_back(std::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 ':'." << std::endl; + "parameter separated by ':'." + << std::endl; return PARSE_ARGUMENT_FAIL; } direct_dependencies_explicitly_set_ = true; - vector<string> direct = Split(value, ":", true); + std::vector<string> direct = Split( + value, ":", true); GOOGLE_DCHECK(direct_dependencies_.empty()); direct_dependencies_.insert(direct.begin(), direct.end()); @@ -1476,7 +1479,7 @@ void CommandLineInterface::PrintHelpText() { } bool CommandLineInterface::GenerateOutput( - const vector<const FileDescriptor*>& parsed_files, + const std::vector<const FileDescriptor*>& parsed_files, const OutputDirective& output_directive, GeneratorContext* generator_context) { // Call the generator. @@ -1522,12 +1525,12 @@ bool CommandLineInterface::GenerateOutput( } bool CommandLineInterface::GenerateDependencyManifestFile( - const vector<const FileDescriptor*>& parsed_files, + const std::vector<const FileDescriptor*>& parsed_files, const GeneratorContextMap& output_directories, DiskSourceTree* source_tree) { FileDescriptorSet file_set; - set<const FileDescriptor*> already_seen; + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { GetTransitiveDependencies(parsed_files[i], false, @@ -1536,12 +1539,12 @@ bool CommandLineInterface::GenerateDependencyManifestFile( file_set.mutable_file()); } - vector<string> output_filenames; + std::vector<string> output_filenames; for (GeneratorContextMap::const_iterator iter = output_directories.begin(); iter != output_directories.end(); ++iter) { const string& location = iter->first; GeneratorContextImpl* directory = iter->second; - vector<string> relative_output_filenames; + std::vector<string> relative_output_filenames; directory->GetOutputFilenames(&relative_output_filenames); for (int i = 0; i < relative_output_filenames.size(); i++) { string output_filename = location + relative_output_filenames[i]; @@ -1594,7 +1597,7 @@ bool CommandLineInterface::GenerateDependencyManifestFile( } bool CommandLineInterface::GeneratePluginOutput( - const vector<const FileDescriptor*>& parsed_files, + const std::vector<const FileDescriptor*>& parsed_files, const string& plugin_name, const string& parameter, GeneratorContext* generator_context, @@ -1607,7 +1610,7 @@ bool CommandLineInterface::GeneratePluginOutput( request.set_parameter(parameter); } - set<const FileDescriptor*> already_seen; + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { request.add_file_to_generate(parsed_files[i]->name()); GetTransitiveDependencies(parsed_files[i], @@ -1737,11 +1740,11 @@ bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) { } bool CommandLineInterface::WriteDescriptorSet( - const vector<const FileDescriptor*> parsed_files) { + const std::vector<const FileDescriptor*> parsed_files) { FileDescriptorSet file_set; if (imports_in_descriptor_set_) { - set<const FileDescriptor*> already_seen; + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { GetTransitiveDependencies(parsed_files[i], true, // Include json_name @@ -1749,7 +1752,7 @@ bool CommandLineInterface::WriteDescriptorSet( &already_seen, file_set.mutable_file()); } } else { - set<const FileDescriptor*> already_seen; + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { if (!already_seen.insert(parsed_files[i]).second) { continue; @@ -1794,7 +1797,7 @@ void CommandLineInterface::GetTransitiveDependencies( const FileDescriptor* file, bool include_json_name, bool include_source_code_info, - set<const FileDescriptor*>* already_seen, + std::set<const FileDescriptor*>* already_seen, RepeatedPtrField<FileDescriptorProto>* output) { if (!already_seen->insert(file).second) { // Already saw this file. Skip. @@ -1853,11 +1856,11 @@ namespace { // parameter will contain the direct children (when groups are ignored in the // tree) of the given descriptor for the caller to traverse. The declaration // order of the nested messages is also preserved. -typedef pair<int, int> FieldRange; -void GatherOccupiedFieldRanges(const Descriptor* descriptor, - set<FieldRange>* ranges, - vector<const Descriptor*>* nested_messages) { - set<const Descriptor*> groups; +typedef std::pair<int, int> FieldRange; +void GatherOccupiedFieldRanges( + const Descriptor* descriptor, std::set<FieldRange>* ranges, + std::vector<const Descriptor*>* nested_messages) { + std::set<const Descriptor*> groups; for (int i = 0; i < descriptor->field_count(); ++i) { const FieldDescriptor* fd = descriptor->field(i); ranges->insert(FieldRange(fd->number(), fd->number() + 1)); @@ -1889,11 +1892,11 @@ void GatherOccupiedFieldRanges(const Descriptor* descriptor, // Actually prints the formatted free field numbers for given message name and // occupied ranges. void FormatFreeFieldNumbers(const string& name, - const set<FieldRange>& ranges) { + const std::set<FieldRange>& ranges) { string output; StringAppendF(&output, "%-35s free:", name.c_str()); int next_free_number = 1; - for (set<FieldRange>::const_iterator i = ranges.begin(); + for (std::set<FieldRange>::const_iterator i = ranges.begin(); i != ranges.end(); ++i) { // This happens when groups re-use parent field numbers, in which // case we skip the FieldRange entirely. @@ -1920,8 +1923,8 @@ void FormatFreeFieldNumbers(const string& name, void CommandLineInterface::PrintFreeFieldNumbers( const Descriptor* descriptor) { - set<FieldRange> ranges; - vector<const Descriptor*> nested_messages; + std::set<FieldRange> ranges; + std::vector<const Descriptor*> nested_messages; GatherOccupiedFieldRanges(descriptor, &ranges, &nested_messages); for (int i = 0; i < nested_messages.size(); ++i) { diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h index d779fc87..28471ee7 100644 --- a/src/google/protobuf/compiler/command_line_interface.h +++ b/src/google/protobuf/compiler/command_line_interface.h @@ -56,9 +56,7 @@ class FileDescriptorProto; // descriptor.pb.h template<typename T> class RepeatedPtrField; // repeated_field.h } // namespace protobuf -} // namespace google -namespace google { namespace protobuf { namespace compiler { @@ -247,24 +245,24 @@ class LIBPROTOC_EXPORT CommandLineInterface { // Generate the given output file from the given input. struct OutputDirective; // see below - bool GenerateOutput(const vector<const FileDescriptor*>& parsed_files, + bool GenerateOutput(const std::vector<const FileDescriptor*>& parsed_files, const OutputDirective& output_directive, GeneratorContext* generator_context); - bool GeneratePluginOutput(const vector<const FileDescriptor*>& parsed_files, - const string& plugin_name, - const string& parameter, - GeneratorContext* generator_context, - string* error); + bool GeneratePluginOutput( + const std::vector<const FileDescriptor*>& parsed_files, + const string& plugin_name, const string& parameter, + GeneratorContext* generator_context, string* error); // Implements --encode and --decode. bool EncodeOrDecode(const DescriptorPool* pool); // Implements the --descriptor_set_out option. - bool WriteDescriptorSet(const vector<const FileDescriptor*> parsed_files); + bool WriteDescriptorSet( + const std::vector<const FileDescriptor*> parsed_files); // Implements the --dependency_out option bool GenerateDependencyManifestFile( - const vector<const FileDescriptor*>& parsed_files, + const std::vector<const FileDescriptor*>& parsed_files, const GeneratorContextMap& output_directories, DiskSourceTree* source_tree); @@ -281,7 +279,7 @@ class LIBPROTOC_EXPORT CommandLineInterface { const FileDescriptor* file, bool include_json_name, bool include_source_code_info, - set<const FileDescriptor*>* already_seen, + std::set<const FileDescriptor*>* already_seen, RepeatedPtrField<FileDescriptorProto>* output); // Implements the --print_free_field_numbers. This function prints free field @@ -315,16 +313,16 @@ class LIBPROTOC_EXPORT CommandLineInterface { CodeGenerator* generator; string help_text; }; - typedef map<string, GeneratorInfo> GeneratorMap; + typedef std::map<string, GeneratorInfo> GeneratorMap; GeneratorMap generators_by_flag_name_; GeneratorMap generators_by_option_name_; // A map from generator names to the parameters specified using the option // flag. For example, if the user invokes the compiler with: // protoc --foo_out=outputdir --foo_opt=enable_bar ... // Then there will be an entry ("--foo_out", "enable_bar") in this map. - map<string, string> generator_parameters_; + std::map<string, string> generator_parameters_; // Similar to generator_parameters_, but stores the parameters for plugins. - map<string, string> plugin_parameters_; + std::map<string, string> plugin_parameters_; // See AllowPlugins(). If this is empty, plugins aren't allowed. string plugin_prefix_; @@ -332,7 +330,7 @@ class LIBPROTOC_EXPORT CommandLineInterface { // Maps specific plugin names to files. When executing a plugin, this map // is searched first to find the plugin executable. If not found here, the // PATH (or other OS-specific search strategy) is searched. - map<string, string> plugins_; + std::map<string, string> plugins_; // Stuff parsed from command line. enum Mode { @@ -358,12 +356,13 @@ class LIBPROTOC_EXPORT CommandLineInterface { ErrorFormat error_format_; - vector<pair<string, string> > proto_path_; // Search path for proto files. - vector<string> input_files_; // Names of the input proto files. + std::vector<std::pair<string, string> > + proto_path_; // Search path for proto files. + std::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_; + std::set<string> direct_dependencies_; bool direct_dependencies_explicitly_set_; // output_directives_ lists all the files we are supposed to output and what @@ -374,7 +373,7 @@ class LIBPROTOC_EXPORT CommandLineInterface { string parameter; string output_location; }; - vector<OutputDirective> output_directives_; + std::vector<OutputDirective> output_directives_; // When using --encode or --decode, this names the type we are encoding or // decoding. (Empty string indicates --decode_raw.) diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index dfbaa45a..d5b5b185 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -217,7 +217,7 @@ class CommandLineInterfaceTest : public testing::Test { string captured_stdout_; // Pointers which need to be deleted later. - vector<CodeGenerator*> mock_generators_to_delete_; + std::vector<CodeGenerator*> mock_generators_to_delete_; NullCodeGenerator* null_generator_; }; @@ -291,7 +291,7 @@ void CommandLineInterfaceTest::TearDown() { } void CommandLineInterfaceTest::Run(const string& command) { - vector<string> args = Split(command, " ", true); + std::vector<string> args = Split(command, " ", true); if (!disallow_plugins_) { cli_.AllowPlugins("prefix-"); @@ -759,7 +759,7 @@ TEST_F(CommandLineInterfaceTest, TrailingBackslash) { TEST_F(CommandLineInterfaceTest, Win32ErrorMessage) { EXPECT_EQ("The system cannot find the file specified.\r\n", - Subprocess::Win32ErrorMessage(ERROR_FILE_NOT_FOUND)); + Subprocess::Win32ErrorMessage(ERROR_FILE_NOT_FOUND)); } #endif // defined(_WIN32) || defined(__CYGWIN__) @@ -1856,7 +1856,7 @@ class EncodeDecodeTest : public testing::Test { enum ReturnCode { SUCCESS, ERROR }; bool Run(const string& command) { - vector<string> args; + std::vector<string> args; args.push_back("protoc"); SplitStringUsing(command, " ", &args); args.push_back("--proto_path=" + TestSourceDir()); diff --git a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc index deef290b..bf4e5831 100644 --- a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc @@ -114,7 +114,7 @@ class MockGeneratorContext : public GeneratorContext { } private: - map<string, string*> files_; + std::map<string, string*> files_; }; TEST(BootstrapTest, GeneratedDescriptorMatches) { diff --git a/src/google/protobuf/compiler/cpp/cpp_enum.cc b/src/google/protobuf/compiler/cpp/cpp_enum.cc index 6ced26bc..9493d5f8 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum.cc @@ -70,7 +70,7 @@ EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor, EnumGenerator::~EnumGenerator() {} void EnumGenerator::FillForwardDeclaration( - map<string, const EnumDescriptor*>* enum_names) { + std::map<string, const EnumDescriptor*>* enum_names) { if (!options_.proto_h) { return; } @@ -78,7 +78,7 @@ void EnumGenerator::FillForwardDeclaration( } void EnumGenerator::GenerateDefinition(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = classname_; vars["short_name"] = descriptor_->name(); vars["enumbase"] = classname_ + (options_.proto_h ? " : int" : ""); @@ -180,7 +180,7 @@ GenerateGetEnumDescriptorSpecializations(io::Printer* printer) { } void EnumGenerator::GenerateSymbolImports(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["nested_name"] = descriptor_->name(); vars["classname"] = classname_; vars["constexpr"] = options_.proto_h ? "constexpr " : ""; @@ -229,33 +229,36 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) { } } -void EnumGenerator::GenerateDescriptorInitializer( - io::Printer* printer, int index) { - map<string, string> vars; - vars["classname"] = classname_; - vars["index"] = SimpleItoa(index); +void EnumGenerator::GenerateDescriptorInitializer(io::Printer* printer) { + std::map<string, string> vars; + vars["index"] = SimpleItoa(descriptor_->index()); + vars["index_in_metadata"] = SimpleItoa(index_in_metadata_); if (descriptor_->containing_type() == NULL) { printer->Print(vars, - "$classname$_descriptor_ = file->enum_type($index$);\n"); + "file_level_enum_descriptors[$index_in_metadata$] = " + "file->enum_type($index$);\n"); } else { vars["parent"] = ClassName(descriptor_->containing_type(), false); printer->Print(vars, - "$classname$_descriptor_ = $parent$_descriptor_->enum_type($index$);\n"); + "file_level_enum_descriptors[$index_in_metadata$] = " + "$parent$_descriptor->enum_type($index$);\n"); } } void EnumGenerator::GenerateMethods(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = classname_; + vars["index_in_metadata"] = SimpleItoa(index_in_metadata_); vars["constexpr"] = options_.proto_h ? "constexpr " : ""; if (HasDescriptorMethods(descriptor_->file(), options_)) { - printer->Print(vars, - "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" - "}\n"); + printer->Print( + vars, + "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n" + " protobuf_AssignDescriptorsOnce();\n" + " return file_level_enum_descriptors[$index_in_metadata$];\n" + "}\n"); } printer->Print(vars, @@ -266,13 +269,13 @@ void EnumGenerator::GenerateMethods(io::Printer* printer) { // each number once by first constructing a set containing all valid // numbers, then printing a case statement for each element. - set<int> numbers; + std::set<int> numbers; for (int j = 0; j < descriptor_->value_count(); j++) { const EnumValueDescriptor* value = descriptor_->value(j); numbers.insert(value->number()); } - for (set<int>::iterator iter = numbers.begin(); + for (std::set<int>::iterator iter = numbers.begin(); iter != numbers.end(); ++iter) { printer->Print( " case $number$:\n", diff --git a/src/google/protobuf/compiler/cpp/cpp_enum.h b/src/google/protobuf/compiler/cpp/cpp_enum.h index 90edf001..0b568c57 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum.h +++ b/src/google/protobuf/compiler/cpp/cpp_enum.h @@ -66,7 +66,8 @@ class EnumGenerator { // enums. A given key in enum_names will map from an enum class name to the // EnumDescriptor that was responsible for its inclusion in the map. This can // be used to associate the descriptor with the code generated for it. - void FillForwardDeclaration(map<string, const EnumDescriptor*>* enum_names); + void FillForwardDeclaration( + std::map<string, const EnumDescriptor*>* enum_names); // Generate header code defining the enum. This code should be placed // within the enum's package namespace, but NOT within any class, even for @@ -87,7 +88,7 @@ class EnumGenerator { // Generate code that initializes the global variable storing the enum's // descriptor. - void GenerateDescriptorInitializer(io::Printer* printer, int index); + void GenerateDescriptorInitializer(io::Printer* printer); // Generate non-inline methods related to the enum, such as IsValidValue(). // Goes in the .cc file. @@ -100,6 +101,9 @@ class EnumGenerator { // whether to generate the *_ARRAYSIZE constant. const bool generate_array_size_; + int index_in_metadata_; + + friend class FileGenerator; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc index c3dfa817..b6658079 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc @@ -46,7 +46,7 @@ namespace cpp { namespace { void SetEnumVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); const EnumValueDescriptor* default_value = descriptor->default_value_enum(); @@ -82,7 +82,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void EnumFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$$type$ $classname$::$name$() const {\n" @@ -122,6 +122,11 @@ GenerateConstructorCode(io::Printer* printer) const { } void EnumFieldGenerator:: +GenerateCopyConstructorCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_ = from.$name$_;\n"); +} + +void EnumFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { printer->Print(variables_, "int value;\n" @@ -142,7 +147,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { } else { printer->Print( "} else {\n" - " unknown_fields_stream.WriteVarint32($tag$);\n" + " unknown_fields_stream.WriteVarint32($tag$u);\n" " unknown_fields_stream.WriteVarint32(value);\n", "tag", SimpleItoa(internal::WireFormat::MakeTag(descriptor_))); } @@ -186,7 +191,7 @@ EnumOneofFieldGenerator::~EnumOneofFieldGenerator() {} void EnumOneofFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$$type$ $classname$::$name$() const {\n" @@ -223,8 +228,9 @@ GenerateSwappingCode(io::Printer* printer) const { void EnumOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { - printer->Print(variables_, - " $classname$_default_oneof_instance_->$name$_ = $default$;\n"); + printer->Print( + variables_, + " $classname$_default_oneof_instance_.$name$_ = $default$;\n"); } // =================================================================== @@ -262,7 +268,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void RepeatedEnumFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$$type$ $classname$::$name$(int index) const {\n" @@ -311,11 +317,6 @@ 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"); } diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.h b/src/google/protobuf/compiler/cpp/cpp_enum_field.h index 57ffeec5..3ecd7ba8 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.h @@ -58,6 +58,7 @@ class EnumFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; @@ -65,7 +66,7 @@ class EnumFieldGenerator : public FieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); @@ -101,9 +102,9 @@ 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 GenerateCopyConstructorCode(io::Printer* printer) const {} void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; @@ -112,7 +113,7 @@ class RepeatedEnumFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_extension.cc b/src/google/protobuf/compiler/cpp/cpp_extension.cc index 4554c72c..e4fce461 100644 --- a/src/google/protobuf/compiler/cpp/cpp_extension.cc +++ b/src/google/protobuf/compiler/cpp/cpp_extension.cc @@ -92,7 +92,7 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor, ExtensionGenerator::~ExtensionGenerator() {} void ExtensionGenerator::GenerateDeclaration(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["extendee" ] = ExtendeeClassName(descriptor_); vars["number" ] = SimpleItoa(descriptor_->number()); vars["type_traits" ] = type_traits_; @@ -128,7 +128,7 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) { ClassName(descriptor_->extension_scope(), false) + "::"; string name = scope + descriptor_->name(); - map<string, string> vars; + std::map<string, string> vars; vars["extendee" ] = ExtendeeClassName(descriptor_); vars["type_traits" ] = type_traits_; vars["name" ] = name; @@ -167,7 +167,7 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) { } void ExtensionGenerator::GenerateRegistration(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["extendee" ] = ExtendeeClassName(descriptor_); vars["number" ] = SimpleItoa(descriptor_->number()); vars["field_type" ] = SimpleItoa(static_cast<int>(descriptor_->type())); diff --git a/src/google/protobuf/compiler/cpp/cpp_field.cc b/src/google/protobuf/compiler/cpp/cpp_field.cc index e2033c1a..4480a9d2 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_field.cc @@ -59,7 +59,7 @@ namespace cpp { using internal::WireFormat; void SetCommonFieldVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options) { (*variables)["name"] = FieldName(descriptor); (*variables)["index"] = SimpleItoa(descriptor->index()); @@ -98,7 +98,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, } void SetCommonOneofFieldVariables(const FieldDescriptor* descriptor, - map<string, string>* variables) { + std::map<string, string>* variables) { const string prefix = descriptor->containing_oneof()->name() + "_."; (*variables)["oneof_prefix"] = prefix; (*variables)["oneof_name"] = descriptor->containing_oneof()->name(); diff --git a/src/google/protobuf/compiler/cpp/cpp_field.h b/src/google/protobuf/compiler/cpp/cpp_field.h index fdd338a6..00dc25d4 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_field.h @@ -61,11 +61,11 @@ namespace cpp { // ['name', 'index', 'number', 'classname', 'declared_type', 'tag_size', // 'deprecation']. void SetCommonFieldVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options); void SetCommonOneofFieldVariables(const FieldDescriptor* descriptor, - map<string, string>* variables); + std::map<string, string>* variables); class FieldGenerator { public: @@ -124,10 +124,20 @@ class FieldGenerator { io::Printer* /*printer*/) const {} // Generate lines of code (statements, not declarations) which clear the - // field. This is used to define the clear_$name$() method as well as - // the Clear() method for the whole message. + // field. This is used to define the clear_$name$() method virtual void GenerateClearingCode(io::Printer* printer) const = 0; + // Generate lines of code (statements, not declarations) which clear the field + // as part of the Clear() method for the whole message. For message types + // which have field presence bits, MessageGenerator::GenerateClear will have + // already checked the presence bits. + // + // Since most field types can re-use GenerateClearingCode, this method is not + // pure virtual. + virtual void GenerateMessageClearingCode(io::Printer* printer) const { + GenerateClearingCode(printer); + } + // Generate lines of code (statements, not declarations) which merges the // contents of the field from the current message to the target message, // which is stored in the generated code variable "from". @@ -136,12 +146,8 @@ 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); - } + // Generates a copy constructor + virtual void GenerateCopyConstructorCode(io::Printer* printer) const = 0; // Generate lines of code (statements, not declarations) which swaps // this field and the corresponding field of another message, which diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index b8b456b7..bc664c70 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -60,33 +60,42 @@ namespace cpp { FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) : file_(file), options_(options), - message_generators_( - new google::protobuf::scoped_ptr<MessageGenerator>[file->message_type_count()]), - enum_generators_( - new google::protobuf::scoped_ptr<EnumGenerator>[file->enum_type_count()]), - service_generators_( - new google::protobuf::scoped_ptr<ServiceGenerator>[file->service_count()]), - extension_generators_( - new google::protobuf::scoped_ptr<ExtensionGenerator>[file->extension_count()]) { + message_generators_owner_( + new google::protobuf::scoped_ptr<MessageGenerator>[ file->message_type_count() ]), + enum_generators_owner_( + new google::protobuf::scoped_ptr<EnumGenerator>[ file->enum_type_count() ]), + service_generators_owner_( + new google::protobuf::scoped_ptr<ServiceGenerator>[ file->service_count() ]), + extension_generators_owner_( + new google::protobuf::scoped_ptr<ExtensionGenerator>[ file->extension_count() ]) { for (int i = 0; i < file->message_type_count(); i++) { - message_generators_[i].reset( - new MessageGenerator(file->message_type(i), options)); + message_generators_owner_[i].reset( + new MessageGenerator(file->message_type(i), options)); + message_generators_owner_[i]->Flatten(&message_generators_); + } + + for (int i = 0; i < message_generators_.size(); i++) { + message_generators_[i]->AddGenerators(&enum_generators_, + &extension_generators_); } for (int i = 0; i < file->enum_type_count(); i++) { - enum_generators_[i].reset( - new EnumGenerator(file->enum_type(i), options)); + enum_generators_owner_[i].reset( + new EnumGenerator(file->enum_type(i), options)); + enum_generators_.push_back(enum_generators_owner_[i].get()); } for (int i = 0; i < file->service_count(); i++) { - service_generators_[i].reset( - new ServiceGenerator(file->service(i), options)); + service_generators_owner_[i].reset( + new ServiceGenerator(file->service(i), options)); + service_generators_.push_back(service_generators_owner_[i].get()); } for (int i = 0; i < file->extension_count(); i++) { - extension_generators_[i].reset( - new ExtensionGenerator(file->extension(i), options)); + extension_generators_owner_[i].reset( + new ExtensionGenerator(file->extension(i), options)); + extension_generators_.push_back(extension_generators_owner_[i].get()); } package_parts_ = Split(file_->package(), ".", true); @@ -94,29 +103,7 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) FileGenerator::~FileGenerator() {} -void FileGenerator::GenerateProtoHeader(io::Printer* printer, - const string& info_path) { - if (!options_.proto_h) { - return; - } - - string filename_identifier = FilenameIdentifier(file_->name()); - GenerateTopHeaderGuard(printer, filename_identifier); - - - GenerateLibraryIncludes(printer); - - for (int i = 0; i < file_->public_dependency_count(); i++) { - const FileDescriptor* dep = file_->public_dependency(i); - const char* extension = ".proto.h"; - string dependency = StripProto(dep->name()) + extension; - printer->Print( - "#include \"$dependency$\" // IWYU pragma: export\n", - "dependency", dependency); - } - - GenerateMetadataPragma(printer, info_path); - +void FileGenerator::GenerateHeader(io::Printer* printer) { printer->Print( "// @@protoc_insertion_point(includes)\n"); @@ -166,6 +153,32 @@ void FileGenerator::GenerateProtoHeader(io::Printer* printer, "\n" "// @@protoc_insertion_point(global_scope)\n" "\n"); +} + +void FileGenerator::GenerateProtoHeader(io::Printer* printer, + const string& info_path) { + if (!options_.proto_h) { + return; + } + + string filename_identifier = FilenameIdentifier(file_->name()); + GenerateTopHeaderGuard(printer, filename_identifier); + + + GenerateLibraryIncludes(printer); + + for (int i = 0; i < file_->public_dependency_count(); i++) { + const FileDescriptor* dep = file_->public_dependency(i); + const char* extension = ".proto.h"; + string dependency = StripProto(dep->name()) + extension; + printer->Print( + "#include \"$dependency$\" // IWYU pragma: export\n", + "dependency", dependency); + } + + GenerateMetadataPragma(printer, info_path); + + GenerateHeader(printer); GenerateBottomHeaderGuard(printer, filename_identifier); } @@ -185,59 +198,29 @@ void FileGenerator::GeneratePBHeader(io::Printer* printer, GenerateDependencyIncludes(printer); GenerateMetadataPragma(printer, info_path); - printer->Print( - "// @@protoc_insertion_point(includes)\n"); - - - - // Open namespace. - GenerateNamespaceOpeners(printer); - if (!options_.proto_h) { - GenerateGlobalStateFunctionDeclarations(printer); - GenerateMessageForwardDeclarations(printer); - - printer->Print("\n"); - - GenerateEnumDefinitions(printer); - - printer->Print(kThickSeparator); - printer->Print("\n"); - - GenerateMessageDefinitions(printer); - - printer->Print("\n"); - printer->Print(kThickSeparator); - printer->Print("\n"); - - GenerateServiceDefinitions(printer); - - GenerateExtensionIdentifiers(printer); - - printer->Print("\n"); - printer->Print(kThickSeparator); - printer->Print("\n"); - - GenerateInlineFunctionDefinitions(printer); - } - - printer->Print( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n"); + GenerateHeader(printer); + } else { + // This is unfortunately necessary for some plugins. I don't see why we + // need two of the same insertion points. + // TODO(gerbens) remove this. + printer->Print( + "// @@protoc_insertion_point(includes)\n"); - // Close up namespace. - GenerateNamespaceClosers(printer); + // Open namespace. + GenerateNamespaceOpeners(printer); + printer->Print( + "\n" + "// @@protoc_insertion_point(namespace_scope)\n"); + // Close up namespace. + GenerateNamespaceClosers(printer); - if (!options_.proto_h) { - // We need to specialize some templates in the ::google::protobuf namespace: - GenerateProto2NamespaceEnumSpecializations(printer); + printer->Print( + "\n" + "// @@protoc_insertion_point(global_scope)\n" + "\n"); } - printer->Print( - "\n" - "// @@protoc_insertion_point(global_scope)\n" - "\n"); - GenerateBottomHeaderGuard(printer, filename_identifier); } @@ -267,7 +250,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) { "right", use_system_include ? ">" : "\""); // Unknown fields implementation in lite mode uses StringOutputStream - if (!UseUnknownFieldSet(file_, options_) && file_->message_type_count() > 0) { + if (!UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) { printer->Print( "#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n"); } @@ -297,25 +280,48 @@ void FileGenerator::GenerateSource(io::Printer* printer) { GenerateNamespaceOpeners(printer); + for (int i = 0; i < message_generators_.size(); i++) { + if (IsMapEntryMessage(message_generators_[i]->descriptor_)) continue; + printer->Print( + "class $classname$DefaultTypeInternal : " + "public ::google::protobuf::internal::ExplicitlyConstructed<$classname$> {};\n" + "$classname$DefaultTypeInternal _$classname$_default_instance_;\n", + "classname", message_generators_[i]->classname_); + } + if (HasDescriptorMethods(file_, options_)) { printer->Print( "\n" "namespace {\n" "\n"); - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateDescriptorDeclarations(printer); + + if (!message_generators_.empty()) { + printer->Print("::google::protobuf::Metadata file_level_metadata[$size$];\n", + "size", SimpleItoa(message_generators_.size())); } - for (int i = 0; i < file_->enum_type_count(); i++) { + if (!enum_generators_.empty()) { printer->Print( - "const ::google::protobuf::EnumDescriptor* $name$_descriptor_ = NULL;\n", - "name", ClassName(file_->enum_type(i), false)); + "const ::google::protobuf::EnumDescriptor* " + "file_level_enum_descriptors[$size$];\n", + "size", SimpleItoa(enum_generators_.size())); + } + if (HasGenericServices(file_, options_) && file_->service_count() > 0) { + printer->Print( + "const ::google::protobuf::ServiceDescriptor* " + "file_level_service_descriptors[$size$];\n", + "size", SimpleItoa(file_->service_count())); } + for (int i = 0; i < message_generators_.size(); i++) { + message_generators_[i]->index_in_metadata_ = i; + message_generators_[i]->GenerateDescriptorDeclarations(printer); + } + for (int i = 0; i < enum_generators_.size(); i++) { + enum_generators_[i]->index_in_metadata_ = i; + } if (HasGenericServices(file_, options_)) { - for (int i = 0; i < file_->service_count(); i++) { - printer->Print( - "const ::google::protobuf::ServiceDescriptor* $name$_descriptor_ = NULL;\n", - "name", file_->service(i)->name()); + for (int i = 0; i < service_generators_.size(); i++) { + service_generators_[i]->index_in_metadata_ = i; } } @@ -330,26 +336,12 @@ void FileGenerator::GenerateSource(io::Printer* printer) { GenerateBuildDescriptors(printer); // Generate enums. - for (int i = 0; i < file_->enum_type_count(); i++) { + for (int i = 0; i < enum_generators_.size(); i++) { enum_generators_[i]->GenerateMethods(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"); - } + for (int i = 0; i < message_generators_.size(); i++) { printer->Print("\n"); printer->Print(kThickSeparator); printer->Print("\n"); @@ -364,7 +356,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) { if (HasGenericServices(file_, options_)) { // Generate services. - for (int i = 0; i < file_->service_count(); i++) { + for (int i = 0; i < service_generators_.size(); i++) { if (i == 0) printer->Print("\n"); printer->Print(kThickSeparator); printer->Print("\n"); @@ -373,7 +365,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) { } // Define extensions. - for (int i = 0; i < file_->extension_count(); i++) { + for (int i = 0; i < extension_generators_.size(); i++) { extension_generators_[i]->GenerateDefinition(printer); } @@ -391,8 +383,9 @@ void FileGenerator::GenerateSource(io::Printer* printer) { class FileGenerator::ForwardDeclarations { public: ~ForwardDeclarations() { - for (map<string, ForwardDeclarations *>::iterator it = namespaces_.begin(), - end = namespaces_.end(); + for (std::map<string, ForwardDeclarations*>::iterator + it = namespaces_.begin(), + end = namespaces_.end(); it != end; ++it) { delete it->second; } @@ -407,11 +400,11 @@ class FileGenerator::ForwardDeclarations { return ns; } - map<string, const Descriptor*>& classes() { return classes_; } - map<string, const EnumDescriptor*>& enums() { return enums_; } + std::map<string, const Descriptor*>& classes() { return classes_; } + std::map<string, const EnumDescriptor*>& enums() { return enums_; } void Print(io::Printer* printer) const { - for (map<string, const EnumDescriptor *>::const_iterator + for (std::map<string, const EnumDescriptor *>::const_iterator it = enums_.begin(), end = enums_.end(); it != end; ++it) { @@ -420,13 +413,21 @@ class FileGenerator::ForwardDeclarations { printer->Print("bool $enumname$_IsValid(int value);\n", "enumname", it->first); } - for (map<string, const Descriptor *>::const_iterator it = classes_.begin(), - end = classes_.end(); + for (std::map<string, const Descriptor*>::const_iterator + it = classes_.begin(), + end = classes_.end(); it != end; ++it) { printer->Print("class $classname$;\n", "classname", it->first); printer->Annotate("classname", it->second); + + printer->Print( + "class $classname$DefaultTypeInternal;\n" + "extern $classname$DefaultTypeInternal " + "_$classname$_default_instance_;\n", // NOLINT + "classname", + it->first); } - for (map<string, ForwardDeclarations *>::const_iterator + for (std::map<string, ForwardDeclarations *>::const_iterator it = namespaces_.begin(), end = namespaces_.end(); it != end; ++it) { @@ -440,9 +441,9 @@ class FileGenerator::ForwardDeclarations { private: - map<string, ForwardDeclarations*> namespaces_; - map<string, const Descriptor*> classes_; - map<string, const EnumDescriptor*> enums_; + std::map<string, ForwardDeclarations*> namespaces_; + std::map<string, const Descriptor*> classes_; + std::map<string, const EnumDescriptor*> enums_; }; void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { @@ -465,75 +466,135 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // and we only use AddDescriptors() to allocate default instances. if (HasDescriptorMethods(file_, options_)) { - printer->Print( - "\n" - "void $assigndescriptorsname$() GOOGLE_ATTRIBUTE_COLD;\n" - "void $assigndescriptorsname$() {\n", - "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name())); - printer->Indent(); - - // Make sure the file has found its way into the pool. If a descriptor - // is requested *during* static init then AddDescriptors() may not have - // been called yet, so we call it manually. Note that it's fine if - // AddDescriptors() is called multiple times. - printer->Print( - "$adddescriptorsname$();\n", - "adddescriptorsname", GlobalAddDescriptorsName(file_->name())); + if (!message_generators_.empty()) { + printer->Print( + "\n" + "const ::google::protobuf::uint32* $offsetfunname$() GOOGLE_ATTRIBUTE_COLD;\n" + "const ::google::protobuf::uint32* $offsetfunname$() {\n", + "offsetfunname", GlobalOffsetTableName(file_->name())); + printer->Indent(); - // Get the file's descriptor from the pool. - printer->Print( - "const ::google::protobuf::FileDescriptor* file =\n" - " ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n" - " \"$filename$\");\n" - // Note that this GOOGLE_CHECK is necessary to prevent a warning about "file" - // being unused when compiling an empty .proto file. - "GOOGLE_CHECK(file != NULL);\n", - "filename", file_->name()); + printer->Print("static const ::google::protobuf::uint32 offsets[] = {\n"); + printer->Indent(); + std::vector<std::pair<size_t, size_t> > pairs; + for (int i = 0; i < message_generators_.size(); i++) { + pairs.push_back(message_generators_[i]->GenerateOffsets(printer)); + } + printer->Outdent(); + printer->Outdent(); + printer->Print( + " };\n" + " return offsets;\n" + "}\n" + "\n"); - // Go through all the stuff defined in this file and generated code to - // assign the global descriptor pointers based on the file descriptor. - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateDescriptorInitializer(printer, i); - } - for (int i = 0; i < file_->enum_type_count(); i++) { - enum_generators_[i]->GenerateDescriptorInitializer(printer, i); - } - if (HasGenericServices(file_, options_)) { - for (int i = 0; i < file_->service_count(); i++) { - service_generators_[i]->GenerateDescriptorInitializer(printer, i); + printer->Print( + "static const ::google::protobuf::internal::MigrationSchema schemas[] = {\n"); + printer->Indent(); + { + int offset = 0; + for (int i = 0; i < message_generators_.size(); i++) { + message_generators_[i]->GenerateSchema(printer, offset, + pairs[i].second); + offset += pairs[i].first; + } + } + printer->Outdent(); + printer->Print( + "};\n" + "\n" + "static const ::google::protobuf::internal::DefaultInstanceData " + "file_default_instances[] = {\n"); + printer->Indent(); + for (int i = 0; i < message_generators_.size(); i++) { + const Descriptor* descriptor = message_generators_[i]->descriptor_; + if (IsMapEntryMessage(descriptor)) continue; + + string oneof_default = "NULL"; + if (message_generators_[i]->descriptor_->oneof_decl_count()) { + oneof_default = + "&" + ClassName(descriptor, false) + "_default_oneof_instance_"; + } + printer->Print( + "{reinterpret_cast<const " + "::google::protobuf::Message*>(&_$classname$_default_instance_), " + "$oneof_default$},\n", + "classname", ClassName(descriptor, false), "oneof_default", + oneof_default); } + printer->Outdent(); + printer->Print( + "};\n" + "\n"); + } else { + // we still need these symbols to exist + printer->Print( + "inline ::google::protobuf::uint32* $offsetfunname$() { return NULL; }\n" + "static const ::google::protobuf::internal::MigrationSchema* schemas = NULL;\n" + "static const ::google::protobuf::internal::DefaultInstanceData* " + "file_default_instances = NULL;\n", + "offsetfunname", + GlobalOffsetTableName(file_->name())); } - printer->Outdent(); - printer->Print( - "}\n" - "\n"); - // --------------------------------------------------------------- // protobuf_AssignDescriptorsOnce(): The first time it is called, calls // AssignDescriptors(). All later times, waits for the first call to // complete and then returns. + string message_factory = "NULL"; printer->Print( "namespace {\n" "\n" - "GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\n" + "void protobuf_AssignDescriptors() {\n" + // Make sure the file has found its way into the pool. If a descriptor + // is requested *during* static init then AddDescriptors() may not have + // been called yet, so we call it manually. Note that it's fine if + // AddDescriptors() is called multiple times. + " $adddescriptorsname$();\n" + " ::google::protobuf::MessageFactory* factory = $factory$;\n" + " AssignDescriptors(\n" + " \"$filename$\", schemas, file_default_instances, " + "$offsetfunname$(), factory,\n" + " $metadata$, $enum_descriptors$, $service_descriptors$);\n" + "}\n" + "\n" "void protobuf_AssignDescriptorsOnce() {\n" - " ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n" - " &$assigndescriptorsname$);\n" + " static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n" + " ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);\n" "}\n" "\n", - "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name())); - - // protobuf_RegisterTypes(): Calls - // MessageFactory::InternalRegisterGeneratedType() for each message type. + "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), + "offsetfunname", GlobalOffsetTableName(file_->name()), "filename", + file_->name(), "metadata", + !message_generators_.empty() ? "file_level_metadata" : "NULL", + "enum_descriptors", + !enum_generators_.empty() ? "file_level_enum_descriptors" : "NULL", + "service_descriptors", + HasGenericServices(file_, options_) && file_->service_count() > 0 + ? "file_level_service_descriptors" + : "NULL", + "factory", message_factory); + + // Only here because of useless string reference that we don't want in + // protobuf_AssignDescriptorsOnce, because that is called from all the + // GetMetadata member methods. printer->Print( "void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\n" "void protobuf_RegisterTypes(const ::std::string&) {\n" " protobuf_AssignDescriptorsOnce();\n"); printer->Indent(); - for (int i = 0; i < file_->message_type_count(); i++) { + // All normal messages can be done generically + if (!message_generators_.empty()) { + printer->Print( + "::google::protobuf::internal::RegisterAllTypes(file_level_metadata, $size$);\n", + "size", SimpleItoa(message_generators_.size())); + } + + // Map types are treated special + // TODO(gerbens) find a way to treat maps more like normal messages. + for (int i = 0; i < message_generators_.size(); i++) { message_generators_[i]->GenerateTypeRegistrations(printer); } @@ -553,7 +614,7 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { "shutdownfilename", GlobalShutdownFileName(file_->name())); printer->Indent(); - for (int i = 0; i < file_->message_type_count(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { message_generators_[i]->GenerateShutdownCode(printer); } @@ -566,8 +627,8 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // Now generate the InitDefaults() function. printer->Print( "void $initdefaultsname$_impl() {\n" - " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" - "\n", + " GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n" + "", // Vars. "initdefaultsname", GlobalInitDefaultsName(file_->name())); @@ -586,26 +647,28 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { "name", add_desc_name); } + // Force initialization of primitive values we depend on. + printer->Print("::google::protobuf::internal::InitProtobufDefaults();\n"); + // 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++) { + for (int i = 0; i < message_generators_.size(); i++) { message_generators_[i]->GenerateDefaultInstanceAllocator(printer); } - for (int i = 0; i < file_->extension_count(); i++) { + for (int i = 0; i < extension_generators_.size(); i++) { extension_generators_[i]->GenerateRegistration(printer); } - for (int i = 0; i < file_->message_type_count(); i++) { + for (int i = 0; i < message_generators_.size(); 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" + " static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n" + " ::google::protobuf::GoogleOnceInit(&once, &$initdefaultsname$_impl);\n" "}\n", "initdefaultsname", GlobalInitDefaultsName(file_->name())); @@ -614,8 +677,6 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // Now generate the AddDescriptors() function. printer->Print( "void $adddescriptorsname$_impl() {\n" - " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" - "\n" " $initdefaultsname$();\n", // Vars. "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), @@ -632,60 +693,42 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { string file_data; file_proto.SerializeToString(&file_data); + printer->Print("static const char descriptor[] = {\n"); + printer->Indent(); + #ifdef _MSC_VER bool breakdown_large_file = true; #else bool breakdown_large_file = false; #endif - // Workaround for MSVC: "Error C1091: compiler limit: string exceeds 65535 - // bytes in length". Declare a static array of characters rather than use a - // string literal. - if (breakdown_large_file && file_data.size() > 65535) { - // This has to be explicitly marked as a signed char because the generated - // code puts negative values in the array, and sometimes plain char is - // unsigned. That implicit narrowing conversion is not allowed in C++11. - // <http://stackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-is-it-just-me-or-does-this-sound-like-a-breakin> - // has details on why. - printer->Print( - "static const signed char descriptor[] = {\n"); - printer->Indent(); - - // Only write 25 bytes per line. + if (breakdown_large_file && file_data.size() > 66538) { + // Workaround for MSVC: "Error C1091: compiler limit: string exceeds 65535 + // bytes in length". Declare a static array of characters rather than use + // a string literal. Only write 25 bytes per line. static const int kBytesPerLine = 25; for (int i = 0; i < file_data.size();) { - for (int j = 0; j < kBytesPerLine && i < file_data.size(); ++i, ++j) { - printer->Print( - "$char$, ", - "char", SimpleItoa(file_data[i])); - } - printer->Print( - "\n"); + for (int j = 0; j < kBytesPerLine && i < file_data.size(); ++i, ++j) { + printer->Print("'$char$', ", "char", + CEscape(file_data.substr(i, 1))); + } + printer->Print("\n"); } - - printer->Outdent(); - printer->Print( - "};\n"); - - printer->Print( - "::google::protobuf::DescriptorPool::InternalAddGeneratedFile(descriptor, $size$);\n", - "size", SimpleItoa(file_data.size())); - } else { - printer->Print( - "::google::protobuf::DescriptorPool::InternalAddGeneratedFile("); - // Only write 40 bytes per line. static const int kBytesPerLine = 40; for (int i = 0; i < file_data.size(); i += kBytesPerLine) { - printer->Print("\n \"$data$\"", - "data", - EscapeTrigraphs( - CEscape(file_data.substr(i, kBytesPerLine)))); + printer->Print(" \"$data$\"\n", "data", + EscapeTrigraphs(CEscape( + file_data.substr(i, kBytesPerLine)))); + } } + + printer->Outdent(); + printer->Print("};\n"); printer->Print( - ", $size$);\n", + "::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n" + " descriptor, $size$);\n", "size", SimpleItoa(file_data.size())); - } // Call MessageFactory::InternalRegisterGeneratedFile(). printer->Print( @@ -777,14 +820,11 @@ void FileGenerator::FillForwardDeclarations(ForwardDeclarations* decls) { decls = decls->AddOrGetNamespace(package_parts_[i]); } // Generate enum definitions. - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->FillEnumForwardDeclarations(&decls->enums()); - } - for (int i = 0; i < file_->enum_type_count(); i++) { + for (int i = 0; i < enum_generators_.size(); i++) { enum_generators_[i]->FillForwardDeclaration(&decls->enums()); } // Generate forward declarations of classes. - for (int i = 0; i < file_->message_type_count(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { message_generators_[i]->FillMessageForwardDeclarations( &decls->classes()); } @@ -840,12 +880,10 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { printer->Print( "#include <google/protobuf/arena.h>\n" "#include <google/protobuf/arenastring.h>\n" - "#include <google/protobuf/generated_message_util.h>\n"); - if (UseUnknownFieldSet(file_, options_)) { - printer->Print( - "#include <google/protobuf/metadata.h>\n"); - } - if (file_->message_type_count() > 0) { + "#include <google/protobuf/generated_message_util.h>\n" + "#include <google/protobuf/metadata.h>\n"); + + if (!message_generators_.empty()) { if (HasDescriptorMethods(file_, options_)) { printer->Print( "#include <google/protobuf/message.h>\n"); @@ -855,8 +893,10 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { } } printer->Print( - "#include <google/protobuf/repeated_field.h>\n" - "#include <google/protobuf/extension_set.h>\n"); + "#include <google/protobuf/repeated_field.h>" + " // IWYU pragma: export\n" + "#include <google/protobuf/extension_set.h>" + " // IWYU pragma: export\n"); if (HasMapFields(file_)) { printer->Print( "#include <google/protobuf/map.h>\n"); @@ -884,7 +924,7 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { "#include <google/protobuf/service.h>\n"); } - if (UseUnknownFieldSet(file_, options_) && file_->message_type_count() > 0) { + if (UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) { printer->Print( "#include <google/protobuf/unknown_field_set.h>\n"); } @@ -910,7 +950,7 @@ void FileGenerator::GenerateMetadataPragma(io::Printer* printer, } void FileGenerator::GenerateDependencyIncludes(io::Printer* printer) { - set<string> public_import_names; + std::set<string> public_import_names; for (int i = 0; i < file_->public_dependency_count(); i++) { public_import_names.insert(file_->public_dependency(i)->name()); } @@ -943,33 +983,11 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations( "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 - // called by the .pb.cc file in which they are defined. - "void $assigndescriptorsname$();\n" - "void $shutdownfilename$();\n" - "\n", - "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name()), - "shutdownfilename", GlobalShutdownFileName(file_->name())); -} - -void FileGenerator::GenerateMessageForwardDeclarations(io::Printer* printer) { - map<string, const Descriptor*> classes; - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->FillMessageForwardDeclarations(&classes); - } - for (map<string, const Descriptor *>::const_iterator it = classes.begin(), - end = classes.end(); - it != end; ++it) { - printer->Print("class $classname$;\n", "classname", it->first); - printer->Annotate("classname", it->second); - } } void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) { // Generate class definitions. - for (int i = 0; i < file_->message_type_count(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { if (i > 0) { printer->Print("\n"); printer->Print(kThinSeparator); @@ -981,10 +999,7 @@ void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) { void FileGenerator::GenerateEnumDefinitions(io::Printer* printer) { // Generate enum definitions. - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateEnumDefinitions(printer); - } - for (int i = 0; i < file_->enum_type_count(); i++) { + for (int i = 0; i < enum_generators_.size(); i++) { enum_generators_[i]->GenerateDefinition(printer); } } @@ -992,7 +1007,7 @@ void FileGenerator::GenerateEnumDefinitions(io::Printer* printer) { void FileGenerator::GenerateServiceDefinitions(io::Printer* printer) { if (HasGenericServices(file_, options_)) { // Generate service definitions. - for (int i = 0; i < file_->service_count(); i++) { + for (int i = 0; i < service_generators_.size(); i++) { if (i > 0) { printer->Print("\n"); printer->Print(kThinSeparator); @@ -1008,9 +1023,10 @@ void FileGenerator::GenerateServiceDefinitions(io::Printer* printer) { } void FileGenerator::GenerateExtensionIdentifiers(io::Printer* printer) { - // Declare extension identifiers. + // Declare extension identifiers. These are in global scope and so only + // the global scope extensions. for (int i = 0; i < file_->extension_count(); i++) { - extension_generators_[i]->GenerateDeclaration(printer); + extension_generators_owner_[i]->GenerateDeclaration(printer); } } @@ -1051,7 +1067,7 @@ void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) { printer->Print("#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n"); // Generate class inline methods. - for (int i = 0; i < file_->message_type_count(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { if (i > 0) { printer->Print(kThinSeparator); printer->Print("\n"); @@ -1061,7 +1077,7 @@ void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) { } printer->Print("#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS\n"); - for (int i = 0; i < file_->message_type_count(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { if (i > 0) { printer->Print(kThinSeparator); printer->Print("\n"); @@ -1084,10 +1100,7 @@ void FileGenerator::GenerateProto2NamespaceEnumSpecializations( "#ifndef SWIG\n" "namespace google {\nnamespace protobuf {\n" "\n"); - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); - } - for (int i = 0; i < file_->enum_type_count(); i++) { + for (int i = 0; i < enum_generators_.size(); i++) { enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); } printer->Print( diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h index 5dcf692b..25d6eabf 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.h +++ b/src/google/protobuf/compiler/cpp/cpp_file.h @@ -68,6 +68,9 @@ class FileGenerator { FileGenerator(const FileDescriptor* file, const Options& options); ~FileGenerator(); + // Shared code between the two header generators below. + void GenerateHeader(io::Printer* printer); + // info_path, if non-empty, should be the path (relative to printer's output) // to the metadata file describing this proto header. void GenerateProtoHeader(io::Printer* printer, @@ -117,18 +120,6 @@ class FileGenerator { // Generates types for classes. void GenerateMessageDefinitions(io::Printer* printer); - // Generates forward-declarations for just this file's classes. This is - // used for .pb.h headers, but not in proto_h mode. - void GenerateMessageForwardDeclarations(io::Printer* printer); - - // Fills in types for forward declarations. This is used internally, and - // also by other FileGenerators to determine imports' declarations. - void FillMessageForwardDeclarations(ForwardDeclarations* decls); - void FillMessageDefinitions(ForwardDeclarations* decls); - - // Generates enum definitions. - void GenerateEnumForwardDeclarations(io::Printer* printer); - void FillEnumForwardDeclarations(ForwardDeclarations* decls); void GenerateEnumDefinitions(io::Printer* printer); // Generates generic service definitions. @@ -145,13 +136,25 @@ class FileGenerator { const FileDescriptor* file_; const Options options_; - google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > message_generators_; - google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_; - google::protobuf::scoped_array<google::protobuf::scoped_ptr<ServiceGenerator> > service_generators_; - google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > extension_generators_; + // Contains the post-order walk of all the messages (and child messages) in + // this file. If you need a pre-order walk just reverse iterate. + std::vector<MessageGenerator*> message_generators_; + std::vector<EnumGenerator*> enum_generators_; + std::vector<ServiceGenerator*> service_generators_; + std::vector<ExtensionGenerator*> extension_generators_; + + // These members are just for owning (and thus proper deleting). Some of the + // message_ and enum_generators above are owned by child messages. + google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > + message_generators_owner_; + google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_owner_; + google::protobuf::scoped_array<google::protobuf::scoped_ptr<ServiceGenerator> > + service_generators_owner_; + google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > + extension_generators_owner_; // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. - vector<string> package_parts_; + std::vector<string> package_parts_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_generator.cc b/src/google/protobuf/compiler/cpp/cpp_generator.cc index 31d189c2..648ab28a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_generator.cc +++ b/src/google/protobuf/compiler/cpp/cpp_generator.cc @@ -59,7 +59,7 @@ bool CppGenerator::Generate(const FileDescriptor* file, const string& parameter, GeneratorContext* generator_context, string* error) const { - vector<pair<string, string> > options; + std::vector<std::pair<string, string> > options; ParseGeneratorParameter(parameter, &options); // ----------------------------------------------------------------- diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 6d844cc2..5a37b9d7 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -371,9 +371,9 @@ string DefaultValue(const FieldDescriptor* field) { return "GOOGLE_ULONGLONG(" + SimpleItoa(field->default_value_uint64())+ ")"; case FieldDescriptor::CPPTYPE_DOUBLE: { double value = field->default_value_double(); - if (value == numeric_limits<double>::infinity()) { + if (value == std::numeric_limits<double>::infinity()) { return "::google::protobuf::internal::Infinity()"; - } else if (value == -numeric_limits<double>::infinity()) { + } else if (value == -std::numeric_limits<double>::infinity()) { return "-::google::protobuf::internal::Infinity()"; } else if (value != value) { return "::google::protobuf::internal::NaN()"; @@ -384,9 +384,9 @@ string DefaultValue(const FieldDescriptor* field) { case FieldDescriptor::CPPTYPE_FLOAT: { float value = field->default_value_float(); - if (value == numeric_limits<float>::infinity()) { + if (value == std::numeric_limits<float>::infinity()) { return "static_cast<float>(::google::protobuf::internal::Infinity())"; - } else if (value == -numeric_limits<float>::infinity()) { + } else if (value == -std::numeric_limits<float>::infinity()) { return "static_cast<float>(-::google::protobuf::internal::Infinity())"; } else if (value != value) { return "static_cast<float>(::google::protobuf::internal::NaN())"; @@ -450,8 +450,8 @@ string GlobalInitDefaultsName(const string& filename) { } // Return the name of the AssignDescriptors() function for a given file. -string GlobalAssignDescriptorsName(const string& filename) { - return "protobuf_AssignDesc_" + FilenameIdentifier(filename); +string GlobalOffsetTableName(const string& filename) { + return "protobuf_Offsets_" + FilenameIdentifier(filename); } // Return the name of the ShutdownFile() function for a given file. @@ -602,7 +602,7 @@ static Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field, static void GenerateUtf8CheckCode(const FieldDescriptor* field, const Options& options, bool for_parse, - const map<string, string>& variables, + const std::map<string, string>& variables, const char* parameters, const char* strict_function, const char* verify_function, @@ -652,7 +652,7 @@ static void GenerateUtf8CheckCode(const FieldDescriptor* field, void GenerateUtf8CheckCodeForString(const FieldDescriptor* field, const Options& options, bool for_parse, - const map<string, string>& variables, + const std::map<string, string>& variables, const char* parameters, io::Printer* printer) { GenerateUtf8CheckCode(field, options, for_parse, variables, parameters, @@ -662,7 +662,7 @@ void GenerateUtf8CheckCodeForString(const FieldDescriptor* field, void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field, const Options& options, bool for_parse, - const map<string, string>& variables, + const std::map<string, string>& variables, const char* parameters, io::Printer* printer) { GenerateUtf8CheckCode(field, options, for_parse, variables, parameters, diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h index 3a0c0388..c988bda8 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -150,8 +150,8 @@ 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); +// Return the name of the offset table function for a given file. +string GlobalOffsetTableName(const string& filename); // Return the qualified C++ name for a file level symbol. string QualifiedFileLevelSymbol(const string& package, const string& name); @@ -269,13 +269,13 @@ bool IsWellKnownMessage(const FileDescriptor* descriptor); void GenerateUtf8CheckCodeForString(const FieldDescriptor* field, const Options& options, bool for_parse, - const map<string, string>& variables, + const std::map<string, string>& variables, const char* parameters, io::Printer* printer); void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field, const Options& options, bool for_parse, - const map<string, string>& variables, + const std::map<string, string>& variables, const char* parameters, io::Printer* printer); inline ::google::protobuf::FileOptions_OptimizeMode GetOptimizeFor( diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc index 31ac9ca7..5c4b56f7 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc @@ -45,10 +45,10 @@ bool IsProto3Field(const FieldDescriptor* field_descriptor) { } void SetMessageVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); - (*variables)["type"] = FieldMessageTypeName(descriptor); + (*variables)["type"] = ClassName(descriptor->message_type(), false); (*variables)["stream_writer"] = (*variables)["declared_type"] + (HasFastArraySerialization(descriptor->message_type()->file(), options) @@ -137,7 +137,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void MapFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline" : ""; printer->Print(variables, "$inline$ const ::google::protobuf::Map< $key_cpp$, $val_cpp$ >&\n" @@ -154,7 +154,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, void MapFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : ""; printer->Print(variables, "$this_message$$name$_.Clear();\n"); } @@ -173,14 +173,20 @@ void MapFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { if (HasDescriptorMethods(descriptor_->file(), options_)) { printer->Print(variables_, - "$name$_.SetAssignDescriptorCallback(\n" - " protobuf_AssignDescriptorsOnce);\n" - "$name$_.SetEntryDescriptor(\n" - " &$type$_descriptor_);\n"); + "$name$_.SetAssignDescriptorCallback(\n" + " protobuf_AssignDescriptorsOnce);\n" + "$name$_.SetEntryDescriptor(\n" + " &$type$_descriptor);\n"); } } void MapFieldGenerator:: +GenerateCopyConstructorCode(io::Printer* printer) const { + GenerateConstructorCode(printer); + GenerateMergingCode(printer); +} + +void MapFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { const FieldDescriptor* key_field = descriptor_->message_type()->FindFieldByName("key"); @@ -224,7 +230,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { "->AddLengthDelimited($number$, data);\n"); } else { printer->Print(variables_, - " unknown_fields_stream.WriteVarint32($tag$);\n" + " unknown_fields_stream.WriteVarint32($tag$u);\n" " unknown_fields_stream.WriteVarint32(data.size());\n" " unknown_fields_stream.WriteString(data);\n"); } @@ -252,7 +258,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { } static void GenerateSerializationLoop(io::Printer* printer, - const map<string, string>& variables, + const std::map<string, string>& variables, bool supports_arenas, const string& utf8_check, const string& loop_header, @@ -291,17 +297,17 @@ static void GenerateSerializationLoop(io::Printer* printer, void MapFieldGenerator:: GenerateSerializeWithCachedSizes(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["write_entry"] = "::google::protobuf::internal::WireFormatLite::Write" + variables["stream_writer"] + "(\n " + variables["number"] + ", *entry, output)"; - variables["deterministic"] = "output->IsSerializationDeterminstic()"; + variables["deterministic"] = "output->IsSerializationDeterministic()"; GenerateSerializeWithCachedSizes(printer, variables); } void MapFieldGenerator:: GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["write_entry"] = "target = ::google::protobuf::internal::WireFormatLite::\n" " InternalWrite" + variables["declared_type"] + @@ -312,7 +318,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { } void MapFieldGenerator::GenerateSerializeWithCachedSizes( - io::Printer* printer, const map<string, string>& variables) const { + io::Printer* printer, const std::map<string, string>& variables) const { printer->Print(variables, "if (!this->$name$().empty()) {\n"); printer->Indent(); diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.h b/src/google/protobuf/compiler/cpp/cpp_map_field.h index 2930fe59..816687b3 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.h @@ -55,6 +55,7 @@ class MapFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; @@ -63,11 +64,11 @@ class MapFieldGenerator : public FieldGenerator { private: // A helper for GenerateSerializeWithCachedSizes{,ToArray}. void GenerateSerializeWithCachedSizes( - io::Printer* printer, const map<string, string>& variables) const; + io::Printer* printer, const std::map<string, string>& variables) const; const FieldDescriptor* descriptor_; const bool dependent_field_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index efc56ddc..2b71acb5 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -207,7 +207,7 @@ class FieldGroup { } void SetPreferredLocation(float location) { preferred_location_ = location; } - const vector<const FieldDescriptor*>& fields() const { return fields_; } + const std::vector<const FieldDescriptor*>& fields() const { return fields_; } // FieldGroup objects sort by their preferred location. bool operator<(const FieldGroup& other) const { @@ -221,7 +221,7 @@ class FieldGroup { // approximate, but should put this group close to where its member fields // originally went. float preferred_location_; - vector<const FieldDescriptor*> fields_; + std::vector<const FieldDescriptor*> fields_; // We rely on the default copy constructor and operator= so this type can be // used in a vector. }; @@ -251,6 +251,39 @@ bool CanInitializeByZeroing(const FieldDescriptor* field) { } } +bool IsPOD(const FieldDescriptor* field) { + if (field->is_repeated() || field->is_extension()) return false; + switch (field->cpp_type()) { + case internal::WireFormatLite::CPPTYPE_ENUM: + case internal::WireFormatLite::CPPTYPE_INT32: + case internal::WireFormatLite::CPPTYPE_INT64: + case internal::WireFormatLite::CPPTYPE_UINT32: + case internal::WireFormatLite::CPPTYPE_UINT64: + case internal::WireFormatLite::CPPTYPE_FLOAT: + case internal::WireFormatLite::CPPTYPE_DOUBLE: + case internal::WireFormatLite::CPPTYPE_BOOL: + return true; + case internal::WireFormatLite::CPPTYPE_STRING: + return false; + default: + return false; + } +} + +// Helper for the code that emits the SharedCtor() method. +bool CanConstructByZeroing(const FieldDescriptor* field, + const Options& options) { + bool ret = CanInitializeByZeroing(field); + + // Non-repeated, non-lazy message fields are simply raw pointers, so we can + // use memset to initialize these in SharedCtor. We cannot use this in + // Clear, as we need to potentially delete the existing value. + ret = ret || + (!field->is_repeated() && + field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE); + return ret; +} + // Reorder 'fields' so that if the fields are output into a c++ class in the new // order, fields of similiar family (see below) are together and within each // family, alignment padding is minimized. @@ -260,9 +293,6 @@ bool CanInitializeByZeroing(const FieldDescriptor* field) { // 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. // @@ -275,30 +305,32 @@ bool CanInitializeByZeroing(const FieldDescriptor* field) { // 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. +// MessageFieldGenerator::GenerateConstructorCode), which allows them to be +// memset. // // ZERO_INITIALIZABLE is memset in Clear/SharedCtor // // OTHER these fields are initialized one-by-one. -void OptimizePadding(vector<const FieldDescriptor*>* fields) { +void OptimizePadding(std::vector<const FieldDescriptor*>* fields, + const Options& options) { // 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, + ZERO_INITIALIZABLE = 4, + OTHER = 5, kMaxFamily }; // First divide fields into those that align to 1 byte, 4 bytes or 8 bytes. - vector<FieldGroup> aligned_to_1[kMaxFamily]; - vector<FieldGroup> aligned_to_4[kMaxFamily]; - vector<FieldGroup> aligned_to_8[kMaxFamily]; + std::vector<FieldGroup> aligned_to_1[kMaxFamily]; + std::vector<FieldGroup> aligned_to_4[kMaxFamily]; + std::vector<FieldGroup> aligned_to_8[kMaxFamily]; for (int i = 0; i < fields->size(); ++i) { const FieldDescriptor* field = (*fields)[i]; @@ -309,6 +341,7 @@ void OptimizePadding(vector<const FieldDescriptor*>* fields) { f = STRING; } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { f = MESSAGE; + } else if (CanInitializeByZeroing(field)) { f = ZERO_INITIALIZABLE; } @@ -427,23 +460,9 @@ 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) { + std::map<string, string>* variables) { GOOGLE_CHECK(IsMapEntryMessage(descriptor)); const FieldDescriptor* key = descriptor->FindFieldByName("key"); const FieldDescriptor* val = descriptor->FindFieldByName("value"); @@ -475,6 +494,7 @@ bool HasPrivateHasMethod(const FieldDescriptor* field) { field->containing_oneof() != NULL); } + } // anonymous namespace // =================================================================== @@ -500,7 +520,33 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, optimized_order_.push_back(descriptor_->field(i)); } } - OptimizePadding(&optimized_order_); + OptimizePadding(&optimized_order_, options_); + + if (HasFieldPresence(descriptor_->file())) { + int has_bit_index = 0; + has_bit_indices_.resize(descriptor_->field_count(), -1); + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + // Skip fields that do not have has bits. + if (field->is_repeated()) { + continue; + } + + has_bit_indices_[field->index()] = has_bit_index; + has_bit_index++; + } + + // Assign fields that do not use has bits to be at the end. This can be + // removed once we shrink the has bits we assign. + // + // TODO(ckennelly): Shrink the has bits for these fields. + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* field = descriptor_->field(i); + if (has_bit_indices_[field->index()] < 0) { + has_bit_indices_[field->index()] = has_bit_index++; + } + } + } for (int i = 0; i < descriptor->nested_type_count(); i++) { nested_generators_[i].reset( @@ -534,48 +580,42 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, MessageGenerator::~MessageGenerator() {} -void MessageGenerator:: -FillMessageForwardDeclarations(map<string, const Descriptor*>* class_names) { - (*class_names)[classname_] = descriptor_; - - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // map entry message doesn't need forward declaration. Since map entry - // message cannot be a top level class, we just need to avoid calling - // GenerateForwardDeclaration here. - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->FillMessageForwardDeclarations(class_names); +size_t MessageGenerator::HasBitsSize() const { + // 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; } -} -void MessageGenerator:: -FillEnumForwardDeclarations(map<string, const EnumDescriptor*>* enum_names) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->FillEnumForwardDeclarations(enum_names); - } - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->FillForwardDeclaration(enum_names); - } + return sizeof_has_bits; } -void MessageGenerator:: -GenerateEnumDefinitions(io::Printer* printer) { +void MessageGenerator::Flatten(std::vector<MessageGenerator*>* list) { for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateEnumDefinitions(printer); + nested_generators_[i]->Flatten(list); } + list->push_back(this); +} +void MessageGenerator::AddGenerators( + std::vector<EnumGenerator*>* enum_generators, + std::vector<ExtensionGenerator*>* extension_generators) { for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->GenerateDefinition(printer); + enum_generators->push_back(enum_generators_[i].get()); + } + for (int i = 0; i < descriptor_->extension_count(); i++) { + extension_generators->push_back(extension_generators_[i].get()); } } -void MessageGenerator:: -GenerateGetEnumDescriptorSpecializations(io::Printer* printer) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); - } - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); - } +void MessageGenerator::FillMessageForwardDeclarations( + std::map<string, const Descriptor*>* class_names) { + if (IsMapEntryMessage(descriptor_)) return; + (*class_names)[classname_] = descriptor_; } void MessageGenerator:: @@ -585,7 +625,7 @@ GenerateDependentFieldAccessorDeclarations(io::Printer* printer) { PrintFieldComment(printer, field); - map<string, string> vars; + std::map<string, string> vars; SetCommonFieldVariables(field, &vars, options_); if (use_dependent_base_ && IsFieldDependent(field)) { @@ -607,7 +647,7 @@ GenerateFieldAccessorDeclarations(io::Printer* printer) { PrintFieldComment(printer, field); - map<string, string> vars; + std::map<string, string> vars; SetCommonFieldVariables(field, &vars, options_); vars["constant_name"] = FieldConstantName(field); @@ -679,6 +719,8 @@ GenerateDependentFieldAccessorDefinitions(io::Printer* printer) { for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); + if (field->options().weak()) continue; + PrintFieldComment(printer, field); // These functions are not really dependent: they are part of the @@ -688,7 +730,7 @@ GenerateDependentFieldAccessorDefinitions(io::Printer* printer) { // See the comment in FileGenerator::GenerateInlineFunctionDefinitions // for a more complete explanation. if (use_dependent_base_ && IsFieldDependent(field)) { - map<string, string> vars; + std::map<string, string> vars; SetCommonFieldVariables(field, &vars, options_); vars["inline"] = "inline "; if (field->containing_oneof()) { @@ -725,13 +767,16 @@ GenerateDependentFieldAccessorDefinitions(io::Printer* printer) { void MessageGenerator:: GenerateSingularFieldHasBits(const FieldDescriptor* field, - map<string, string> vars, + std::map<string, string> vars, io::Printer* printer) { if (HasFieldPresence(descriptor_->file())) { // N.B.: without field presence, we do not use has-bits or generate // has_$name$() methods. - vars["has_array_index"] = SimpleItoa(field->index() / 32); - vars["has_mask"] = StrCat(strings::Hex(1u << (field->index() % 32), + int has_bit_index = has_bit_indices_[field->index()]; + GOOGLE_CHECK_GE(has_bit_index, 0); + + vars["has_array_index"] = SimpleItoa(has_bit_index / 32); + vars["has_mask"] = StrCat(strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8)); printer->Print(vars, "$inline$" @@ -771,7 +816,7 @@ GenerateSingularFieldHasBits(const FieldDescriptor* field, void MessageGenerator:: GenerateOneofHasBits(io::Printer* printer, bool is_inline) { for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["oneof_name"] = descriptor_->oneof_decl(i)->name(); vars["oneof_index"] = SimpleItoa(descriptor_->oneof_decl(i)->index()); vars["cap_oneof_name"] = @@ -793,7 +838,7 @@ GenerateOneofHasBits(io::Printer* printer, bool is_inline) { void MessageGenerator:: GenerateOneofMemberHasBits(const FieldDescriptor* field, - const map<string, string>& vars, + const std::map<string, string>& vars, io::Printer* printer) { // Singular field in a oneof // N.B.: Without field presence, we do not use has-bits or generate @@ -815,7 +860,7 @@ GenerateOneofMemberHasBits(const FieldDescriptor* field, void MessageGenerator:: GenerateFieldClear(const FieldDescriptor* field, - const map<string, string>& vars, + const std::map<string, string>& vars, io::Printer* printer) { // Generate clear_$name$() (See GenerateFieldAccessorDeclarations and // GenerateDependentFieldAccessorDeclarations, $dependent_classname$ is @@ -863,7 +908,7 @@ GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline) { PrintFieldComment(printer, field); - map<string, string> vars; + std::map<string, string> vars; SetCommonFieldVariables(field, &vars, options_); vars["inline"] = is_inline ? "inline " : ""; if (use_dependent_base_ && IsFieldDependent(field)) { @@ -925,7 +970,7 @@ GenerateDependentBaseClassDefinition(io::Printer* printer) { return; } - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = DependentBaseClassTemplateName(descriptor_); vars["full_name"] = descriptor_->full_name(); vars["superclass"] = SuperClassName(descriptor_, options_); @@ -951,23 +996,13 @@ GenerateDependentBaseClassDefinition(io::Printer* printer) { void MessageGenerator:: GenerateClassDefinition(io::Printer* printer) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // map entry message doesn't need class definition. Since map entry message - // cannot be a top level class, we just need to avoid calling - // GenerateClassDefinition here. - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->GenerateClassDefinition(printer); - printer->Print("\n"); - printer->Print(kThinSeparator); - printer->Print("\n"); - } - + if (IsMapEntryMessage(descriptor_)) return; if (use_dependent_base_) { GenerateDependentBaseClassDefinition(printer); printer->Print("\n"); } - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = classname_; vars["full_name"] = descriptor_->full_name(); vars["field_count"] = SimpleItoa(descriptor_->field_count()); @@ -1007,44 +1042,19 @@ GenerateClassDefinition(io::Printer* printer) { "\n"); if (PreserveUnknownFields(descriptor_)) { - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n" - " return _internal_metadata_.unknown_fields();\n" - "}\n" - "\n" - "inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n" - " return _internal_metadata_.mutable_unknown_fields();\n" - "}\n" - "\n"); - } else { - if (SupportsArenas(descriptor_)) { - printer->Print( - "inline const ::std::string& unknown_fields() const {\n" - " return _unknown_fields_.Get(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n" - "}\n" - "\n" - "inline ::std::string* mutable_unknown_fields() {\n" - " return _unknown_fields_.Mutable(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n" - " GetArenaNoVirtual());\n" - "}\n" - "\n"); - } else { - printer->Print( - "inline const ::std::string& unknown_fields() const {\n" - " return _unknown_fields_.GetNoArena(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n" - "}\n" - "\n" - "inline ::std::string* mutable_unknown_fields() {\n" - " return _unknown_fields_.MutableNoArena(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n" - "}\n" - "\n"); - } - } + string type = UseUnknownFieldSet(descriptor_->file(), options_) + ? "::google::protobuf::UnknownFieldSet" + : "::std::string"; + printer->Print( + "inline const $type$& unknown_fields() const {\n" + " return _internal_metadata_.unknown_fields();\n" + "}\n" + "\n" + "inline $type$* mutable_unknown_fields() {\n" + " return _internal_metadata_.mutable_unknown_fields();\n" + "}\n" + "\n", + "type", type ); } // N.B.: We exclude GetArena() when arena support is disabled, falling back on @@ -1054,8 +1064,10 @@ GenerateClassDefinition(io::Printer* printer) { // virtual method version of GetArenaNoVirtual(), required for generic dispatch given a // MessageLite* (e.g., in RepeatedField::AddAllocated()). printer->Print( - "inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n" - "inline void* GetMaybeArenaPointer() const {\n" + "inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {\n" + " return GetArenaNoVirtual();\n" + "}\n" + "inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {\n" " return MaybeArenaPtr();\n" "}\n"); } @@ -1101,7 +1113,10 @@ GenerateClassDefinition(io::Printer* printer) { // TODO(gerbens) make this private, while still granting other protos access. printer->Print( vars, - "static const $classname$* internal_default_instance();\n" + "static inline const $classname$* internal_default_instance() {\n" + " return reinterpret_cast<const $classname$*>(\n" + " &_$classname$_default_instance_);\n" + "}\n" "\n"); @@ -1124,97 +1139,76 @@ GenerateClassDefinition(io::Printer* printer) { "\n"); } + vars["new_final"] = " PROTOBUF_FINAL"; + printer->Print(vars, "void Swap($classname$* other);\n" "\n" "// implements Message ----------------------------------------------\n" "\n" - "inline $classname$* New() const { return New(NULL); }\n" + "inline $classname$* New() const$new_final$ { return New(NULL); }\n" "\n" - "$classname$* New(::google::protobuf::Arena* arena) const;\n"); + "$classname$* New(::google::protobuf::Arena* arena) const$new_final$;\n"); + + // For instances that derive from Message (rather than MessageLite), some + // methods are virtual and should be marked as final. + string use_final = HasDescriptorMethods(descriptor_->file(), options_) ? + " PROTOBUF_FINAL" : ""; if (HasGeneratedMethods(descriptor_->file(), options_)) { if (HasDescriptorMethods(descriptor_->file(), options_)) { printer->Print(vars, - "void CopyFrom(const ::google::protobuf::Message& from);\n" - "void MergeFrom(const ::google::protobuf::Message& from);\n"); + "void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;\n" + "void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;\n"); } else { printer->Print(vars, - "void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);\n"); + "void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from)\n" + " PROTOBUF_FINAL;\n"); } - printer->Print(vars, - "void CopyFrom(const $classname$& from);\n" - "void MergeFrom(const $classname$& from);\n" - "void Clear();\n" - "bool IsInitialized() const;\n" - "\n" - "size_t ByteSizeLong() const;\n" - "bool MergePartialFromCodedStream(\n" - " ::google::protobuf::io::CodedInputStream* input);\n" - "void SerializeWithCachedSizes(\n" - " ::google::protobuf::io::CodedOutputStream* output) const;\n"); + vars["clear_final"] = " PROTOBUF_FINAL"; + vars["is_initialized_final"] = " PROTOBUF_FINAL"; + vars["merge_partial_final"] = " PROTOBUF_FINAL"; + + printer->Print( + vars, + "void CopyFrom(const $classname$& from);\n" + "void MergeFrom(const $classname$& from);\n" + "void Clear()$clear_final$;\n" + "bool IsInitialized() const$is_initialized_final$;\n" + "\n" + "size_t ByteSizeLong() const PROTOBUF_FINAL;\n" + "bool MergePartialFromCodedStream(\n" + " ::google::protobuf::io::CodedInputStream* input)$merge_partial_final$;\n" + "void SerializeWithCachedSizes(\n" + " ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;\n"); // DiscardUnknownFields() is implemented in message.cc using reflections. We // need to implement this function in generated code for messages. if (!UseUnknownFieldSet(descriptor_->file(), options_)) { printer->Print( - "void DiscardUnknownFields();\n"); + "void DiscardUnknownFields()$final$;\n", + "final", use_final); } if (HasFastArraySerialization(descriptor_->file(), options_)) { printer->Print( "::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n" - " bool deterministic, ::google::protobuf::uint8* output) const;\n" - "::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n" + " bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;\n" + "::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)\n" + " const PROTOBUF_FINAL {\n" " return InternalSerializeWithCachedSizesToArray(false, output);\n" "}\n"); } } - // Check all FieldDescriptors including those in oneofs to estimate - // whether ::std::string is likely to be used, and depending on that - // estimate, set uses_string_ to true or false. That contols - // whether to force initialization of empty_string_ in SharedCtor(). - // It's often advantageous to do so to keep "is empty_string_ - // inited?" code from appearing all over the place. - vector<const FieldDescriptor*> descriptors; - for (int i = 0; i < descriptor_->field_count(); i++) { - descriptors.push_back(descriptor_->field(i)); - } - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { - descriptors.push_back(descriptor_->oneof_decl(i)->field(j)); - } - } - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - const Descriptor* nested_type = descriptor_->nested_type(i); - if (IsMapEntryMessage(nested_type)) { - descriptors.push_back(nested_type->FindFieldByName("key")); - descriptors.push_back(nested_type->FindFieldByName("value")); - } - } - uses_string_ = false; - if (PreserveUnknownFields(descriptor_) && - !UseUnknownFieldSet(descriptor_->file(), options_)) { - uses_string_ = true; - } - for (int i = 0; i < descriptors.size(); i++) { - const FieldDescriptor* field = descriptors[i]; - if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { - switch (field->options().ctype()) { - default: uses_string_ = true; break; - } - } - } - printer->Print( - "int GetCachedSize() const { return _cached_size_; }\n" + "int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }\n" "private:\n" "void SharedCtor();\n" "void SharedDtor();\n" - "void SetCachedSize(int size) const;\n" - "void InternalSwap($classname$* other);\n" - "void UnsafeMergeFrom(const $classname$& from);\n", - "classname", classname_); + "void SetCachedSize(int size) const$final$;\n" + "void InternalSwap($classname$* other);\n", + "classname", classname_, + "final", use_final); if (SupportsArenas(descriptor_)) { printer->Print( "protected:\n" @@ -1225,7 +1219,7 @@ GenerateClassDefinition(io::Printer* printer) { "classname", classname_); } - if (UseUnknownFieldSet(descriptor_->file(), options_)) { + if (SupportsArenas(descriptor_)) { printer->Print( "private:\n" "inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n" @@ -1233,29 +1227,29 @@ GenerateClassDefinition(io::Printer* printer) { "}\n" "inline void* MaybeArenaPtr() const {\n" " return _internal_metadata_.raw_arena_ptr();\n" - "}\n" - "public:\n" - "\n"); + "}\n"); } else { printer->Print( "private:\n" "inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n" - " return _arena_ptr_;\n" - "}\n" - "inline ::google::protobuf::Arena* MaybeArenaPtr() const {\n" - " return _arena_ptr_;\n" + " return NULL;\n" "}\n" + "inline void* MaybeArenaPtr() const {\n" + " return NULL;\n" + "}\n"); + } + + printer->Print( "public:\n" "\n"); - } if (HasDescriptorMethods(descriptor_->file(), options_)) { printer->Print( - "::google::protobuf::Metadata GetMetadata() const;\n" + "::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;\n" "\n"); } else { printer->Print( - "::std::string GetTypeName() const;\n" + "::std::string GetTypeName() const PROTOBUF_FINAL;\n" "\n"); } @@ -1313,17 +1307,15 @@ GenerateClassDefinition(io::Printer* printer) { // messages without true field presence. if (HasFieldPresence(descriptor_->file()) || descriptor_->field(i)->containing_oneof()) { - printer->Print( - "inline void set_has_$name$();\n", - "name", FieldName(descriptor_->field(i))); + printer->Print("void set_has_$name$();\n", "name", + FieldName(descriptor_->field(i))); } // clear_has_***() generated only for non-oneof fields // in proto1/2. if (!descriptor_->field(i)->containing_oneof() && HasFieldPresence(descriptor_->file())) { - printer->Print( - "inline void clear_has_$name$();\n", - "name", FieldName(descriptor_->field(i))); + printer->Print("void clear_has_$name$();\n", "name", + FieldName(descriptor_->field(i))); } } } @@ -1353,7 +1345,7 @@ 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"; - const size_t sizeof_has_bits = HasBitsSize(descriptor_); + const size_t sizeof_has_bits = HasBitsSize(); const string has_bits_decl = sizeof_has_bits == 0 ? "" : "::google::protobuf::internal::HasBits<" + SimpleItoa(sizeof_has_bits / 4) + "> _has_bits_;\n"; @@ -1377,9 +1369,8 @@ GenerateClassDefinition(io::Printer* printer) { "::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n"); } else { printer->Print( - "::google::protobuf::internal::ArenaStringPtr _unknown_fields_;\n" - "::google::protobuf::Arena* _arena_ptr_;\n" - "\n"); + "::google::protobuf::internal::InternalMetadataWithArenaLite " + "_internal_metadata_;\n"); } if (SupportsArenas(descriptor_)) { @@ -1404,33 +1395,12 @@ GenerateClassDefinition(io::Printer* printer) { // Field members: - // List fields which doesn't belong to any oneof - 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); - fieldname_to_chunk[FieldName(field)] = i / 8; - } - } - // Emit some private and static members - runs_of_fields_ = vector< vector<string> >(1); 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 (CanInitializeByZeroing(field)) { - const string& fieldname = FieldName(field); - if (!runs_of_fields_.back().empty() && - (fieldname_to_chunk[runs_of_fields_.back().back()] != - fieldname_to_chunk[fieldname])) { - runs_of_fields_.push_back(vector<string>()); - } - runs_of_fields_.back().push_back(fieldname); - } else if (!runs_of_fields_.back().empty()) { - runs_of_fields_.push_back(vector<string>()); - } } // For each oneof generate a union @@ -1491,65 +1461,37 @@ GenerateClassDefinition(io::Printer* printer) { GlobalAddDescriptorsName(descriptor_->file()->name())); printer->Print( - "friend void $assigndescriptorsname$();\n" - "friend void $shutdownfilename$();\n" - "\n", - "assigndescriptorsname", - GlobalAssignDescriptorsName(descriptor_->file()->name()), - "shutdownfilename", GlobalShutdownFileName(descriptor_->file()->name())); - - printer->Print( - "void InitAsDefaultInstance();\n", - "classname", classname_); + "friend const ::google::protobuf::uint32* $offsetfunname$();\n" + "friend void $shutdownfilename$();\n" + "\n", + "offsetfunname", GlobalOffsetTableName(descriptor_->file()->name()), + "shutdownfilename", GlobalShutdownFileName(descriptor_->file()->name())); printer->Outdent(); - printer->Print("};\n"); - - // This should ideally be put into the class scope, but Visual Studio just - // refuses to compile it and complains about "use of undefined XXX": - // https://ci.appveyor.com/project/protobuf/protobuf/build/1.0.2673/job/nrdf4tb9dau0sck5 - // A program as simple as "struct X { enum { value = sizeof(X) }; };" will - // trigger the same error. - printer->Print( - "extern ::google::protobuf::internal::ExplicitlyConstructed<$classname$> " - "$classname$_default_instance_;\n", - "classname", classname_); - + printer->Print("};"); GOOGLE_DCHECK(!need_to_emit_cached_size); } void MessageGenerator:: GenerateDependentInlineMethods(io::Printer* printer) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // map entry message doesn't need inline methods. Since map entry message - // cannot be a top level class, we just need to avoid calling - // GenerateInlineMethods here. - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->GenerateDependentInlineMethods(printer); - printer->Print(kThinSeparator); - printer->Print("\n"); + if (IsMapEntryMessage(descriptor_)) return; + for (int i = 0; i < descriptor_->field_count(); i++) { + if (descriptor_->field(i)->options().weak()) { + field_generators_.get(descriptor_->field(i)) + .GenerateDependentInlineAccessorDefinitions(printer); + } } - GenerateDependentFieldAccessorDefinitions(printer); } void MessageGenerator:: GenerateInlineMethods(io::Printer* printer, bool is_inline) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // map entry message doesn't need inline methods. Since map entry message - // cannot be a top level class, we just need to avoid calling - // GenerateInlineMethods here. - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->GenerateInlineMethods(printer, is_inline); - printer->Print(kThinSeparator); - printer->Print("\n"); - } - + if (IsMapEntryMessage(descriptor_)) return; GenerateFieldAccessorDefinitions(printer, is_inline); // Generate oneof_case() functions. for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["class_name"] = classname_; vars["camel_oneof_name"] = UnderscoresToCamelCase( descriptor_->oneof_decl(i)->name(), true); @@ -1565,28 +1507,10 @@ GenerateInlineMethods(io::Printer* printer, bool is_inline) { "_oneof_case_[$oneof_index$]);\n" "}\n"); } - - printer->Print( - "inline const $classname$* $classname$::internal_default_instance() {\n" - " return &$classname$_default_instance_.get();\n" - "}\n", - "classname", classname_); } void MessageGenerator:: GenerateDescriptorDeclarations(io::Printer* printer) { - if (!IsMapEntryMessage(descriptor_)) { - printer->Print( - "const ::google::protobuf::Descriptor* $name$_descriptor_ = NULL;\n" - "const ::google::protobuf::internal::GeneratedMessageReflection*\n" - " $name$_reflection_ = NULL;\n", - "name", classname_); - } else { - printer->Print( - "const ::google::protobuf::Descriptor* $name$_descriptor_ = NULL;\n", - "name", classname_); - } - // Generate oneof default instance for reflection usage. if (descriptor_->oneof_decl_count() > 0) { printer->Print("struct $name$OneofInstance {\n", @@ -1604,140 +1528,31 @@ GenerateDescriptorDeclarations(io::Printer* printer) { } } - printer->Print("}* $name$_default_oneof_instance_ = NULL;\n", - "name", classname_); - } - - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateDescriptorDeclarations(printer); - } - - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - printer->Print( - "const ::google::protobuf::EnumDescriptor* $name$_descriptor_ = NULL;\n", - "name", ClassName(descriptor_->enum_type(i), false)); + printer->Print("} $name$_default_oneof_instance_;\n", "name", classname_); } } -void MessageGenerator:: -GenerateDescriptorInitializer(io::Printer* printer, int index) { - // TODO(kenton): Passing the index to this method is redundant; just use - // descriptor_->index() instead. - map<string, string> vars; - vars["classname"] = classname_; - vars["index"] = SimpleItoa(index); - - // Obtain the descriptor from the parent's descriptor. - if (descriptor_->containing_type() == NULL) { - printer->Print(vars, - "$classname$_descriptor_ = file->message_type($index$);\n"); - } else { - vars["parent"] = ClassName(descriptor_->containing_type(), false); - printer->Print(vars, - "$classname$_descriptor_ = " - "$parent$_descriptor_->nested_type($index$);\n"); - } - +void MessageGenerator::GenerateSchema(io::Printer* printer, int offset, + int has_offset) { if (IsMapEntryMessage(descriptor_)) return; - // Generate the offsets. - GenerateOffsets(printer); + std::map<string, string> vars; - const bool pass_pool_and_factory = false; - vars["fn"] = pass_pool_and_factory ? - "new ::google::protobuf::internal::GeneratedMessageReflection" : - "::google::protobuf::internal::GeneratedMessageReflection" - "::NewGeneratedMessageReflection"; - // Construct the reflection object. - printer->Print(vars, - "$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_),\n"); - } - - // Unknown field offset: either points to the unknown field set if embedded - // directly, or indicates that the unknown field set is stored as part of the - // internal metadata if not. - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print(vars, - " -1,\n"); - } else { - printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _unknown_fields_),\n"); - } - - if (descriptor_->extension_range_count() > 0) { - printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _extensions_),\n"); - } else { - // No extensions. - printer->Print(vars, - " -1,\n"); - } - - if (descriptor_->oneof_decl_count() > 0) { - printer->Print(vars, - " $classname$_default_oneof_instance_,\n" - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _oneof_case_[0]),\n"); - } - - if (pass_pool_and_factory) { - printer->Print( - " ::google::protobuf::DescriptorPool::generated_pool(),\n"); - printer->Print(vars, - " ::google::protobuf::MessageFactory::generated_factory(),\n"); - } + vars["classname"] = classname_; + vars["offset"] = SimpleItoa(offset); + vars["has_bits_offsets"] = HasFieldPresence(descriptor_->file()) + ? SimpleItoa(offset + has_offset) + : "-1"; printer->Print(vars, - " sizeof($classname$),\n"); - - // Arena offset: either an offset to the metadata struct that contains the - // arena pointer and unknown field set (in a space-efficient way) if we use - // that implementation strategy, or an offset directly to the arena pointer if - // 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"); - } else { - printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _arena_));\n"); - } - - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateDescriptorInitializer(printer, i); - } - - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->GenerateDescriptorInitializer(printer, i); - } + "{ $offset$, $has_bits_offsets$, sizeof($classname$)},\n"); } void MessageGenerator:: 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$::internal_default_instance());\n", - "classname", classname_); - } else { - map<string, string> vars; + if (IsMapEntryMessage(descriptor_)) { + std::map<string, string> vars; CollectMapInfo(descriptor_, &vars); vars["classname"] = classname_; @@ -1750,31 +1565,27 @@ GenerateTypeRegistrations(io::Printer* printer) { vars["default_enum_value"] = "0"; } - printer->Print(vars, - "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n" - " $classname$_descriptor_,\n" - " ::google::protobuf::internal::MapEntry<\n" - " $key$,\n" - " $val$,\n" - " $key_wire_type$,\n" - " $val_wire_type$,\n" - " $default_enum_value$>::CreateDefaultInstance(\n" - " $classname$_descriptor_));\n"); - } - - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateTypeRegistrations(printer); + vars["index_in_metadata"] = SimpleItoa(index_in_metadata_); + + printer->Print( + vars, + "const ::google::protobuf::Descriptor* $classname$_descriptor = " + "file_level_metadata[$index_in_metadata$].descriptor;\n" + "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n" + " $classname$_descriptor,\n" + " ::google::protobuf::internal::MapEntry<\n" + " $key$,\n" + " $val$,\n" + " $key_wire_type$,\n" + " $val_wire_type$,\n" + " $default_enum_value$>::CreateDefaultInstance(\n" + " $classname$_descriptor));\n"); } } 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()); + if (IsMapEntryMessage(descriptor_)) return; // Construct the default instances of all fields, as they will be used // when creating the default instance of the entire message. @@ -1783,64 +1594,60 @@ GenerateDefaultInstanceAllocator(io::Printer* printer) { .GenerateDefaultInstanceAllocator(printer); } - if (IsMapEntryMessage(descriptor_)) return; - // 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_.DefaultConstruct();\n", + printer->Print("_$classname$_default_instance_.DefaultConstruct();\n", "classname", classname_); - - if ((descriptor_->oneof_decl_count() > 0) && - HasDescriptorMethods(descriptor_->file(), options_)) { - printer->Print( - "$classname$_default_oneof_instance_ = new $classname$OneofInstance();\n", - "classname", classname_); - } - - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateDefaultInstanceAllocator(printer); - } - } void MessageGenerator:: GenerateDefaultInstanceInitializer(io::Printer* printer) { - printer->Print( - "$classname$_default_instance_.get_mutable()->InitAsDefaultInstance();" - "\n", - "classname", classname_); + if (IsMapEntryMessage(descriptor_)) return; - // Register extensions. - for (int i = 0; i < descriptor_->extension_count(); i++) { - extension_generators_[i]->GenerateRegistration(printer); - } + // 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 + // constructed yet at that time. + // TODO(kenton): Maybe all message fields (even for non-default messages) + // should be initialized to point at default instances rather than NULL? + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* field = descriptor_->field(i); - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // map entry message doesn't need to initialize default instance manually. - // Since map entry message cannot be a top level class, we just need to - // avoid calling DefaultInstanceInitializer here. - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->GenerateDefaultInstanceInitializer(printer); + if (!field->is_repeated() && + field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + (field->containing_oneof() == NULL || + HasDescriptorMethods(descriptor_->file(), options_))) { + string name; + if (field->containing_oneof()) { + name = classname_ + "_default_oneof_instance_."; + } else { + name = "_" + classname_ + "_default_instance_.get_mutable()->"; + } + name += FieldName(field); + printer->Print( + "$name$_ = const_cast< $type$*>(\n" + " $type$::internal_default_instance());\n", + // Vars. + "name", name, "type", FieldMessageTypeName(field)); + } else if (field->containing_oneof() && + HasDescriptorMethods(descriptor_->file(), options_)) { + field_generators_.get(descriptor_->field(i)) + .GenerateConstructorCode(printer); + } } } void MessageGenerator:: GenerateShutdownCode(io::Printer* printer) { - printer->Print( - "$classname$_default_instance_.Shutdown();\n", - "classname", classname_); + if (IsMapEntryMessage(descriptor_)) return; + + printer->Print("_$classname$_default_instance_.Shutdown();\n", "classname", + classname_); + if (HasDescriptorMethods(descriptor_->file(), options_)) { - if (descriptor_->oneof_decl_count() > 0) { - printer->Print( - "delete $classname$_default_oneof_instance_;\n", - "classname", classname_); - } - printer->Print( - "delete $classname$_reflection_;\n", - "classname", classname_); + printer->Print("delete file_level_metadata[$index$].reflection;\n", "index", + SimpleItoa(index_in_metadata_)); } // Handle default instances of fields. @@ -1848,16 +1655,12 @@ GenerateShutdownCode(io::Printer* printer) { field_generators_.get(descriptor_->field(i)) .GenerateShutdownCode(printer); } - - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->GenerateShutdownCode(printer); - } } void MessageGenerator:: GenerateClassMethods(io::Printer* printer) { + if (IsMapEntryMessage(descriptor_)) return; + // mutable_unknown_fields wrapper function for LazyStringOutputStream // callback. if (PreserveUnknownFields(descriptor_) && @@ -1888,21 +1691,6 @@ GenerateClassMethods(io::Printer* printer) { "classname", classname_); } - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->GenerateMethods(printer); - } - - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // map entry message doesn't need class methods. Since map entry message - // cannot be a top level class, we just need to avoid calling - // GenerateClassMethods here. - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->GenerateClassMethods(printer); - printer->Print("\n"); - printer->Print(kThinSeparator); - printer->Print("\n"); - } - // Generate non-inline field definitions. for (int i = 0; i < descriptor_->field_count(); i++) { field_generators_.get(descriptor_->field(i)) @@ -1922,11 +1710,6 @@ GenerateClassMethods(io::Printer* printer) { "#endif // !defined(_MSC_VER) || _MSC_VER >= 1900\n" "\n"); - // Define extension identifiers. - for (int i = 0; i < descriptor_->extension_count(); i++) { - extension_generators_[i]->GenerateDefinition(printer); - } - GenerateStructors(printer); printer->Print("\n"); @@ -1961,12 +1744,6 @@ 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); @@ -1974,15 +1751,12 @@ GenerateClassMethods(io::Printer* printer) { if (HasDescriptorMethods(descriptor_->file(), options_)) { printer->Print( - "::google::protobuf::Metadata $classname$::GetMetadata() const {\n" - " protobuf_AssignDescriptorsOnce();\n" - " ::google::protobuf::Metadata metadata;\n" - " metadata.descriptor = $classname$_descriptor_;\n" - " metadata.reflection = $classname$_reflection_;\n" - " return metadata;\n" - "}\n" - "\n", - "classname", classname_); + "::google::protobuf::Metadata $classname$::GetMetadata() const {\n" + " protobuf_AssignDescriptorsOnce();\n" + " return file_level_metadata[$index$];\n" + "}\n" + "\n", + "classname", classname_, "index", SimpleItoa(index_in_metadata_)); } else { printer->Print( "::std::string $classname$::GetTypeName() const {\n" @@ -1995,22 +1769,49 @@ GenerateClassMethods(io::Printer* printer) { } -void MessageGenerator:: -GenerateOffsets(io::Printer* printer) { - printer->Print("static const int $classname$_offsets_[$field_count$] = {\n", - "classname", classname_, "field_count", - SimpleItoa(std::max(1, descriptor_->field_count() + - descriptor_->oneof_decl_count()))); - printer->Indent(); +std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( + io::Printer* printer) { + if (IsMapEntryMessage(descriptor_)) return std::make_pair(0, 0); + std::map<string, string> variables; + variables["classname"] = classname_; + if (HasFieldPresence(descriptor_->file())) { + printer->Print( + variables, + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _has_bits_),\n"); + } else { + printer->Print("~0u, // no _has_bits_\n"); + } + printer->Print(variables, + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, " + "_internal_metadata_),\n"); + if (descriptor_->extension_range_count() > 0) { + printer->Print( + variables, + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _extensions_),\n"); + } else { + printer->Print("~0u, // no _extensions_\n"); + } + if (descriptor_->oneof_decl_count() > 0) { + printer->Print(variables, + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, " + "_oneof_case_[0]),\n"); + } else { + printer->Print("~0u, // no _oneof_case_\n"); + } + + const int kNumGenericOffsets = 4; // the number of fixed offsets above + const size_t offsets = kNumGenericOffsets + + descriptor_->field_count() + + descriptor_->oneof_decl_count(); + size_t entries = offsets; for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); if (field->containing_oneof()) { printer->Print( "PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(" - "$classname$_default_oneof_instance_, $name$_),\n", - "classname", classname_, - "name", FieldName(field)); + "(&$classname$_default_oneof_instance_), $name$_),\n", + "classname", classname_, "name", FieldName(field)); } else { printer->Print( "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, " @@ -2028,8 +1829,14 @@ GenerateOffsets(io::Printer* printer) { "name", oneof->name()); } - printer->Outdent(); - printer->Print("};\n"); + if (HasFieldPresence(descriptor_->file())) { + entries += has_bit_indices_.size(); + for (int i = 0; i < has_bit_indices_.size(); i++) { + printer->Print("$index$,\n", "index", SimpleItoa(has_bit_indices_[i])); + } + } + + return std::make_pair(entries, offsets); } void MessageGenerator:: @@ -2043,66 +1850,26 @@ GenerateSharedConstructorCode(io::Printer* printer) { // 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) { + (HasBitsSize() % 8) != 0) { printer->Print("_cached_size_ = 0;\n"); need_to_clear_cached_size = false; } - if (PreserveUnknownFields(descriptor_) && - !UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "_unknown_fields_.UnsafeSetDefault(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n"); - } - - 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; - } - } - - 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]); - + // TODO(gerbens) Clean this hack, and why do i need a reference to a pointer?? + for (int i = 0; i < descriptor_->nested_type_count(); i++) { + if (HasDescriptorMethods(descriptor_->file(), options_) && + IsMapEntryMessage(descriptor_->nested_type(i))) { 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); + "const ::google::protobuf::Descriptor*& $type$_descriptor = " + "file_level_metadata[$index$].descriptor;\n", + "type", ClassName(descriptor_->nested_type(i), false), "index", + SimpleItoa(nested_generators_[i]->index_in_metadata_)); } } + std::vector<bool> processed(optimized_order_.size(), false); + GenerateConstructorBody(printer, processed, false); + for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { printer->Print( "clear_has_$oneof_name$();\n", @@ -2133,21 +1900,6 @@ GenerateSharedDestructorCode(io::Printer* printer) { "\n"); } - // Write the desctructor for _unknown_fields_ in lite runtime. - if (PreserveUnknownFields(descriptor_) && - !UseUnknownFieldSet(descriptor_->file(), options_)) { - if (SupportsArenas(descriptor_)) { - printer->Print( - "_unknown_fields_.Destroy(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n" - " arena);\n"); - } else { - printer->Print( - "_unknown_fields_.DestroyNoArena(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n"); - } - } - // Write the destructors for each field except oneof members. // optimized_order_ does not contain oneof fields. for (int i = 0; i < optimized_order_.size(); i++) { @@ -2164,35 +1916,6 @@ GenerateSharedDestructorCode(io::Printer* printer) { "oneof_name", descriptor_->oneof_decl(i)->name()); } - // 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 - // MessageFieldGenerator::GenerateDestructorCode(). - bool need_delete_message_field = false; - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - if (!field->is_repeated() && - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - // Skip oneof members - if (!field->containing_oneof()) { - if (!need_delete_message_field) { - need_delete_message_field = true; - printer->Print( - "if (this != &$classname$_default_instance_.get()) {\n", - "classname", classname_); - printer->Indent(); - } - printer->Print("delete $name$_;\n", "name", FieldName(field)); - } - } - } - if (need_delete_message_field) { - printer->Outdent(); - printer->Print( - "}\n"); - } - printer->Outdent(); printer->Print( "}\n" @@ -2219,12 +1942,31 @@ GenerateArenaDestructorCode(io::Printer* printer) { "classname", classname_); bool need_registration = false; - for (int i = 0; i < descriptor_->field_count(); i++) { - if (field_generators_.get(descriptor_->field(i)) + // Process non-oneof fields first. + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + if (field_generators_.get(field) .GenerateArenaDestructorCode(printer)) { need_registration = true; } } + + // Process oneof fields. + // + // Note: As of 10/5/2016, GenerateArenaDestructorCode does not emit anything + // and returns false for oneof fields. + for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { + const OneofDescriptor* oneof = descriptor_->oneof_decl(i); + + for (int j = 0; j < oneof->field_count(); j++) { + const FieldDescriptor* field = oneof->field(j); + if (field_generators_.get(field) + .GenerateArenaDestructorCode(printer)) { + need_registration = true; + } + } + } + printer->Outdent(); printer->Print( "}\n"); @@ -2245,6 +1987,75 @@ GenerateArenaDestructorCode(io::Printer* printer) { } } +void MessageGenerator::GenerateConstructorBody(io::Printer* printer, + std::vector<bool> processed, + bool copy_constructor) const { + 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]; + if ((copy_constructor && IsPOD(field)) || + (!copy_constructor && CanConstructByZeroing(field, options_))) { + if (last_start == NULL) { + last_start = field; + } + + runs[last_start]++; + } else { + last_start = NULL; + } + } + + string pod_template; + if (copy_constructor) { + pod_template = + "::memcpy(&$first$_, &from.$first$_,\n" + " reinterpret_cast<char*>(&$last$_) -\n" + " reinterpret_cast<char*>(&$first$_) + sizeof($last$_));\n"; + } else { + pod_template = + "::memset(&$first$_, 0, reinterpret_cast<char*>(&$last$_) -\n" + " reinterpret_cast<char*>(&$first$_) + sizeof($last$_));\n"; + } + + for (int i = 0; i < optimized_order_.size(); ++i) { + if (processed[i]) { + continue; + } + + 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(pod_template.c_str(), + "first", first_field_name, + "last", last_field_name); + + i += run_length - 1; + // ++i at the top of the loop. + } else { + if (copy_constructor) { + field_generators_.get(field).GenerateCopyConstructorCode(printer); + } else { + field_generators_.get(field).GenerateConstructorCode(printer); + } + } + } +} + void MessageGenerator:: GenerateStructors(io::Printer* printer) { string superclass; @@ -2260,11 +2071,7 @@ GenerateStructors(io::Printer* printer) { initializer_with_arena += ",\n _extensions_(arena)"; } - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - initializer_with_arena += ",\n _internal_metadata_(arena)"; - } else { - initializer_with_arena += ",\n _arena_ptr_(arena)"; - } + initializer_with_arena += ",\n _internal_metadata_(arena)"; // Initialize member variables with arena constructor. for (int i = 0; i < optimized_order_.size(); i++) { @@ -2282,8 +2089,7 @@ GenerateStructors(io::Printer* printer) { } string initializer_null; - initializer_null = (UseUnknownFieldSet(descriptor_->file(), options_) ? - ", _internal_metadata_(NULL)" : ", _arena_ptr_(NULL)"); + initializer_null = ", _internal_metadata_(NULL)"; if (IsAnyMessage(descriptor_)) { initializer_null += ", _any_metadata_(&type_url_, &value_)"; } @@ -2291,7 +2097,9 @@ GenerateStructors(io::Printer* printer) { printer->Print( "$classname$::$classname$()\n" " : $superclass$()$initializer$ {\n" - " if (this != internal_default_instance()) $initdefaultsname$();\n" + " if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {\n" + " $initdefaultsname$();\n" + " }\n" " SharedCtor();\n" " // @@protoc_insertion_point(constructor:$full_name$)\n" "}\n", @@ -2318,44 +2126,6 @@ GenerateStructors(io::Printer* printer) { GlobalInitDefaultsName(descriptor_->file()->name())); } - printer->Print( - "\n" - "void $classname$::InitAsDefaultInstance() {\n", - "classname", classname_); - - // 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 - // constructed yet at that time. - // TODO(kenton): Maybe all message fields (even for non-default messages) - // should be initialized to point at default instances rather than NULL? - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - if (!field->is_repeated() && - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - (field->containing_oneof() == NULL || - HasDescriptorMethods(descriptor_->file(), options_))) { - string name; - if (field->containing_oneof()) { - name = classname_ + "_default_oneof_instance_->"; - } - name += FieldName(field); - printer->Print( - " $name$_ = const_cast< $type$*>(\n" - " $type$::internal_default_instance());\n", - // Vars. - "name", name, "type", FieldMessageTypeName(field)); - } else if (field->containing_oneof() && - HasDescriptorMethods(descriptor_->file(), options_)) { - field_generators_.get(descriptor_->field(i)) - .GenerateConstructorCode(printer); - } - } - printer->Print( - "}\n" - "\n"); - // Generate the copy constructor. printer->Print( "$classname$::$classname$(const $classname$& from)\n" @@ -2363,24 +2133,113 @@ GenerateStructors(io::Printer* printer) { "classname", classname_, "superclass", superclass, "full_name", descriptor_->full_name()); - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - ",\n _internal_metadata_(NULL)"); - } else if (!UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print(",\n _arena_ptr_(NULL)"); + printer->Indent(); + printer->Indent(); + printer->Indent(); + + printer->Print( + ",\n_internal_metadata_(NULL)"); + + if (HasFieldPresence(descriptor_->file())) { + printer->Print(",\n_has_bits_(from._has_bits_)"); + } + + bool need_to_emit_cached_size = true; + const string cached_size_decl = ",\n_cached_size_(0)"; + // 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() % 8) != 0) { + printer->Print(cached_size_decl.c_str()); + need_to_emit_cached_size = false; } + + std::vector<bool> processed(optimized_order_.size(), false); + for (int i = 0; i < optimized_order_.size(); ++i) { + const FieldDescriptor* field = optimized_order_[i]; + + if (!(field->is_repeated() && !(field->is_map())) + ) { + continue; + } + + processed[i] = true; + printer->Print(",\n$name$_(from.$name$_)", + "name", FieldName(field)); + } + + if (need_to_emit_cached_size) { + printer->Print(cached_size_decl.c_str()); + need_to_emit_cached_size = false; + } + if (IsAnyMessage(descriptor_)) { - printer->Print(",\n _any_metadata_(&type_url_, &value_)"); + printer->Print(",\n_any_metadata_(&type_url_, &value_)"); } + + printer->Outdent(); + printer->Outdent(); printer->Print(" {\n"); + + printer->Print( + "_internal_metadata_.MergeFrom(from._internal_metadata_);\n"); + + if (descriptor_->extension_range_count() > 0) { + printer->Print("_extensions_.MergeFrom(from._extensions_);\n"); + } + + // TODO(gerbens) Clean this hack, and why do i need a reference to a pointer?? + for (int i = 0; i < descriptor_->nested_type_count(); i++) { + if (HasDescriptorMethods(descriptor_->file(), options_) && + IsMapEntryMessage(descriptor_->nested_type(i))) { + printer->Print( + "const ::google::protobuf::Descriptor*& $type$_descriptor = " + "file_level_metadata[$index$].descriptor;\n", + "type", ClassName(descriptor_->nested_type(i), false), "index", + SimpleItoa(nested_generators_[i]->index_in_metadata_)); + } + } + + GenerateConstructorBody(printer, processed, true); + + // Copy oneof fields. Oneof field requires oneof case check. + for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) { + printer->Print( + "clear_has_$oneofname$();\n" + "switch (from.$oneofname$_case()) {\n", + "oneofname", descriptor_->oneof_decl(i)->name()); + printer->Indent(); + for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { + const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + printer->Print( + "case k$field_name$: {\n", + "field_name", UnderscoresToCamelCase(field->name(), true)); + printer->Indent(); + field_generators_.get(field).GenerateMergingCode(printer); + printer->Print( + "break;\n"); + printer->Outdent(); + printer->Print( + "}\n"); + } + printer->Print( + "case $cap_oneof_name$_NOT_SET: {\n" + " break;\n" + "}\n", + "oneof_index", + SimpleItoa(descriptor_->oneof_decl(i)->index()), + "cap_oneof_name", + ToUpper(descriptor_->oneof_decl(i)->name())); + printer->Outdent(); + printer->Print( + "}\n"); + } + + printer->Outdent(); printer->Print( - " SharedCtor();\n" - " UnsafeMergeFrom(from);\n" " // @@protoc_insertion_point(copy_constructor:$full_name$)\n" "}\n" "\n", - "classname", classname_, - "superclass", superclass, "full_name", descriptor_->full_name()); // Generate the shared constructor code. @@ -2419,28 +2278,20 @@ GenerateStructors(io::Printer* printer) { printer->Print( "const ::google::protobuf::Descriptor* $classname$::descriptor() {\n" " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" + " return file_level_metadata[$index$].descriptor;\n" "}\n" "\n", - "classname", classname_, "initdefaultsname", - GlobalInitDefaultsName(descriptor_->file()->name())); + "index", SimpleItoa(index_in_metadata_), "classname", classname_); } printer->Print( "const $classname$& $classname$::default_instance() {\n" " $initdefaultsname$();\n" " return *internal_default_instance();\n" - "}\n", + "}\n\n", "classname", classname_, "initdefaultsname", GlobalInitDefaultsName(descriptor_->file()->name())); - printer->Print( - "\n" - "::google::protobuf::internal::ExplicitlyConstructed<$classname$> " - "$classname$_default_instance_;\n" - "\n", - "classname", classname_); - if (SupportsArenas(descriptor_)) { printer->Print( "$classname$* $classname$::New(::google::protobuf::Arena* arena) const {\n" @@ -2484,154 +2335,173 @@ GenerateClear(io::Printer* printer) { printer->Print("_extensions_.Clear();\n"); } - // Step 2: Everything but extensions, repeateds, unions. - // These are handled in chunks of 8. The first chunk is - // the non-extensions-non-repeateds-non-unions in - // descriptor_->field(0), descriptor_->field(1), ... descriptor_->field(7), - // and the second chunk is the same for - // descriptor_->field(8), descriptor_->field(9), ... descriptor_->field(15), - // etc. - set<int> step2_indices; - hash_map<string, int> fieldname_to_chunk; - hash_map<int, string> memsets_for_chunk; - hash_map<int, int> memset_field_count_for_chunk; - hash_set<string> handled; // fields that appear anywhere in memsets_for_chunk - hash_map<int, uint32> fields_mask_for_chunk; - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (!field->is_repeated() && !field->containing_oneof()) { - step2_indices.insert(i); - int chunk = i / 8; - fieldname_to_chunk[FieldName(field)] = chunk; - fields_mask_for_chunk[chunk] |= static_cast<uint32>(1) << (i % 32); - } - } - - // Step 2a: Greedily seek runs of fields that can be cleared by memset-to-0. - // The generated code uses two macros to help it clear runs of fields: - // ZR_HELPER_(f1) - ZR_HELPER_(f0) computes the difference, in bytes, of the - // positions of two fields in the Message. - // ZR_ zeroes a non-empty range of fields via memset. - const char* macros = - "#if defined(__clang__)\n" - "#define ZR_HELPER_(f) \\\n" - " _Pragma(\"clang diagnostic push\") \\\n" - " _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n" - " __builtin_offsetof($classname$, f) \\\n" - " _Pragma(\"clang diagnostic pop\")\n" - "#else\n" - "#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n" - " &reinterpret_cast<$classname$*>(16)->f)\n" - "#endif\n\n" - "#define ZR_(first, last) do {\\\n" - " ::memset(&(first), 0,\\\n" - " ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n" - "} while (0)\n\n"; - for (int i = 0; i < runs_of_fields_.size(); i++) { - const vector<string>& run = runs_of_fields_[i]; - if (run.size() < 2) continue; - const string& first_field_name = run[0]; - const string& last_field_name = run.back(); - int chunk = fieldname_to_chunk[run[0]]; - memsets_for_chunk[chunk].append( - "ZR_(" + first_field_name + "_, " + last_field_name + "_);\n"); - for (int j = 0; j < run.size(); j++) { - GOOGLE_DCHECK_EQ(chunk, fieldname_to_chunk[run[j]]); - handled.insert(run[j]); - } - memset_field_count_for_chunk[chunk] += run.size(); - } - const bool macros_are_needed = handled.size() > 0; - if (macros_are_needed) { - printer->Outdent(); - printer->Print(macros, - "classname", classname_); - printer->Indent(); - } - // Step 2b: Finish step 2, ignoring fields handled in step 2a. - int last_index = -1; - bool chunk_block_in_progress = false; - for (int i = 0; i < descriptor_->field_count(); i++) { - if (step2_indices.count(i) == 0) continue; - const FieldDescriptor* field = descriptor_->field(i); - const string fieldname = FieldName(field); - if (i / 8 != last_index / 8 || last_index < 0) { - // End previous chunk, if there was one. - if (chunk_block_in_progress) { - printer->Outdent(); - printer->Print("}\n"); - chunk_block_in_progress = false; + int last_i = -1; + for (int i = 0; i < optimized_order_.size(); ) { + // Detect infinite loops. + GOOGLE_CHECK_NE(i, last_i); + last_i = i; + + // Step 2: Repeated fields don't use _has_bits_; emit code to clear them + // here. + for (; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + const FieldGenerator& generator = field_generators_.get(field); + + if (!field->is_repeated()) { + break; } - // Start chunk. - const string& memsets = memsets_for_chunk[i / 8]; - uint32 mask = fields_mask_for_chunk[i / 8]; - int count = popcnt(mask); - GOOGLE_DCHECK_GE(count, 1); - if (count == 1 || - count == memset_field_count_for_chunk[i / 8]) { - // No "if" here because the chunk is trivial. + + if (use_dependent_base_ && IsFieldDependent(field)) { + printer->Print("clear_$name$();\n", "name", FieldName(field)); } else { - if (HasFieldPresence(descriptor_->file())) { - printer->Print( - "if (_has_bits_[$index$ / 32] & $mask$u) {\n", - "index", SimpleItoa(i / 8 * 8), - "mask", SimpleItoa(mask)); - printer->Indent(); - chunk_block_in_progress = true; - } + generator.GenerateMessageClearingCode(printer); } - printer->Print(memsets.c_str()); - } - last_index = i; - if (handled.count(fieldname) > 0) continue; - - // It's faster to just overwrite primitive types, but we should - // only clear strings and messages if they were set. - // TODO(kenton): Let the CppFieldGenerator decide this somehow. - bool should_check_bit = - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || - field->cpp_type() == FieldDescriptor::CPPTYPE_STRING; - - bool have_enclosing_if = false; - if (should_check_bit && - // If no field presence, then always clear strings/messages as well. - HasFieldPresence(descriptor_->file())) { - printer->Print("if (has_$name$()) {\n", "name", fieldname); - printer->Indent(); - have_enclosing_if = true; } - if (use_dependent_base_ && IsFieldDependent(field)) { - printer->Print("clear_$name$();\n", "name", fieldname); - } else { - field_generators_.get(field).GenerateClearingCode(printer); + // Step 3: Greedily seek runs of fields that can be cleared by + // memset-to-0. + int last_chunk = -1; + int last_chunk_start = -1; + int last_chunk_end = -1; + uint32 last_chunk_mask = 0; + + int memset_run_start = -1; + int memset_run_end = -1; + for (; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + + if (!CanInitializeByZeroing(field)) { + break; + } + + // "index" defines where in the _has_bits_ the field appears. + // "i" is our loop counter within optimized_order_. + int index = HasFieldPresence(descriptor_->file()) ? + has_bit_indices_[field->index()] : 0; + int chunk = index / 8; + + if (last_chunk == -1) { + last_chunk = chunk; + last_chunk_start = i; + } else if (chunk != last_chunk) { + // Emit the fields for this chunk so far. + break; + } + + if (memset_run_start == -1) { + memset_run_start = i; + } + + memset_run_end = i; + last_chunk_end = i; + last_chunk_mask |= static_cast<uint32>(1) << (index % 32); } - if (have_enclosing_if) { - printer->Outdent(); - printer->Print("}\n"); + // Step 4: Non-repeated, non-zero initializable fields. + for (; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + if (field->is_repeated() || CanInitializeByZeroing(field)) { + break; + } + + // "index" defines where in the _has_bits_ the field appears. + // "i" is our loop counter within optimized_order_. + int index = HasFieldPresence(descriptor_->file()) ? + has_bit_indices_[field->index()] : 0; + int chunk = index / 8; + + if (last_chunk == -1) { + last_chunk = chunk; + last_chunk_start = i; + } else if (chunk != last_chunk) { + // Emit the fields for this chunk so far. + break; + } + + last_chunk_end = i; + last_chunk_mask |= static_cast<uint32>(1) << (index % 32); } - } - if (chunk_block_in_progress) { - printer->Outdent(); - printer->Print("}\n"); - } - if (macros_are_needed) { - printer->Outdent(); - printer->Print("\n#undef ZR_HELPER_\n#undef ZR_\n\n"); - printer->Indent(); - } + if (last_chunk != -1) { + GOOGLE_DCHECK_NE(-1, last_chunk_start); + GOOGLE_DCHECK_NE(-1, last_chunk_end); + GOOGLE_DCHECK_NE(0, last_chunk_mask); - // Step 3: Repeated fields don't use _has_bits_; emit code to clear them here. - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + const int count = popcnt(last_chunk_mask); + const bool have_outer_if = HasFieldPresence(descriptor_->file()) && + (last_chunk_start != last_chunk_end); - if (field->is_repeated()) { - if (use_dependent_base_ && IsFieldDependent(field)) { - printer->Print("clear_$name$();\n", "name", FieldName(field)); - } else { - field_generators_.get(field).GenerateClearingCode(printer); + if (have_outer_if) { + // Check (up to) 8 has_bits at a time if we have more than one field in + // this chunk. Due to field layout ordering, we may check + // _has_bits_[last_chunk * 8 / 32] multiple times. + GOOGLE_DCHECK_LE(2, count); + GOOGLE_DCHECK_GE(8, count); + + printer->Print( + "if (_has_bits_[$index$ / 32] & $mask$u) {\n", + "index", SimpleItoa(last_chunk * 8), + "mask", SimpleItoa(last_chunk_mask)); + printer->Indent(); + } + + if (memset_run_start != -1) { + if (memset_run_start == memset_run_end) { + // For clarity, do not memset a single field. + const FieldGenerator& generator = + field_generators_.get(optimized_order_[memset_run_start]); + generator.GenerateMessageClearingCode(printer); + } else { + const string first_field_name = + FieldName(optimized_order_[memset_run_start]); + const string last_field_name = + FieldName(optimized_order_[memset_run_end]); + + 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); + } + + // Advance last_chunk_start to skip over the fields we zeroed/memset. + last_chunk_start = memset_run_end + 1; + } + + // Go back and emit clears for each of the fields we processed. + for (int j = last_chunk_start; j <= last_chunk_end; j++) { + const FieldDescriptor* field = optimized_order_[j]; + const string fieldname = FieldName(field); + const FieldGenerator& generator = field_generators_.get(field); + + // It's faster to just overwrite primitive types, but we should only + // clear strings and messages if they were set. + // + // TODO(kenton): Let the CppFieldGenerator decide this somehow. + bool should_check_bit = + field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || + field->cpp_type() == FieldDescriptor::CPPTYPE_STRING; + + bool have_enclosing_if = false; + if (should_check_bit && + // If no field presence, then always clear strings/messages as well. + HasFieldPresence(descriptor_->file())) { + printer->Print("if (has_$name$()) {\n", "name", fieldname); + printer->Indent(); + have_enclosing_if = true; + } + + generator.GenerateMessageClearingCode(printer); + + if (have_enclosing_if) { + printer->Outdent(); + printer->Print("}\n"); + } + } + + if (have_outer_if) { + printer->Outdent(); + printer->Print("}\n"); } } } @@ -2649,23 +2519,7 @@ GenerateClear(io::Printer* printer) { } if (PreserveUnknownFields(descriptor_)) { - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "if (_internal_metadata_.have_unknown_fields()) {\n" - " mutable_unknown_fields()->Clear();\n" - "}\n"); - } else { - if (SupportsArenas(descriptor_)) { - printer->Print( - "_unknown_fields_.ClearToEmpty(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n" - " GetArenaNoVirtual());\n"); - } else { - printer->Print( - "_unknown_fields_.ClearToEmptyNoArena(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n"); - } - } + printer->Print("_internal_metadata_.Clear();\n"); } printer->Outdent(); @@ -2676,7 +2530,7 @@ void MessageGenerator:: GenerateOneofClear(io::Printer* printer) { // Generated function clears the active field and union case (e.g. foo_case_). for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - map<string, string> oneof_vars; + std::map<string, string> oneof_vars; oneof_vars["classname"] = classname_; oneof_vars["oneofname"] = descriptor_->oneof_decl(i)->name(); oneof_vars["full_name"] = descriptor_->full_name(); @@ -2742,10 +2596,13 @@ GenerateSwap(io::Printer* printer) { " if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n" " InternalSwap(other);\n" " } else {\n" - " $classname$ temp;\n" - " temp.UnsafeMergeFrom(*this);\n" - " CopyFrom(*other);\n" - " other->CopyFrom(temp);\n" + " $classname$* temp = New(GetArenaNoVirtual());\n" + " temp->MergeFrom(*other);\n" + " other->CopyFrom(*this);\n" + " InternalSwap(temp);\n" + " if (GetArenaNoVirtual() == NULL) {\n" + " delete temp;\n" + " }\n" " }\n" "}\n" "void $classname$::UnsafeArenaSwap($classname$* other) {\n" @@ -2769,8 +2626,10 @@ GenerateSwap(io::Printer* printer) { printer->Indent(); if (HasGeneratedMethods(descriptor_->file(), options_)) { - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + for (int i = 0; i < optimized_order_.size(); i++) { + // optimized_order_ does not contain oneof fields, but the field + // generators for these fields do not emit swapping code on their own. + const FieldDescriptor* field = optimized_order_[i]; field_generators_.get(field).GenerateSwappingCode(printer); } @@ -2789,13 +2648,8 @@ GenerateSwap(io::Printer* printer) { } } - // Ignore PreserveUnknownFields here - always swap internal_metadata as it - // may contain more than just unknown fields. - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "_internal_metadata_.Swap(&other->_internal_metadata_);\n"); - } else { - printer->Print("_unknown_fields_.Swap(&other->_unknown_fields_);\n"); + if (PreserveUnknownFields(descriptor_)) { + printer->Print("_internal_metadata_.Swap(&other->_internal_metadata_);\n"); } printer->Print("std::swap(_cached_size_, other->_cached_size_);\n"); @@ -2819,7 +2673,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)) MergeFromFail(__LINE__);\n", + " GOOGLE_DCHECK_NE(&from, this);\n", "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); @@ -2838,7 +2692,7 @@ GenerateMergeFrom(io::Printer* printer) { "} else {\n" "// @@protoc_insertion_point(generalized_merge_from_cast_success:" "$full_name$)\n" - " UnsafeMergeFrom(*source);\n" + " MergeFrom(*source);\n" "}\n", "classname", classname_, "full_name", descriptor_->full_name()); @@ -2860,25 +2714,118 @@ 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_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", + " GOOGLE_DCHECK_NE(&from, this);\n", "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); - // Merge Repeated fields. These fields do not require a - // check as we can simply iterate over them. - for (int i = 0; i < descriptor_->field_count(); ++i) { - const FieldDescriptor* field = descriptor_->field(i); + if (descriptor_->extension_range_count() > 0) { + printer->Print("_extensions_.MergeFrom(from._extensions_);\n"); + } - if (field->is_repeated()) { - field_generators_.get(field).GenerateUnsafeMergingCode(printer); + printer->Print( + "_internal_metadata_.MergeFrom(from._internal_metadata_);\n"); + + int last_i = -1; + for (int i = 0; i < optimized_order_.size(); ) { + // Detect infinite loops. + GOOGLE_CHECK_NE(i, last_i); + last_i = i; + + // Merge Repeated fields. These fields do not require a + // check as we can simply iterate over them. + for (; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + if (!field->is_repeated()) { + break; + } + + const FieldGenerator& generator = field_generators_.get(field); + generator.GenerateMergingCode(printer); + } + + // Merge Optional and Required fields (after a _has_bit check). + int last_chunk = -1; + int last_chunk_start = -1; + int last_chunk_end = -1; + uint32 last_chunk_mask = 0; + for (; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + if (field->is_repeated()) { + break; + } + + // "index" defines where in the _has_bits_ the field appears. + // "i" is our loop counter within optimized_order_. + int index = HasFieldPresence(descriptor_->file()) ? + has_bit_indices_[field->index()] : 0; + int chunk = index / 8; + + if (last_chunk == -1) { + last_chunk = chunk; + last_chunk_start = i; + } else if (chunk != last_chunk) { + // Emit the fields for this chunk so far. + break; + } + + last_chunk_end = i; + last_chunk_mask |= static_cast<uint32>(1) << (index % 32); + } + + if (last_chunk != -1) { + GOOGLE_DCHECK_NE(-1, last_chunk_start); + GOOGLE_DCHECK_NE(-1, last_chunk_end); + GOOGLE_DCHECK_NE(0, last_chunk_mask); + + const int count = popcnt(last_chunk_mask); + const bool have_outer_if = HasFieldPresence(descriptor_->file()) && + (last_chunk_start != last_chunk_end); + + if (have_outer_if) { + // Check (up to) 8 has_bits at a time if we have more than one field in + // this chunk. Due to field layout ordering, we may check + // _has_bits_[last_chunk * 8 / 32] multiple times. + GOOGLE_DCHECK_LE(2, count); + GOOGLE_DCHECK_GE(8, count); + + printer->Print( + "if (from._has_bits_[$index$ / 32] & $mask$u) {\n", + "index", SimpleItoa(last_chunk * 8), + "mask", SimpleItoa(last_chunk_mask)); + printer->Indent(); + } + + // Go back and emit clears for each of the fields we processed. + for (int j = last_chunk_start; j <= last_chunk_end; j++) { + const FieldDescriptor* field = optimized_order_[j]; + const FieldGenerator& generator = field_generators_.get(field); + + bool have_enclosing_if = false; + if (HasFieldPresence(descriptor_->file())) { + printer->Print( + "if (from.has_$name$()) {\n", + "name", FieldName(field)); + printer->Indent(); + have_enclosing_if = true; + } else { + // Merge semantics without true field presence: primitive fields are + // merged only if non-zero (numeric) or non-empty (string). + have_enclosing_if = EmitFieldNonDefaultCondition( + printer, "from.", field); + } + + generator.GenerateMergingCode(printer); + + if (have_enclosing_if) { + printer->Outdent(); + printer->Print("}\n"); + } + } + + if (have_outer_if) { + printer->Outdent(); + printer->Print("}\n"); + } } } @@ -2912,78 +2859,6 @@ GenerateMergeFrom(io::Printer* printer) { "}\n"); } - // Merge Optional and Required fields (after a _has_bit check). - int last_index = -1; - - for (int i = 0; i < descriptor_->field_count(); ++i) { - const FieldDescriptor* field = descriptor_->field(i); - - if (!field->is_repeated() && !field->containing_oneof()) { - if (HasFieldPresence(descriptor_->file())) { - // See above in GenerateClear for an explanation of this. - if (i / 8 != last_index / 8 || last_index < 0) { - if (last_index >= 0) { - printer->Outdent(); - printer->Print("}\n"); - } - printer->Print( - "if (from._has_bits_[$index$ / 32] & " - "(0xffu << ($index$ % 32))) {\n", - "index", SimpleItoa(field->index())); - printer->Indent(); - } - } - - last_index = i; - - bool have_enclosing_if = false; - if (HasFieldPresence(descriptor_->file())) { - printer->Print( - "if (from.has_$name$()) {\n", - "name", FieldName(field)); - printer->Indent(); - have_enclosing_if = true; - } else { - // Merge semantics without true field presence: primitive fields are - // merged only if non-zero (numeric) or non-empty (string). - have_enclosing_if = EmitFieldNonDefaultCondition( - printer, "from.", field); - } - - field_generators_.get(field).GenerateMergingCode(printer); - - if (have_enclosing_if) { - printer->Outdent(); - printer->Print("}\n"); - } - } - } - - if (HasFieldPresence(descriptor_->file()) && - last_index >= 0) { - printer->Outdent(); - printer->Print("}\n"); - } - - if (descriptor_->extension_range_count() > 0) { - printer->Print("_extensions_.MergeFrom(from._extensions_);\n"); - } - - if (PreserveUnknownFields(descriptor_)) { - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "if (from._internal_metadata_.have_unknown_fields()) {\n" - " ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(\n" - " from.unknown_fields(), &_internal_metadata_);\n" - "}\n"); - } else { - printer->Print( - "if (!from.unknown_fields().empty()) {\n" - " mutable_unknown_fields()->append(from.unknown_fields());\n" - "}\n"); - } - } - printer->Outdent(); printer->Print("}\n"); } @@ -3020,7 +2895,7 @@ GenerateCopyFrom(io::Printer* printer) { printer->Print( "if (&from == this) return;\n" "Clear();\n" - "UnsafeMergeFrom(from);\n"); + "MergeFrom(from);\n"); printer->Outdent(); printer->Print("}\n"); @@ -3061,7 +2936,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { // on the CodedOutputStream. printer->Print( " ::google::protobuf::io::LazyStringOutputStream unknown_fields_string(\n" - " ::google::protobuf::NewPermanentCallback(\n" + " NewPermanentCallback(\n" " &MutableUnknownFieldsFor$classname$, this));\n" " ::google::protobuf::io::CodedOutputStream unknown_fields_stream(\n" " &unknown_fields_string, false);\n", @@ -3082,13 +2957,41 @@ GenerateMergeFromCodedStream(io::Printer* printer) { WireFormat::MakeTag(ordered_fields[descriptor_->field_count() - 1]); const int kCutoff0 = 127; // fits in 1-byte varint const int kCutoff1 = (127 << 7) + 127; // fits in 2-byte varint + + // We need to capture the last tag when parsing if this is a Group type, as + // our caller will verify (via CodedInputStream::LastTagWas) that the correct + // closing tag was received. + bool capture_last_tag = false; + const Descriptor* parent = descriptor_->containing_type(); + if (parent) { + for (int i = 0; i < parent->field_count(); i++) { + const FieldDescriptor* field = parent->field(i); + if (field->type() == FieldDescriptor::TYPE_GROUP && + field->message_type() == descriptor_) { + capture_last_tag = true; + break; + } + } + } + + for (int i = 0; i < descriptor_->file()->extension_count(); i++) { + const FieldDescriptor* field = descriptor_->file()->extension(i); + if (field->type() == FieldDescriptor::TYPE_GROUP && + field->message_type() == descriptor_) { + capture_last_tag = true; + break; + } + } + printer->Print("::std::pair< ::google::protobuf::uint32, bool> p = " - "input->ReadTagWithCutoff($max$);\n" + "input->ReadTagWithCutoff$lasttag$($max$u);\n" "tag = p.first;\n" "if (!p.second) goto handle_unusual;\n", "max", SimpleItoa(maxtag <= kCutoff0 ? kCutoff0 : (maxtag <= kCutoff1 ? kCutoff1 : - maxtag))); + maxtag)), + "lasttag", !capture_last_tag ? "NoLastTag" : ""); + if (descriptor_->field_count() > 0) { // We don't even want to print the switch() if we have no fields because // MSVC dislikes switch() statements that contain only a default value. @@ -3098,6 +3001,13 @@ GenerateMergeFromCodedStream(io::Printer* printer) { // of each case. However, this is actually a bit slower in practice as it // creates a jump table that is 8x larger and sparser, and meanwhile the // if()s are highly predictable. + // + // Historically, we inserted checks to peek at the next tag on the wire and + // jump directly to the next case statement. While this avoids the jump + // table that the switch uses, it greatly increases code size (20-60%) and + // inserts branches that may fail (especially for real world protos that + // interleave--in field number order--hot and cold fields). Loadtests + // confirmed that removing this optimization is performance neutral. printer->Print("switch (::google::protobuf::internal::WireFormatLite::" "GetTagFieldNumber(tag)) {\n"); @@ -3114,19 +3024,9 @@ GenerateMergeFromCodedStream(io::Printer* printer) { } } - // need_label is true if we generated "goto parse_$name$" while handling the - // previous field. - bool need_label = false; - // 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; PrintFieldComment(printer, field); @@ -3137,20 +3037,11 @@ GenerateMergeFromCodedStream(io::Printer* printer) { const FieldGenerator& field_generator = field_generators_.get(field); // Emit code to parse the common, expected case. - printer->Print("if (tag == $commontag$) {\n", + printer->Print("if (tag == $commontag$u) {\n", "commontag", SimpleItoa(WireFormat::MakeTag(field))); - if (need_label || - (field->is_repeated() && !field->is_packed() && !loops)) { - printer->Print( - " parse_$name$:\n", - "name", field->name()); - } if (loops) { - printer->Print( - " DO_(input->IncrementRecursionDepth());\n" - " parse_loop_$name$:\n", - "name", field->name()); + printer->Print(" DO_(input->IncrementRecursionDepth());\n"); } printer->Indent(); @@ -3165,7 +3056,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { if (field->is_packed()) { internal::WireFormatLite::WireType wiretype = WireFormat::WireTypeForFieldType(field->type()); - printer->Print("} else if (tag == $uncommontag$) {\n", + printer->Print("} else if (tag == $uncommontag$u) {\n", "uncommontag", SimpleItoa( internal::WireFormatLite::MakeTag( field->number(), wiretype))); @@ -3175,7 +3066,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { } else if (field->is_packable() && !field->is_packed()) { internal::WireFormatLite::WireType wiretype = internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED; - printer->Print("} else if (tag == $uncommontag$) {\n", + printer->Print("} else if (tag == $uncommontag$u) {\n", "uncommontag", SimpleItoa( internal::WireFormatLite::MakeTag( field->number(), wiretype))); @@ -3189,87 +3080,10 @@ GenerateMergeFromCodedStream(io::Printer* printer) { " goto handle_unusual;\n" "}\n"); - // switch() is slow since it can't be predicted well. Insert some if()s - // here that attempt to predict the next tag. - // For non-packed repeated fields, expect the same tag again. + // For repeated messages/groups, we need to decrement recursion depth. if (loops) { printer->Print( - "if (input->ExpectTag($tag$)) goto parse_loop_$name$;\n", - "tag", SimpleItoa(WireFormat::MakeTag(field)), - "name", field->name()); - } else if (field->is_repeated() && !field->is_packed()) { - printer->Print( - "if (input->ExpectTag($tag$)) goto parse_$name$;\n", - "tag", SimpleItoa(WireFormat::MakeTag(field)), - "name", field->name()); - } - - // Have we emitted "if (input->ExpectTag($next_tag$)) ..." yet? - bool emitted_goto_next_tag = false; - - // For repeated messages/groups, we need to decrement recursion depth, - // unless the next tag is also for a repeated message/group. - if (loops) { - if (next_field_loops) { - const FieldDescriptor* next_field = ordered_fields[i + 1]; - printer->Print( - "if (input->ExpectTag($next_tag$)) goto parse_loop_$next_name$;\n", - "next_tag", SimpleItoa(WireFormat::MakeTag(next_field)), - "next_name", next_field->name()); - emitted_goto_next_tag = true; - } - printer->Print( - "input->UnsafeDecrementRecursionDepth();\n"); - } - - // 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) { - // 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 + 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 = delta == 1; - } + "input->UnsafeDecrementRecursionDepth();\n"); } printer->Print( @@ -3382,7 +3196,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { } void MessageGenerator::GenerateSerializeOneofFields( - io::Printer* printer, const vector<const FieldDescriptor*>& fields, + io::Printer* printer, const std::vector<const FieldDescriptor*>& fields, bool to_array) { GOOGLE_CHECK(!fields.empty()); if (fields.size() == 1) { @@ -3450,7 +3264,7 @@ void MessageGenerator::GenerateSerializeOneField( void MessageGenerator::GenerateSerializeOneExtensionRange( io::Printer* printer, const Descriptor::ExtensionRange* range, bool to_array) { - map<string, string> vars; + std::map<string, string> vars; vars["start"] = SimpleItoa(range->start); vars["end"] = SimpleItoa(range->end); printer->Print(vars, @@ -3600,7 +3414,7 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) { io::Printer* printer_; const bool to_array_; const bool eager_; - vector<const FieldDescriptor*> v_; + std::vector<const FieldDescriptor*> v_; }; std::vector<const FieldDescriptor*> ordered_fields = @@ -3663,30 +3477,29 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) { } } -static vector<uint32> RequiredFieldsBitMask(const Descriptor* desc) { - vector<uint32> result; - uint32 mask = 0; - for (int i = 0; i < desc->field_count(); i++) { - if (i > 0 && i % 32 == 0) { - result.push_back(mask); - mask = 0; - } - if (desc->field(i)->is_required()) { - mask |= (1 << (i & 31)); +std::vector<uint32> MessageGenerator::RequiredFieldsBitMask() const { + const int array_size = HasBitsSize(); + std::vector<uint32> masks(array_size, 0); + + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* field = descriptor_->field(i); + if (!field->is_required()) { + continue; } + + const int has_bit_index = has_bit_indices_[field->index()]; + masks[has_bit_index / 32] |= + static_cast<uint32>(1) << (has_bit_index % 32); } - if (mask != 0) { - result.push_back(mask); - } - return result; + return masks; } // Create an expression that evaluates to // "for all i, (_has_bits_[i] & masks[i]) == masks[i]" // masks is allowed to be shorter than _has_bits_, but at least one element of // masks must be non-zero. -static string ConditionalToCheckBitmasks(const vector<uint32>& masks) { - vector<string> parts; +static string ConditionalToCheckBitmasks(const std::vector<uint32>& masks) { + std::vector<string> parts; for (int i = 0; i < masks.size(); i++) { if (masks[i] == 0) continue; string m = StrCat("0x", strings::Hex(masks[i], strings::ZERO_PAD_8)); @@ -3735,8 +3548,8 @@ GenerateByteSize(io::Printer* printer) { "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); printer->Print("size_t total_size = 0;\n"); - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; if (field->is_required()) { printer->Print("\n" "if (has_$name$()) {\n", @@ -3763,18 +3576,41 @@ GenerateByteSize(io::Printer* printer) { "size_t total_size = 0;\n" "\n"); + if (descriptor_->extension_range_count() > 0) { + printer->Print( + "total_size += _extensions_.ByteSize();\n" + "\n"); + } + + if (PreserveUnknownFields(descriptor_)) { + if (UseUnknownFieldSet(descriptor_->file(), options_)) { + printer->Print( + "if (_internal_metadata_.have_unknown_fields()) {\n" + " total_size +=\n" + " ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n" + " unknown_fields());\n" + "}\n"); + } else { + printer->Print( + "total_size += unknown_fields().size();\n" + "\n"); + } + } + // Handle required fields (if any). We expect all of them to be // present, so emit one conditional that checks for that. If they are all // present then the fast path executes; otherwise the slow path executes. if (num_required_fields_ > 1 && HasFieldPresence(descriptor_->file())) { // The fast path works if all required fields are present. - vector<uint32> masks_for_has_bits = RequiredFieldsBitMask(descriptor_); + const std::vector<uint32> masks_for_has_bits = RequiredFieldsBitMask(); printer->Print((string("if (") + ConditionalToCheckBitmasks(masks_for_has_bits) + ") { // All required fields are present.\n").c_str()); printer->Indent(); - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + // Oneof fields cannot be required, so optimized_order_ contains all of the + // fields that we need to potentially emit. + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; if (!field->is_required()) continue; PrintFieldComment(printer, field); field_generators_.get(field).GenerateByteSize(printer); @@ -3786,8 +3622,8 @@ GenerateByteSize(io::Printer* printer) { "}\n"); } else { // num_required_fields_ <= 1: no need to be tricky - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; if (!field->is_required()) continue; PrintFieldComment(printer, field); printer->Print("if (has_$name$()) {\n", @@ -3799,98 +3635,125 @@ GenerateByteSize(io::Printer* printer) { } } - // Handle optional fields (worry below about repeateds, oneofs, etc.). - // These are handled in chunks of 8. The first chunk is - // the non-requireds-non-repeateds-non-unions-non-extensions in - // descriptor_->field(0), descriptor_->field(1), ... descriptor_->field(7), - // and the second chunk is the same for - // descriptor_->field(8), descriptor_->field(9), ... descriptor_->field(15), - // etc. - hash_map<int, uint32> fields_mask_for_chunk; - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (!field->is_required() && !field->is_repeated() && - !field->containing_oneof()) { - fields_mask_for_chunk[i / 8] |= static_cast<uint32>(1) << (i % 32); + int last_i = -1; + for (int i = 0; i < optimized_order_.size(); ) { + // Detect infinite loops. + GOOGLE_CHECK_NE(i, last_i); + last_i = i; + + // Skip required fields. + for (; i < optimized_order_.size() && + optimized_order_[i]->is_required(); i++) { } - } - int last_index = -1; - bool chunk_block_in_progress = false; - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (!field->is_required() && !field->is_repeated() && - !field->containing_oneof()) { - // See above in GenerateClear for an explanation of this. - // TODO(kenton): Share code? Unclear how to do so without - // over-engineering. - if (i / 8 != last_index / 8 || last_index < 0) { - // End previous chunk, if there was one. - if (chunk_block_in_progress) { - printer->Outdent(); - printer->Print("}\n"); - chunk_block_in_progress = false; - } - // Start chunk. - uint32 mask = fields_mask_for_chunk[i / 8]; - int count = popcnt(mask); - GOOGLE_DCHECK_GE(count, 1); - if (count == 1) { - // No "if" here because the chunk is trivial. - } else { - if (HasFieldPresence(descriptor_->file())) { - printer->Print( - "if (_has_bits_[$index$ / 32] & $mask$u) {\n", - "index", SimpleItoa(i), - "mask", SimpleItoa(mask)); - printer->Indent(); - chunk_block_in_progress = true; - } - } + // Handle repeated fields. + for (; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + if (!field->is_repeated()) { + break; } - last_index = i; PrintFieldComment(printer, field); + const FieldGenerator& generator = field_generators_.get(field); + generator.GenerateByteSize(printer); + printer->Print("\n"); + } - bool have_enclosing_if = false; - if (HasFieldPresence(descriptor_->file())) { - printer->Print( - "if (has_$name$()) {\n", - "name", FieldName(field)); - printer->Indent(); - have_enclosing_if = true; - } else { - // Without field presence: field is serialized only if it has a - // non-default value. - have_enclosing_if = EmitFieldNonDefaultCondition( - printer, "this->", field); + // Handle optional (non-repeated/oneof) fields. + // + // These are handled in chunks of 8. The first chunk is + // the non-requireds-non-repeateds-non-unions-non-extensions in + // descriptor_->field(0), descriptor_->field(1), ... descriptor_->field(7), + // and the second chunk is the same for + // descriptor_->field(8), descriptor_->field(9), ... + // descriptor_->field(15), + // etc. + int last_chunk = -1; + int last_chunk_start = -1; + int last_chunk_end = -1; + uint32 last_chunk_mask = 0; + for (; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + if (field->is_repeated() || field->is_required()) { + break; } - field_generators_.get(field).GenerateByteSize(printer); + // "index" defines where in the _has_bits_ the field appears. + // "i" is our loop counter within optimized_order_. + int index = HasFieldPresence(descriptor_->file()) ? + has_bit_indices_[field->index()] : 0; + int chunk = index / 8; + + if (last_chunk == -1) { + last_chunk = chunk; + last_chunk_start = i; + } else if (chunk != last_chunk) { + // Emit the fields for this chunk so far. + break; + } + + last_chunk_end = i; + last_chunk_mask |= static_cast<uint32>(1) << (index % 32); + } + + if (last_chunk != -1) { + GOOGLE_DCHECK_NE(-1, last_chunk_start); + GOOGLE_DCHECK_NE(-1, last_chunk_end); + GOOGLE_DCHECK_NE(0, last_chunk_mask); + + const int count = popcnt(last_chunk_mask); + const bool have_outer_if = HasFieldPresence(descriptor_->file()) && + (last_chunk_start != last_chunk_end); + + if (have_outer_if) { + // Check (up to) 8 has_bits at a time if we have more than one field in + // this chunk. Due to field layout ordering, we may check + // _has_bits_[last_chunk * 8 / 32] multiple times. + GOOGLE_DCHECK_LE(2, count); + GOOGLE_DCHECK_GE(8, count); - if (have_enclosing_if) { - printer->Outdent(); printer->Print( - "}\n" - "\n"); + "if (_has_bits_[$index$ / 32] & $mask$u) {\n", + "index", SimpleItoa(last_chunk * 8), + "mask", SimpleItoa(last_chunk_mask)); + printer->Indent(); } - } - } - if (chunk_block_in_progress) { - printer->Outdent(); - printer->Print("}\n"); - } + // Go back and emit checks for each of the fields we processed. + for (int j = last_chunk_start; j <= last_chunk_end; j++) { + const FieldDescriptor* field = optimized_order_[j]; + const FieldGenerator& generator = field_generators_.get(field); - // Repeated fields don't use _has_bits_ so we count them in a separate - // pass. - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + PrintFieldComment(printer, field); - if (field->is_repeated()) { - PrintFieldComment(printer, field); - field_generators_.get(field).GenerateByteSize(printer); - printer->Print("\n"); + bool have_enclosing_if = false; + if (HasFieldPresence(descriptor_->file())) { + printer->Print( + "if (has_$name$()) {\n", + "name", FieldName(field)); + printer->Indent(); + have_enclosing_if = true; + } else { + // Without field presence: field is serialized only if it has a + // non-default value. + have_enclosing_if = EmitFieldNonDefaultCondition( + printer, "this->", field); + } + + generator.GenerateByteSize(printer); + + if (have_enclosing_if) { + printer->Outdent(); + printer->Print( + "}\n" + "\n"); + } + } + + if (have_outer_if) { + printer->Outdent(); + printer->Print("}\n"); + } } } @@ -3926,27 +3789,6 @@ GenerateByteSize(io::Printer* printer) { "}\n"); } - if (descriptor_->extension_range_count() > 0) { - printer->Print( - "total_size += _extensions_.ByteSize();\n" - "\n"); - } - - if (PreserveUnknownFields(descriptor_)) { - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "if (_internal_metadata_.have_unknown_fields()) {\n" - " total_size +=\n" - " ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n" - " unknown_fields());\n" - "}\n"); - } else { - printer->Print( - "total_size += unknown_fields().size();\n" - "\n"); - } - } - // We update _cached_size_ even though this is a const method. In theory, // this is not thread-compatible, because concurrent writes have undefined // results. In practice, since any concurrent writes will be writing the @@ -3970,35 +3812,38 @@ GenerateIsInitialized(io::Printer* printer) { "classname", classname_); printer->Indent(); + if (descriptor_->extension_range_count() > 0) { + printer->Print( + "if (!_extensions_.IsInitialized()) {\n" + " return false;\n" + "}\n\n"); + } + if (HasFieldPresence(descriptor_->file())) { // Check that all required fields in this message are set. We can do this // most efficiently by checking 32 "has bits" at a time. - int has_bits_array_size = (descriptor_->field_count() + 31) / 32; - for (int i = 0; i < has_bits_array_size; i++) { - uint32 mask = 0; - for (int bit = 0; bit < 32; bit++) { - int index = i * 32 + bit; - if (index >= descriptor_->field_count()) break; - const FieldDescriptor* field = descriptor_->field(index); - - if (field->is_required()) { - mask |= 1 << bit; - } - } + const std::vector<uint32> masks = RequiredFieldsBitMask(); - if (mask != 0) { - printer->Print( - "if ((_has_bits_[$i$] & 0x$mask$) != 0x$mask$) return false;\n", - "i", SimpleItoa(i), - "mask", StrCat(strings::Hex(mask, strings::ZERO_PAD_8))); + for (int i = 0; i < masks.size(); i++) { + uint32 mask = masks[i]; + if (mask == 0) { + continue; } + + // TODO(ckennelly): Consider doing something similar to ByteSizeLong(), + // where we check all of the required fields in a single branch (assuming + // that we aren't going to benefit from early termination). + printer->Print( + "if ((_has_bits_[$i$] & 0x$mask$) != 0x$mask$) return false;\n", + "i", SimpleItoa(i), + "mask", StrCat(strings::Hex(mask, strings::ZERO_PAD_8))); } } - // Now check that all embedded messages are initialized. - printer->Print("\n"); - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + // Now check that all non-oneof embedded messages are initialized. + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + // TODO(ckennelly): Push this down into a generator? if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && !ShouldIgnoreRequiredFieldCheck(field, options_) && HasRequiredFields(field->message_type(), options_)) { @@ -4008,7 +3853,56 @@ GenerateIsInitialized(io::Printer* printer) { " return false;\n", "name", FieldName(field)); } else { - if (field->options().weak() || !field->containing_oneof()) { + GOOGLE_CHECK(field->options().weak() || !field->containing_oneof()); + // For weak fields, use the data member (::google::protobuf::Message*) instead + // of the getter to avoid a link dependency on the weak message type + // which is only forward declared. + printer->Print( + "if (has_$name$()) {\n" + " if (!this->$name$_->IsInitialized()) return false;\n" + "}\n", + "name", FieldName(field)); + } + } + } + + // Go through the oneof fields, emitting a switch if any might have required + // fields. + for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { + const OneofDescriptor* oneof = descriptor_->oneof_decl(i); + + bool has_required_fields = false; + for (int j = 0; j < oneof->field_count(); j++) { + const FieldDescriptor* field = oneof->field(j); + + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + !ShouldIgnoreRequiredFieldCheck(field, options_) && + HasRequiredFields(field->message_type(), options_)) { + has_required_fields = true; + break; + } + } + + if (!has_required_fields) { + continue; + } + + printer->Print( + "switch ($oneofname$_case()) {\n", + "oneofname", oneof->name()); + printer->Indent(); + for (int j = 0; j < oneof->field_count(); j++) { + const FieldDescriptor* field = oneof->field(j); + printer->Print( + "case k$field_name$: {\n", + "field_name", UnderscoresToCamelCase(field->name(), true)); + printer->Indent(); + + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + !ShouldIgnoreRequiredFieldCheck(field, options_) && + HasRequiredFields(field->message_type(), options_)) { + GOOGLE_CHECK(!(field->options().weak() || !field->containing_oneof())); + if (field->options().weak()) { // For weak fields, use the data member (::google::protobuf::Message*) instead // of the getter to avoid a link dependency on the weak message type // which is only forward declared. @@ -4025,15 +3919,22 @@ GenerateIsInitialized(io::Printer* printer) { "name", FieldName(field)); } } - } - } - if (descriptor_->extension_range_count() > 0) { + printer->Print( + "break;\n"); + printer->Outdent(); + printer->Print( + "}\n"); + } printer->Print( - "\n" - "if (!_extensions_.IsInitialized()) {\n" - " return false;\n" - "}\n"); + "case $cap_oneof_name$_NOT_SET: {\n" + " break;\n" + "}\n", + "cap_oneof_name", + ToUpper(oneof->name())); + printer->Outdent(); + printer->Print( + "}\n"); } printer->Outdent(); diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h index 3bdc0ed3..c5efff12 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.h +++ b/src/google/protobuf/compiler/cpp/cpp_message.h @@ -64,6 +64,12 @@ class MessageGenerator { MessageGenerator(const Descriptor* descriptor, const Options& options); ~MessageGenerator(); + // Appends the pre-order walk of the nested generators to list. + void Flatten(std::vector<MessageGenerator*>* list); + // Append the two types of nested generators to the corresponding vector. + void AddGenerators(std::vector<EnumGenerator*>* enum_generators, + std::vector<ExtensionGenerator*>* extension_generators); + // Header stuff. // Return names for forward declarations of this class and all its nested @@ -71,17 +77,7 @@ class MessageGenerator { // descriptor that was responsible for its inclusion in the map. This can be // used to associate the descriptor with the code generated for it. void FillMessageForwardDeclarations( - map<string, const Descriptor*>* class_names); - void FillEnumForwardDeclarations( - map<string, const EnumDescriptor*>* enum_names); - - // Generate definitions of all nested enums (must come before class - // definitions because those classes use the enums definitions). - void GenerateEnumDefinitions(io::Printer* printer); - - // Generate specializations of GetEnumDescriptor<MyEnum>(). - // Precondition: in ::google::protobuf namespace. - void GenerateGetEnumDescriptorSpecializations(io::Printer* printer); + std::map<string, const Descriptor*>* class_names); // Generate definitions for this class and all its nested types. void GenerateClassDefinition(io::Printer* printer); @@ -99,10 +95,6 @@ class MessageGenerator { // will be initialized by the methods below. void GenerateDescriptorDeclarations(io::Printer* printer); - // Generate code that initializes the global variable storing the message's - // descriptor. - void GenerateDescriptorInitializer(io::Printer* printer, int index); - // Generate code that calls MessageFactory::InternalRegisterGeneratedMessage() // for all types. void GenerateTypeRegistrations(io::Printer* printer); @@ -130,8 +122,10 @@ class MessageGenerator { void GenerateDependentFieldAccessorDefinitions(io::Printer* printer); void GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline); - // Generate the field offsets array. - void GenerateOffsets(io::Printer* printer); + // Generate the field offsets array. Returns the a pair of the total numer + // of entries generated and the index of the first has_bit entry. + std::pair<size_t, size_t> GenerateOffsets(io::Printer* printer); + void GenerateSchema(io::Printer* printer, int offset, int has_offset); // Generate constructors and destructor. void GenerateStructors(io::Printer* printer); @@ -168,7 +162,7 @@ class MessageGenerator { // 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, + io::Printer* printer, const std::vector<const FieldDescriptor*>& fields, bool to_array); void GenerateSerializeOneExtensionRange( io::Printer* printer, const Descriptor::ExtensionRange* range, @@ -177,19 +171,26 @@ class MessageGenerator { // Generates has_foo() functions and variables for singular field has-bits. void GenerateSingularFieldHasBits(const FieldDescriptor* field, - map<string, string> vars, + std::map<string, string> vars, io::Printer* printer); // Generates has_foo() functions and variables for oneof field has-bits. void GenerateOneofHasBits(io::Printer* printer, bool is_inline); // Generates has_foo_bar() functions for oneof members. void GenerateOneofMemberHasBits(const FieldDescriptor* field, - const map<string, string>& vars, + const std::map<string, string>& vars, io::Printer* printer); // Generates the clear_foo() method for a field. void GenerateFieldClear(const FieldDescriptor* field, - const map<string, string>& vars, + const std::map<string, string>& vars, io::Printer* printer); + void GenerateConstructorBody(io::Printer* printer, + std::vector<bool> already_processed, + bool copy_constructor) const; + + size_t HasBitsSize() const; + std::vector<uint32> RequiredFieldsBitMask() const; + const Descriptor* descriptor_; string classname_; Options options_; @@ -198,15 +199,17 @@ class MessageGenerator { // 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 + std::vector<const FieldDescriptor *> optimized_order_; + std::vector<int> has_bit_indices_; google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > nested_generators_; google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_; google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > extension_generators_; int num_required_fields_; - bool uses_string_; bool use_dependent_base_; + int index_in_metadata_; + + friend class FileGenerator; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc index ca7bae02..91449657 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc @@ -45,7 +45,7 @@ namespace cpp { namespace { void SetMessageVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); (*variables)["type"] = FieldMessageTypeName(descriptor); @@ -218,7 +218,7 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { return; } - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); // For the CRTP base class, all mutation methods are dependent, and so // they must be in the header. variables["dependent_classname"] = @@ -349,7 +349,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, // 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_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$const $type$& $classname$::$name$() const {\n" @@ -360,7 +360,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, return; } - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$const $type$& $classname$::$name$() const {\n" @@ -469,7 +469,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, void MessageFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : ""; if (!HasFieldPresence(descriptor_->file())) { // If we don't have has-bits, message presence is indicated only by ptr != @@ -486,6 +486,26 @@ GenerateClearingCode(io::Printer* printer) const { } void MessageFieldGenerator:: +GenerateMessageClearingCode(io::Printer* printer) const { + std::map<string, string> variables(variables_); + variables["type"] = FieldMessageTypeName(descriptor_); + + if (!HasFieldPresence(descriptor_->file())) { + // If we don't have has-bits, message presence is indicated only by ptr != + // NULL. Thus on clear, we need to delete the object. + printer->Print(variables_, + "if (GetArenaNoVirtual() == NULL && $name$_ != NULL) {\n" + " delete $name$_;\n" + "}\n" + "$name$_ = NULL;\n"); + } else { + printer->Print(variables_, + "GOOGLE_DCHECK($name$_ != NULL);\n" + "$name$_->$type$::Clear();\n"); + } +} + +void MessageFieldGenerator:: GenerateMergingCode(io::Printer* printer) const { printer->Print(variables_, "mutable_$name$()->$type$::MergeFrom(from.$name$());\n"); @@ -497,11 +517,51 @@ GenerateSwappingCode(io::Printer* printer) const { } void MessageFieldGenerator:: +GenerateDestructorCode(io::Printer* printer) const { + // In google3 a default instance will never get deleted so we don't need to + // worry about that but in opensource protobuf default instances are deleted + // in shutdown process and we need to take special care when handling them. + printer->Print(variables_, + "if (this != internal_default_instance()) {\n" + " delete $name$_;\n" + "}\n"); +} + +void MessageFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { printer->Print(variables_, "$name$_ = NULL;\n"); } void MessageFieldGenerator:: +GenerateCopyConstructorCode(io::Printer* printer) const { + // For non-Arena enabled messages, everything always goes on the heap. + // + // For Arena enabled messages, the logic is a bit more convoluted. + // + // In the copy constructor, we call InternalMetadataWithArena::MergeFrom, + // which does *not* copy the Arena pointer. In the generated MergeFrom + // (see MessageFieldGenerator::GenerateMergingCode), we: + // -> copy the has bits (but this is done in bulk by a memcpy in the copy + // constructor) + // -> check whether the destination field pointer is NULL (it will be, since + // we're initializing it and would have called SharedCtor) and if so: + // -> call _slow_mutable_$name$(), which calls either + // ::google::protobuf::Arena::CreateMessage<>(GetArenaNoVirtual()), or + // ::google::protobuf::Arena::Create<>(GetArenaNoVirtual()) + // + // At this point, GetArenaNoVirtual returns NULL since the Arena pointer + // wasn't copied, so both of these methods allocate the submessage on the + // heap. + + printer->Print(variables_, + "if (from.has_$name$()) {\n" + " $name$_ = new $type$(*from.$name$_);\n" + "} else {\n" + " $name$_ = NULL;\n" + "}\n"); +} + +void MessageFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) { printer->Print(variables_, @@ -581,7 +641,7 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { if (!dependent_base_) { return; } - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = "inline "; variables["dependent_classname"] = DependentBaseClassTemplateName(descriptor_->containing_type()) + "<T>"; @@ -601,7 +661,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, if (dependent_base_) { return; } - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; variables["dependent_classname"] = variables["classname"]; variables["this_message"] = ""; @@ -615,16 +675,15 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, void MessageOneofFieldGenerator:: GenerateNonInlineAccessorDefinitions(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["field_member"] = variables["oneof_prefix"] + variables["name"] + "_"; //printer->Print(variables, } -void MessageOneofFieldGenerator:: -InternalGenerateInlineAccessorDefinitions(const map<string, string>& variables, - io::Printer* printer) const { +void MessageOneofFieldGenerator::InternalGenerateInlineAccessorDefinitions( + const std::map<string, string>& variables, io::Printer* printer) const { printer->Print(variables, "$tmpl$" "$inline$ " @@ -794,7 +853,7 @@ InternalGenerateInlineAccessorDefinitions(const map<string, string>& variables, void MessageOneofFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : ""; if (SupportsArenas(descriptor_)) { printer->Print(variables, @@ -808,11 +867,22 @@ GenerateClearingCode(io::Printer* printer) const { } void MessageOneofFieldGenerator:: +GenerateMessageClearingCode(io::Printer* printer) const { + GenerateClearingCode(printer); +} + +void MessageOneofFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { // Don't print any swapping code. Swapping the union will swap this field. } void MessageOneofFieldGenerator:: +GenerateDestructorCode(io::Printer* printer) const { + // We inherit from MessageFieldGenerator, so we need to override the default + // behavior. +} + +void MessageOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { // Don't print any constructor code. The field is in a union. We allocate // space only when this field is used. @@ -884,7 +954,7 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { if (!dependent_field_) { return; } - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); // For the CRTP base class, all mutation methods are dependent, and so // they must be in the header. variables["dependent_classname"] = @@ -915,7 +985,6 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { " return $this_message$$name$_.Add();\n" "}\n"); - if (dependent_getter_) { printer->Print(variables, "template <class T>\n" @@ -939,7 +1008,7 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { void RepeatedMessageFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; if (!dependent_getter_) { @@ -989,7 +1058,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, void RepeatedMessageFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : ""; printer->Print(variables, "$this_message$$name$_.Clear();\n"); } diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.h b/src/google/protobuf/compiler/cpp/cpp_message_field.h index d8d9279c..9ca91153 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.h @@ -59,23 +59,26 @@ class MessageFieldGenerator : public FieldGenerator { bool is_inline) const; void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; + void GenerateMessageClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; + void GenerateDestructorCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; protected: - void GenerateArenaManipulationCode(const map<string, string>& variables, + void GenerateArenaManipulationCode(const std::map<string, string>& variables, io::Printer* printer) const; virtual void GenerateGetterDeclaration(io::Printer* printer) const; const FieldDescriptor* descriptor_; const bool dependent_field_; - map<string, string> variables_; + std::map<string, string> variables_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator); @@ -94,7 +97,12 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator { bool is_inline) const; void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; + + // MessageFieldGenerator, from which we inherit, overrides this so we need to + // override it as well. + void GenerateMessageClearingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; + void GenerateDestructorCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; protected: @@ -102,7 +110,7 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator { private: void InternalGenerateInlineAccessorDefinitions( - const map<string, string>& variables, io::Printer* printer) const; + const std::map<string, string>& variables, io::Printer* printer) const; const bool dependent_base_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator); @@ -125,6 +133,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const {} void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; @@ -137,7 +146,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator { const FieldDescriptor* descriptor_; const bool dependent_field_; const bool dependent_getter_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc index 54b3d24a..240a6e0a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc @@ -80,7 +80,7 @@ int FixedSize(FieldDescriptor::Type type) { } void SetPrimitiveVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); (*variables)["type"] = PrimitiveTypeName(descriptor->cpp_type()); @@ -122,7 +122,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void PrimitiveFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$$type$ $classname$::$name$() const {\n" @@ -157,6 +157,11 @@ GenerateConstructorCode(io::Printer* printer) const { } void PrimitiveFieldGenerator:: +GenerateCopyConstructorCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_ = from.$name$_;\n"); +} + +void PrimitiveFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { printer->Print(variables_, "$set_hasbit$\n" @@ -206,7 +211,7 @@ PrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {} void PrimitiveOneofFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$$type$ $classname$::$name$() const {\n" @@ -240,7 +245,7 @@ void PrimitiveOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { printer->Print( variables_, - " $classname$_default_oneof_instance_->$name$_ = $default$;\n"); + " $classname$_default_oneof_instance_.$name$_ = $default$;\n"); } void PrimitiveOneofFieldGenerator:: @@ -297,7 +302,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void RepeatedPrimitiveFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$$type$ $classname$::$name$(int index) const {\n" @@ -336,11 +341,6 @@ 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"); } @@ -351,11 +351,16 @@ GenerateConstructorCode(io::Printer* printer) const { } void RepeatedPrimitiveFieldGenerator:: +GenerateCopyConstructorCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_.CopyFrom(from.$name$_);\n"); +} + +void RepeatedPrimitiveFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { printer->Print(variables_, "DO_((::google::protobuf::internal::WireFormatLite::$repeated_reader$<\n" " $type$, $wire_format_field_type$>(\n" - " $tag_size$, $tag$, input, this->mutable_$name$())));\n"); + " $tag_size$, $tag$u, input, this->mutable_$name$())));\n"); } void RepeatedPrimitiveFieldGenerator:: diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h index 23cc697e..44c9ff3e 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h @@ -59,6 +59,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; @@ -66,7 +67,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator); @@ -103,9 +104,9 @@ 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 GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; @@ -114,7 +115,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_service.cc b/src/google/protobuf/compiler/cpp/cpp_service.cc index 6030f7ce..d6b1ddc5 100644 --- a/src/google/protobuf/compiler/cpp/cpp_service.cc +++ b/src/google/protobuf/compiler/cpp/cpp_service.cc @@ -143,7 +143,7 @@ void ServiceGenerator::GenerateMethodSignatures( VirtualOrNon virtual_or_non, io::Printer* printer) { for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> sub_vars; + std::map<string, string> sub_vars; sub_vars["name"] = method->name(); sub_vars["input_type"] = ClassName(method->input_type(), true); sub_vars["output_type"] = ClassName(method->output_type(), true); @@ -161,7 +161,7 @@ void ServiceGenerator::GenerateMethodSignatures( void ServiceGenerator::GenerateDescriptorInitializer( io::Printer* printer, int index) { - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = descriptor_->name(); vars["index"] = SimpleItoa(index); @@ -172,19 +172,20 @@ void ServiceGenerator::GenerateDescriptorInitializer( // =================================================================== void ServiceGenerator::GenerateImplementation(io::Printer* printer) { - printer->Print(vars_, - "$classname$::~$classname$() {}\n" - "\n" - "const ::google::protobuf::ServiceDescriptor* $classname$::descriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" - "}\n" - "\n" - "const ::google::protobuf::ServiceDescriptor* $classname$::GetDescriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" - "}\n" - "\n"); + vars_["index"] = SimpleItoa(index_in_metadata_); + printer->Print( + vars_, + "$classname$::~$classname$() {}\n" + "\n" + "const ::google::protobuf::ServiceDescriptor* $classname$::descriptor() {\n" + " protobuf_AssignDescriptorsOnce();\n" + " return file_level_service_descriptors[$index$];\n" + "}\n" + "\n" + "const ::google::protobuf::ServiceDescriptor* $classname$::GetDescriptor() {\n" + " return descriptor();\n" + "}\n" + "\n"); // Generate methods of the interface. GenerateNotImplementedMethods(printer); @@ -212,7 +213,7 @@ void ServiceGenerator::GenerateImplementation(io::Printer* printer) { void ServiceGenerator::GenerateNotImplementedMethods(io::Printer* printer) { for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> sub_vars; + std::map<string, string> sub_vars; sub_vars["classname"] = descriptor_->name(); sub_vars["name"] = method->name(); sub_vars["index"] = SimpleItoa(i); @@ -232,18 +233,20 @@ void ServiceGenerator::GenerateNotImplementedMethods(io::Printer* printer) { } void ServiceGenerator::GenerateCallMethod(io::Printer* printer) { - printer->Print(vars_, - "void $classname$::CallMethod(const ::google::protobuf::MethodDescriptor* method,\n" - " ::google::protobuf::RpcController* controller,\n" - " const ::google::protobuf::Message* request,\n" - " ::google::protobuf::Message* response,\n" - " ::google::protobuf::Closure* done) {\n" - " GOOGLE_DCHECK_EQ(method->service(), $classname$_descriptor_);\n" - " switch(method->index()) {\n"); + printer->Print( + vars_, + "void $classname$::CallMethod(const ::google::protobuf::MethodDescriptor* method,\n" + " ::google::protobuf::RpcController* controller,\n" + " const ::google::protobuf::Message* request,\n" + " ::google::protobuf::Message* response,\n" + " ::google::protobuf::Closure* done) {\n" + " GOOGLE_DCHECK_EQ(method->service(), " + "file_level_service_descriptors[$index$]);\n" + " switch(method->index()) {\n"); for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> sub_vars; + std::map<string, string> sub_vars; sub_vars["name"] = method->name(); sub_vars["index"] = SimpleItoa(i); sub_vars["input_type"] = ClassName(method->input_type(), true); @@ -289,7 +292,7 @@ void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which, const Descriptor* type = (which == REQUEST) ? method->input_type() : method->output_type(); - map<string, string> sub_vars; + std::map<string, string> sub_vars; sub_vars["index"] = SimpleItoa(i); sub_vars["type"] = ClassName(type, true); @@ -312,7 +315,7 @@ void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which, void ServiceGenerator::GenerateStubMethods(io::Printer* printer) { for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> sub_vars; + std::map<string, string> sub_vars; sub_vars["classname"] = descriptor_->name(); sub_vars["name"] = method->name(); sub_vars["index"] = SimpleItoa(i); diff --git a/src/google/protobuf/compiler/cpp/cpp_service.h b/src/google/protobuf/compiler/cpp/cpp_service.h index ede2fd80..33c02547 100644 --- a/src/google/protobuf/compiler/cpp/cpp_service.h +++ b/src/google/protobuf/compiler/cpp/cpp_service.h @@ -105,8 +105,11 @@ class ServiceGenerator { void GenerateStubMethods(io::Printer* printer); const ServiceDescriptor* descriptor_; - map<string, string> vars_; + std::map<string, string> vars_; + int index_in_metadata_; + + friend class FileGenerator; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index aee3d1ea..a9505e3d 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -46,20 +46,19 @@ namespace cpp { namespace { void SetStringVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); (*variables)["default"] = DefaultValue(descriptor); (*variables)["default_length"] = SimpleItoa(descriptor->default_value_string().length()); - string default_variable_string = + string default_variable_string = "_default_" + FieldName(descriptor) + "_"; + (*variables)["default_variable_name"] = default_variable_string; + (*variables)["default_variable"] = descriptor->default_value_string().empty() ? "&::google::protobuf::internal::GetEmptyStringAlreadyInited()" - : "_default_" + FieldName(descriptor) + "_"; - (*variables)["default_variable"] = default_variable_string; - (*variables)["default_value_init"] = - descriptor->default_value_string().empty() - ? "" : "*" + default_variable_string; + : "&" + (*variables)["classname"] + "::" + default_variable_string + + ".get()"; (*variables)["pointer_type"] = descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char"; // NOTE: Escaped here to unblock proto1->proto2 migration. @@ -104,7 +103,9 @@ GeneratePrivateMembers(io::Printer* printer) const { void StringFieldGenerator:: GenerateStaticMembers(io::Printer* printer) const { if (!descriptor_->default_value_string().empty()) { - printer->Print(variables_, "static ::std::string* $default_variable$;\n"); + printer->Print(variables_, + "static ::google::protobuf::internal::ExplicitlyConstructed< ::std::string>" + " $default_variable_name$;\n"); } } @@ -165,117 +166,121 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void StringFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; if (SupportsArenas(descriptor_)) { - printer->Print(variables, - "$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" - " $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" - " $set_hasbit$\n" - " $name$_.Set($default_variable$, $string_piece$(value),\n" - " GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set_char:$full_name$)\n" - "}\n" - "$inline$" - "void $classname$::set_$name$(const $pointer_type$* value,\n" - " size_t size) {\n" - " $set_hasbit$\n" - " $name$_.Set($default_variable$, $string_piece$(\n" - " 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" - " $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" - " // @@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" - " // @@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" - " if ($name$ != NULL) {\n" - " $set_hasbit$\n" - " } else {\n" - " $clear_hasbit$\n" - " }\n" - " $name$_.SetAllocated($default_variable$, $name$,\n" - " GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n" - "$inline$void $classname$::unsafe_arena_set_allocated_$name$(\n" - " ::std::string* $name$) {\n" - " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" - " if ($name$ != NULL) {\n" - " $set_hasbit$\n" - " } else {\n" - " $clear_hasbit$\n" - " }\n" - " $name$_.UnsafeArenaSetAllocated($default_variable$,\n" - " $name$, GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:" - "$full_name$)\n" - "}\n"); + printer->Print( + variables, + "$inline$const ::std::string& $classname$::$name$() const {\n" + " // @@protoc_insertion_point(field_get:$full_name$)\n" + " return $name$_.Get();\n" + "}\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" + " $set_hasbit$\n" + " $name$_.Set($default_variable$, $string_piece$(value),\n" + " GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set_char:$full_name$)\n" + "}\n" + "$inline$" + "void $classname$::set_$name$(const $pointer_type$* value,\n" + " size_t size) {\n" + " $set_hasbit$\n" + " $name$_.Set($default_variable$, $string_piece$(\n" + " 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" + " $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" + " // @@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" + " // " + "@@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" + " if ($name$ != NULL) {\n" + " $set_hasbit$\n" + " } else {\n" + " $clear_hasbit$\n" + " }\n" + " $name$_.SetAllocated($default_variable$, $name$,\n" + " GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" + "}\n" + "$inline$void $classname$::unsafe_arena_set_allocated_$name$(\n" + " ::std::string* $name$) {\n" + " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" + " if ($name$ != NULL) {\n" + " $set_hasbit$\n" + " } else {\n" + " $clear_hasbit$\n" + " }\n" + " $name$_.UnsafeArenaSetAllocated($default_variable$,\n" + " $name$, GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:" + "$full_name$)\n" + "}\n"); } else { // No-arena case. - printer->Print(variables, - "$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" - " $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" - " $set_hasbit$\n" - " $name$_.SetNoArena($default_variable$, $string_piece$(value));\n" - " // @@protoc_insertion_point(field_set_char:$full_name$)\n" - "}\n" - "$inline$" - "void $classname$::set_$name$(const $pointer_type$* value, " - "size_t size) {\n" - " $set_hasbit$\n" - " $name$_.SetNoArena($default_variable$,\n" - " $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" - " $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" - " // @@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" - " if ($name$ != NULL) {\n" - " $set_hasbit$\n" - " } else {\n" - " $clear_hasbit$\n" - " }\n" - " $name$_.SetAllocatedNoArena($default_variable$, $name$);\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n"); + printer->Print( + variables, + "$inline$const ::std::string& $classname$::$name$() const {\n" + " // @@protoc_insertion_point(field_get:$full_name$)\n" + " return $name$_.GetNoArena();\n" + "}\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" + " $set_hasbit$\n" + " $name$_.SetNoArena($default_variable$, $string_piece$(value));\n" + " // @@protoc_insertion_point(field_set_char:$full_name$)\n" + "}\n" + "$inline$" + "void $classname$::set_$name$(const $pointer_type$* value, " + "size_t size) {\n" + " $set_hasbit$\n" + " $name$_.SetNoArena($default_variable$,\n" + " $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" + " $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" + " // @@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" + " if ($name$ != NULL) {\n" + " $set_hasbit$\n" + " } else {\n" + " $clear_hasbit$\n" + " }\n" + " $name$_.SetAllocatedNoArena($default_variable$, $name$);\n" + " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" + "}\n"); } } @@ -284,7 +289,8 @@ GenerateNonInlineAccessorDefinitions(io::Printer* printer) const { if (!descriptor_->default_value_string().empty()) { // Initialized in GenerateDefaultInstanceAllocator. printer->Print(variables_, - "::std::string* $classname$::$default_variable$ = NULL;\n"); + "::google::protobuf::internal::ExplicitlyConstructed< ::std::string> " + "$classname$::$default_variable_name$;\n"); } } @@ -314,6 +320,52 @@ GenerateClearingCode(io::Printer* printer) const { } void StringFieldGenerator:: +GenerateMessageClearingCode(io::Printer* printer) const { + // Two-dimension specialization here: supporting arenas, field presence, or + // not, and default value is the empty string or not. Complexity here ensures + // the minimal number of branches / amount of extraneous code at runtime + // (given that the below methods are inlined one-liners)! + + // If we have field presence, then the Clear() method of the protocol buffer + // will have checked that this field is set. If so, we can avoid redundant + // checks against default_variable. + const bool must_be_present = HasFieldPresence(descriptor_->file()); + + if (must_be_present) { + printer->Print(variables_, + "GOOGLE_DCHECK(!$name$_.IsDefault($default_variable$));\n"); + } + + if (SupportsArenas(descriptor_)) { + if (descriptor_->default_value_string().empty()) { + printer->Print(variables_, + "$name$_.ClearToEmpty($default_variable$, GetArenaNoVirtual());\n"); + } else { + printer->Print(variables_, + "$name$_.ClearToDefault($default_variable$, GetArenaNoVirtual());\n"); + } + } else if (must_be_present) { + // When Arenas are disabled and field presence has been checked, we can + // safely treat the ArenaStringPtr as a string*. + if (descriptor_->default_value_string().empty()) { + printer->Print(variables_, + "(*$name$_.UnsafeRawStringPointer())->clear();\n"); + } else { + printer->Print(variables_, + "(*$name$_.UnsafeRawStringPointer())->assign(*$default_variable$);\n"); + } + } else { + if (descriptor_->default_value_string().empty()) { + printer->Print(variables_, + "$name$_.ClearToEmptyNoArena($default_variable$);\n"); + } else { + printer->Print(variables_, + "$name$_.ClearToDefaultNoArena($default_variable$);\n"); + } + } +} + +void StringFieldGenerator:: GenerateMergingCode(io::Printer* printer) const { if (SupportsArenas(descriptor_) || descriptor_->containing_oneof() != NULL) { // TODO(gpike): improve this @@ -337,6 +389,34 @@ GenerateConstructorCode(io::Printer* printer) const { } void StringFieldGenerator:: +GenerateCopyConstructorCode(io::Printer* printer) const { + GenerateConstructorCode(printer); + + if (HasFieldPresence(descriptor_->file())) { + printer->Print(variables_, + "if (from.has_$name$()) {\n"); + } else { + printer->Print(variables_, + "if (from.$name$().size() > 0) {\n"); + } + + printer->Indent(); + + if (SupportsArenas(descriptor_) || descriptor_->containing_oneof() != NULL) { + // TODO(gpike): improve this + printer->Print(variables_, + "$name$_.Set($default_variable$, from.$name$(),\n" + " GetArenaNoVirtual());\n"); + } else { + printer->Print(variables_, + "$name$_.AssignWithDefault($default_variable$, from.$name$_);\n"); + } + + printer->Outdent(); + printer->Print("}\n"); +} + +void StringFieldGenerator:: GenerateDestructorCode(io::Printer* printer) const { if (SupportsArenas(descriptor_)) { // The variable |arena| is defined by the enclosing code. @@ -353,8 +433,9 @@ void StringFieldGenerator:: GenerateDefaultInstanceAllocator(io::Printer* printer) const { if (!descriptor_->default_value_string().empty()) { printer->Print(variables_, - "$classname$::$default_variable$ =\n" - " new ::std::string($default$, $default_length$);\n"); + "$classname$::$default_variable_name$.DefaultConstruct();\n" + "*$classname$::$default_variable_name$.get_mutable() = " + "::std::string($default$, $default_length$);\n"); } } @@ -362,7 +443,7 @@ void StringFieldGenerator:: GenerateShutdownCode(io::Printer* printer) const { if (!descriptor_->default_value_string().empty()) { printer->Print(variables_, - "delete $classname$::$default_variable$;\n"); + "$classname$::$default_variable_name$.Shutdown();\n"); } } @@ -427,185 +508,190 @@ StringOneofFieldGenerator::~StringOneofFieldGenerator() {} void StringOneofFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; if (SupportsArenas(descriptor_)) { - printer->Print(variables, - "$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" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " $oneof_prefix$$name$_.Set($default_variable$, value,\n" - " GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set:$full_name$)\n" - "}\n" - "$inline$void $classname$::set_$name$(const char* value) {\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " $oneof_prefix$$name$_.Set($default_variable$,\n" - " $string_piece$(value), GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set_char:$full_name$)\n" - "}\n" - "$inline$" - "void $classname$::set_$name$(const $pointer_type$* value,\n" - " size_t size) {\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " $oneof_prefix$$name$_.Set($default_variable$, $string_piece$(\n" - " reinterpret_cast<const char*>(value), size),\n" - " GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" - "}\n" - "$inline$::std::string* $classname$::mutable_$name$() {\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " return $oneof_prefix$$name$_.Mutable($default_variable$,\n" - " GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - "}\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" - " return $oneof_prefix$$name$_.Release($default_variable$,\n" - " GetArenaNoVirtual());\n" - " } else {\n" - " return NULL;\n" - " }\n" - "}\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" - " clear_has_$oneof_name$();\n" - " return $oneof_prefix$$name$_.UnsafeArenaRelease(\n" - " $default_variable$, GetArenaNoVirtual());\n" - " } else {\n" - " return NULL;\n" - " }\n" - "}\n" - "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" - " if (!has_$name$()) {\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " clear_$oneof_name$();\n" - " if ($name$ != NULL) {\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.SetAllocated($default_variable$, $name$,\n" - " GetArenaNoVirtual());\n" - " }\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n" - "$inline$void $classname$::unsafe_arena_set_allocated_$name$(" - "::std::string* $name$) {\n" - " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" - " if (!has_$name$()) {\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " clear_$oneof_name$();\n" - " if ($name$) {\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeArenaSetAllocated($default_variable$, " - "$name$, GetArenaNoVirtual());\n" - " }\n" - " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:" - "$full_name$)\n" - "}\n"); + printer->Print( + variables, + "$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();\n" + " }\n" + " return *$default_variable$;\n" + "}\n" + "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " $oneof_prefix$$name$_.Set($default_variable$, value,\n" + " GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set:$full_name$)\n" + "}\n" + "$inline$void $classname$::set_$name$(const char* value) {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " $oneof_prefix$$name$_.Set($default_variable$,\n" + " $string_piece$(value), GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set_char:$full_name$)\n" + "}\n" + "$inline$" + "void $classname$::set_$name$(const $pointer_type$* value,\n" + " size_t size) {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " $oneof_prefix$$name$_.Set($default_variable$, $string_piece$(\n" + " reinterpret_cast<const char*>(value), size),\n" + " GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" + "}\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " return $oneof_prefix$$name$_.Mutable($default_variable$,\n" + " GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_mutable:$full_name$)\n" + "}\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" + " return $oneof_prefix$$name$_.Release($default_variable$,\n" + " GetArenaNoVirtual());\n" + " } else {\n" + " return NULL;\n" + " }\n" + "}\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" + " clear_has_$oneof_name$();\n" + " return $oneof_prefix$$name$_.UnsafeArenaRelease(\n" + " $default_variable$, GetArenaNoVirtual());\n" + " } else {\n" + " return NULL;\n" + " }\n" + "}\n" + "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + " if (!has_$name$()) {\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " clear_$oneof_name$();\n" + " if ($name$ != NULL) {\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.SetAllocated($default_variable$, $name$,\n" + " GetArenaNoVirtual());\n" + " }\n" + " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" + "}\n" + "$inline$void $classname$::unsafe_arena_set_allocated_$name$(" + "::std::string* $name$) {\n" + " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" + " if (!has_$name$()) {\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " clear_$oneof_name$();\n" + " if ($name$) {\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeArenaSetAllocated($default_variable$, " + "$name$, GetArenaNoVirtual());\n" + " }\n" + " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:" + "$full_name$)\n" + "}\n"); } else { // No-arena case. - printer->Print(variables, - "$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" - " // @@protoc_insertion_point(field_set:$full_name$)\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " $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" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " $oneof_prefix$$name$_.SetNoArena($default_variable$,\n" - " $string_piece$(value));\n" - " // @@protoc_insertion_point(field_set_char:$full_name$)\n" - "}\n" - "$inline$" - "void $classname$::set_$name$(const $pointer_type$* value, size_t size) {\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " $oneof_prefix$$name$_.SetNoArena($default_variable$, $string_piece$(\n" - " reinterpret_cast<const char*>(value), size));\n" - " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" - "}\n" - "$inline$::std::string* $classname$::mutable_$name$() {\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $oneof_prefix$$name$_.MutableNoArena($default_variable$);\n" - "}\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" - " return $oneof_prefix$$name$_.ReleaseNoArena($default_variable$);\n" - " } else {\n" - " return NULL;\n" - " }\n" - "}\n" - "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" - " if (!has_$name$()) {\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " clear_$oneof_name$();\n" - " if ($name$ != NULL) {\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.SetAllocatedNoArena($default_variable$,\n" - " $name$);\n" - " }\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n"); + printer->Print( + variables, + "$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();\n" + " }\n" + " return *$default_variable$;\n" + "}\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" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " $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" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " $oneof_prefix$$name$_.SetNoArena($default_variable$,\n" + " $string_piece$(value));\n" + " // @@protoc_insertion_point(field_set_char:$full_name$)\n" + "}\n" + "$inline$" + "void $classname$::set_$name$(const $pointer_type$* value, size_t " + "size) {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " $oneof_prefix$$name$_.SetNoArena($default_variable$, " + "$string_piece$(\n" + " reinterpret_cast<const char*>(value), size));\n" + " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" + "}\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " // @@protoc_insertion_point(field_mutable:$full_name$)\n" + " return $oneof_prefix$$name$_.MutableNoArena($default_variable$);\n" + "}\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" + " return $oneof_prefix$$name$_.ReleaseNoArena($default_variable$);\n" + " } else {\n" + " return NULL;\n" + " }\n" + "}\n" + "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + " if (!has_$name$()) {\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " clear_$oneof_name$();\n" + " if ($name$ != NULL) {\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.SetAllocatedNoArena($default_variable$,\n" + " $name$);\n" + " }\n" + " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" + "}\n"); } } void StringOneofFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); if (dependent_field_) { variables["this_message"] = DependentBaseDownCast(); // This clearing code may be in the dependent base class. If the default @@ -614,8 +700,9 @@ GenerateClearingCode(io::Printer* printer) const { // default value's global singleton instance. See SetStringVariables() for // possible values of default_variable. if (!descriptor_->default_value_string().empty()) { - variables["default_variable"] = - DependentBaseDownCast() + variables["default_variable"]; + variables["default_variable"] = "&" + DependentBaseDownCast() + + variables["default_variable_name"] + + ".get()"; } } else { variables["this_message"] = ""; @@ -632,15 +719,21 @@ GenerateClearingCode(io::Printer* printer) const { } void StringOneofFieldGenerator:: +GenerateMessageClearingCode(io::Printer* printer) const { + return GenerateClearingCode(printer); +} + +void StringOneofFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { // Don't print any swapping code. Swapping the union will swap this field. } void StringOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { - printer->Print(variables_, - " $classname$_default_oneof_instance_->$name$_.UnsafeSetDefault(" - "$default_variable$);\n"); + printer->Print( + variables_, + "$classname$_default_oneof_instance_.$name$_.UnsafeSetDefault(\n" + " $default_variable$);\n"); } void StringOneofFieldGenerator:: @@ -733,7 +826,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void RepeatedStringFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$const ::std::string& $classname$::$name$(int index) const {\n" @@ -800,11 +893,6 @@ 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"); } @@ -815,6 +903,11 @@ GenerateConstructorCode(io::Printer* printer) const { } void RepeatedStringFieldGenerator:: +GenerateCopyConstructorCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_.CopyFrom(from.$name$_);"); +} + +void RepeatedStringFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { printer->Print(variables_, "DO_(::google::protobuf::internal::WireFormatLite::Read$declared_type$(\n" diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.h b/src/google/protobuf/compiler/cpp/cpp_string_field.h index 1dea7663..af263c1a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.h @@ -58,9 +58,11 @@ class StringFieldGenerator : public FieldGenerator { bool is_inline) const; void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; + void GenerateMessageClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateDestructorCode(io::Printer* printer) const; void GenerateDefaultInstanceAllocator(io::Printer* printer) const; void GenerateShutdownCode(io::Printer* printer) const; @@ -71,7 +73,7 @@ class StringFieldGenerator : public FieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator); @@ -87,6 +89,10 @@ class StringOneofFieldGenerator : public StringFieldGenerator { void GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const; void GenerateClearingCode(io::Printer* printer) const; + + // StringFieldGenerator, from which we inherit, overrides this so we need to + // override it as well. + void GenerateMessageClearingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; void GenerateDestructorCode(io::Printer* printer) const; @@ -110,9 +116,9 @@ 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 GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; @@ -120,7 +126,7 @@ class RepeatedStringFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedStringFieldGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_unittest.cc index d214ef0a..8eaddb87 100644 --- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc @@ -67,6 +67,7 @@ #include <google/protobuf/compiler/importer.h> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/zero_copy_stream_impl.h> +#include <google/protobuf/arena.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/dynamic_message.h> @@ -199,14 +200,14 @@ TEST(GeneratedMessageTest, FloatingPointDefaults) { EXPECT_EQ(-1.5f, extreme_default.negative_float()); EXPECT_EQ(2.0e8f, extreme_default.large_float()); EXPECT_EQ(-8e-28f, extreme_default.small_negative_float()); - EXPECT_EQ(numeric_limits<double>::infinity(), + EXPECT_EQ(std::numeric_limits<double>::infinity(), extreme_default.inf_double()); - EXPECT_EQ(-numeric_limits<double>::infinity(), + EXPECT_EQ(-std::numeric_limits<double>::infinity(), extreme_default.neg_inf_double()); EXPECT_TRUE(extreme_default.nan_double() != extreme_default.nan_double()); - EXPECT_EQ(numeric_limits<float>::infinity(), + EXPECT_EQ(std::numeric_limits<float>::infinity(), extreme_default.inf_float()); - EXPECT_EQ(-numeric_limits<float>::infinity(), + EXPECT_EQ(-std::numeric_limits<float>::infinity(), extreme_default.neg_inf_float()); EXPECT_TRUE(extreme_default.nan_float() != extreme_default.nan_float()); } @@ -518,6 +519,26 @@ TEST(GeneratedMessageTest, CopyConstructor) { TestUtil::ExpectAllFieldsSet(message2); } +TEST(GeneratedMessageTest, CopyConstructorWithArenas) { + Arena arena; + unittest::TestAllTypes* message1 = + Arena::CreateMessage<unittest::TestAllTypes>(&arena); + TestUtil::SetAllFields(message1); + + unittest::TestAllTypes message2_stack(*message1); + TestUtil::ExpectAllFieldsSet(message2_stack); + + google::protobuf::scoped_ptr<unittest::TestAllTypes> message2_heap( + new unittest::TestAllTypes(*message1)); + TestUtil::ExpectAllFieldsSet(*message2_heap); + + arena.Reset(); + + // Verify that the copies are still intact. + TestUtil::ExpectAllFieldsSet(message2_stack); + TestUtil::ExpectAllFieldsSet(*message2_heap); +} + TEST(GeneratedMessageTest, CopyAssignmentOperator) { unittest::TestAllTypes message1; TestUtil::SetAllFields(&message1); @@ -600,14 +621,16 @@ TEST(GeneratedMessageTest, NonEmptyMergeFrom) { #if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || \ !defined(GOOGLE_PROTOBUF_NO_RTTI) #ifdef PROTOBUF_HAS_DEATH_TEST +#ifndef NDEBUG TEST(GeneratedMessageTest, MergeFromSelf) { unittest::TestAllTypes message; - EXPECT_DEATH(message.MergeFrom(message), "Check failed:.*pb[.]cc"); + EXPECT_DEATH(message.MergeFrom(message), "pb[.]cc.*Check failed:"); EXPECT_DEATH(message.MergeFrom(implicit_cast<const Message&>(message)), - "Check failed:.*pb[.]cc"); + "pb[.]cc.*Check failed:"); } +#endif // NDEBUG #endif // PROTOBUF_HAS_DEATH_TEST #endif // !PROTOBUF_TEST_NO_DESCRIPTORS || !GOOGLE_PROTOBUF_NO_RTTI diff --git a/src/google/protobuf/compiler/cpp/metadata_test.cc b/src/google/protobuf/compiler/cpp/metadata_test.cc index edd30780..03f6b12b 100644 --- a/src/google/protobuf/compiler/cpp/metadata_test.cc +++ b/src/google/protobuf/compiler/cpp/metadata_test.cc @@ -156,7 +156,7 @@ const char kSmallTestFile[] = // couldn't). const GeneratedCodeInfo::Annotation* FindAnnotationOnPath( const GeneratedCodeInfo& info, const string& source_file, - const vector<int>& path) { + const std::vector<int>& path) { for (int i = 0; i < info.annotation_size(); ++i) { const GeneratedCodeInfo::Annotation* annotation = &info.annotation(i); if (annotation->source_file() != source_file || @@ -197,7 +197,7 @@ TEST_F(CppMetadataTest, CapturesEnumNames) { EXPECT_TRUE( CaptureMetadata("test.proto", &file, &pb_h, &info, NULL, NULL, NULL)); EXPECT_EQ("Enum", file.enum_type(0).name()); - vector<int> enum_path; + std::vector<int> enum_path; enum_path.push_back(FileDescriptorProto::kEnumTypeFieldNumber); enum_path.push_back(0); const GeneratedCodeInfo::Annotation* enum_annotation = @@ -226,7 +226,7 @@ TEST_F(CppMetadataTest, CapturesMessageNames) { EXPECT_TRUE( CaptureMetadata("test.proto", &file, &pb_h, &info, NULL, NULL, NULL)); EXPECT_EQ("Message", file.message_type(0).name()); - vector<int> message_path; + std::vector<int> message_path; message_path.push_back(FileDescriptorProto::kMessageTypeFieldNumber); message_path.push_back(0); const GeneratedCodeInfo::Annotation* message_annotation = diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc index 0d9093c0..462748b9 100644 --- a/src/google/protobuf/compiler/importer.cc +++ b/src/google/protobuf/compiler/importer.cc @@ -270,8 +270,8 @@ static string CanonicalizePath(string path) { } #endif - vector<string> canonical_parts; - vector<string> parts = Split( + std::vector<string> canonical_parts; + std::vector<string> parts = Split( path, "/", true); // Note: Removes empty parts. for (int i = 0; i < parts.size(); i++) { if (parts[i] == ".") { diff --git a/src/google/protobuf/compiler/importer.h b/src/google/protobuf/compiler/importer.h index cc8fcc39..759636e1 100644 --- a/src/google/protobuf/compiler/importer.h +++ b/src/google/protobuf/compiler/importer.h @@ -305,7 +305,7 @@ class LIBPROTOBUF_EXPORT DiskSourceTree : public SourceTree { const string& disk_path_param) : virtual_path(virtual_path_param), disk_path(disk_path_param) {} }; - vector<Mapping> mappings_; + std::vector<Mapping> mappings_; string last_error_message_; // Like Open(), but returns the on-disk path in disk_file if disk_file is diff --git a/src/google/protobuf/compiler/importer_unittest.cc b/src/google/protobuf/compiler/importer_unittest.cc index 1b6e9700..00285bcc 100644 --- a/src/google/protobuf/compiler/importer_unittest.cc +++ b/src/google/protobuf/compiler/importer_unittest.cc @@ -293,7 +293,7 @@ class DiskSourceTreeTest : public testing::Test { DiskSourceTree source_tree_; // Paths of two on-disk directories to use during the test. - vector<string> dirnames_; + std::vector<string> dirnames_; }; TEST_F(DiskSourceTreeTest, MapRoot) { diff --git a/src/google/protobuf/compiler/java/java_context.cc b/src/google/protobuf/compiler/java/java_context.cc index 6cfa14a0..b82fb3dd 100644 --- a/src/google/protobuf/compiler/java/java_context.cc +++ b/src/google/protobuf/compiler/java/java_context.cc @@ -108,7 +108,7 @@ void Context::InitializeFieldGeneratorInfoForMessage( for (int i = 0; i < message->nested_type_count(); ++i) { InitializeFieldGeneratorInfoForMessage(message->nested_type(i)); } - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; for (int i = 0; i < message->field_count(); ++i) { fields.push_back(message->field(i)); } @@ -124,11 +124,11 @@ void Context::InitializeFieldGeneratorInfoForMessage( } void Context::InitializeFieldGeneratorInfoForFields( - const vector<const FieldDescriptor*>& fields) { + const std::vector<const FieldDescriptor*>& fields) { // Find out all fields that conflict with some other field in the same // message. - vector<bool> is_conflict(fields.size()); - vector<string> conflict_reason(fields.size()); + std::vector<bool> is_conflict(fields.size()); + std::vector<string> conflict_reason(fields.size()); for (int i = 0; i < fields.size(); ++i) { const FieldDescriptor* field = fields[i]; const string& name = UnderscoresToCapitalizedCamelCase(field); diff --git a/src/google/protobuf/compiler/java/java_context.h b/src/google/protobuf/compiler/java/java_context.h index f92ae87e..b22e7e3a 100644 --- a/src/google/protobuf/compiler/java/java_context.h +++ b/src/google/protobuf/compiler/java/java_context.h @@ -95,11 +95,13 @@ class Context { void InitializeFieldGeneratorInfo(const FileDescriptor* file); void InitializeFieldGeneratorInfoForMessage(const Descriptor* message); void InitializeFieldGeneratorInfoForFields( - const vector<const FieldDescriptor*>& fields); + const std::vector<const FieldDescriptor*>& fields); google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_; - map<const FieldDescriptor*, FieldGeneratorInfo> field_generator_info_map_; - map<const OneofDescriptor*, OneofGeneratorInfo> oneof_generator_info_map_; + std::map<const FieldDescriptor*, FieldGeneratorInfo> + field_generator_info_map_; + std::map<const OneofDescriptor*, OneofGeneratorInfo> + oneof_generator_info_map_; Options options_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Context); }; diff --git a/src/google/protobuf/compiler/java/java_doc_comment.cc b/src/google/protobuf/compiler/java/java_doc_comment.cc index 0b5caba4..59c04ad4 100644 --- a/src/google/protobuf/compiler/java/java_doc_comment.cc +++ b/src/google/protobuf/compiler/java/java_doc_comment.cc @@ -115,7 +115,7 @@ static void WriteDocCommentBodyForLocation( // HTML-escape them so that they don't accidentally close the doc comment. comments = EscapeJavadoc(comments); - vector<string> lines = Split(comments, "\n"); + std::vector<string> lines = Split(comments, "\n"); while (!lines.empty() && lines.back().empty()) { lines.pop_back(); } diff --git a/src/google/protobuf/compiler/java/java_enum.cc b/src/google/protobuf/compiler/java/java_enum.cc index b46cfe9c..b9ee00ff 100644 --- a/src/google/protobuf/compiler/java/java_enum.cc +++ b/src/google/protobuf/compiler/java/java_enum.cc @@ -49,17 +49,6 @@ namespace protobuf { namespace compiler { namespace java { -namespace { -bool EnumHasCustomOptions(const EnumDescriptor* descriptor) { - if (descriptor->options().unknown_fields().field_count() > 0) return true; - for (int i = 0; i < descriptor->value_count(); ++i) { - const EnumValueDescriptor* value = descriptor->value(i); - if (value->options().unknown_fields().field_count() > 0) return true; - } - return false; -} -} // namespace - EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor, bool immutable_api, Context* context) @@ -105,7 +94,7 @@ void EnumGenerator::Generate(io::Printer* printer) { } for (int i = 0; i < canonical_values_.size(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["name"] = canonical_values_[i]->name(); vars["index"] = SimpleItoa(canonical_values_[i]->index()); vars["number"] = SimpleItoa(canonical_values_[i]->number()); @@ -137,7 +126,7 @@ void EnumGenerator::Generate(io::Printer* printer) { // ----------------------------------------------------------------- for (int i = 0; i < aliases_.size(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = descriptor_->name(); vars["name"] = aliases_[i].value->name(); vars["canonical_name"] = aliases_[i].canonical_value->name(); @@ -147,7 +136,7 @@ void EnumGenerator::Generate(io::Printer* printer) { } for (int i = 0; i < descriptor_->value_count(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["name"] = descriptor_->value(i)->name(); vars["number"] = SimpleItoa(descriptor_->value(i)->number()); WriteEnumValueDocComment(printer, descriptor_->value(i)); @@ -243,49 +232,14 @@ void EnumGenerator::Generate(io::Printer* printer) { // at module init time because it wouldn't work with descriptor.proto, but // we can cache the value the first time getDescriptor() is called. if (descriptor_->containing_type() == NULL) { - if (!MultipleJavaFiles(descriptor_->file(), immutable_api_)) { - printer->Print( - " return $file$.getDescriptor().getEnumTypes().get($index$);\n", - "file", name_resolver_->GetClassName(descriptor_->file(), - immutable_api_), - "index", SimpleItoa(descriptor_->index())); - } else { - printer->Indent(); - if (EnumHasCustomOptions(descriptor_)) { - // We need to load the immutable classes in order to parse custom - // options. However, since file level enums (no outer class) are - // shared by immutable code and mutable code, the immutable classes - // may not exist. So we try to use Java reflection to retrieve the - // descriptor from immutable classes. - printer->Print( - "try {\n" - " java.lang.Class immutableFileClass =\n" - " java.lang.Class.forName(\"$immutable_file_class_name$\");\n" - " @java.lang.SuppressWarnings(\"unchecked\")\n" - " java.lang.reflect.Method m =\n" - " immutableFileClass.getMethod(\"getDescriptor\");\n" - " com.google.protobuf.Descriptors.FileDescriptor file =\n" - " (com.google.protobuf.Descriptors.FileDescriptor)\n" - " m.invoke(immutableFileClass);\n" - " return file.getEnumTypes().get($index$);\n" - "} catch (java.lang.Exception e) {\n" - // Immutable classes cannot be found. Proceed as if custom options - // don't exist. - "}\n", - "immutable_file_class_name", - name_resolver_->GetImmutableClassName(descriptor_->file()), - "index", SimpleItoa(descriptor_->index())); - } - printer->Print( - "return $immutable_package$.$descriptor_class$.$descriptor$\n" - " .getEnumTypes().get($index$);\n", - "immutable_package", FileJavaPackage(descriptor_->file(), true), - "descriptor_class", - name_resolver_->GetDescriptorClassName(descriptor_->file()), - "descriptor", "getDescriptor()", - "index", SimpleItoa(descriptor_->index())); - printer->Outdent(); - } + // The class generated for the File fully populates the descriptor with + // extensions in both the mutable and immutable cases. (In the mutable api + // this is accomplished by attempting to load the immutable outer class). + printer->Print( + " return $file$.getDescriptor().getEnumTypes().get($index$);\n", + "file", name_resolver_->GetClassName(descriptor_->file(), + immutable_api_), + "index", SimpleItoa(descriptor_->index())); } else { printer->Print( " return $parent$.$descriptor$.getEnumTypes().get($index$);\n", diff --git a/src/google/protobuf/compiler/java/java_enum.h b/src/google/protobuf/compiler/java/java_enum.h index c33e713d..13dfc32d 100644 --- a/src/google/protobuf/compiler/java/java_enum.h +++ b/src/google/protobuf/compiler/java/java_enum.h @@ -72,13 +72,13 @@ class EnumGenerator { // considered equivalent. We treat the first defined constant for any // given numeric value as "canonical" and the rest as aliases of that // canonical value. - vector<const EnumValueDescriptor*> canonical_values_; + std::vector<const EnumValueDescriptor*> canonical_values_; struct Alias { const EnumValueDescriptor* value; const EnumValueDescriptor* canonical_value; }; - vector<Alias> aliases_; + std::vector<Alias> aliases_; bool immutable_api_; diff --git a/src/google/protobuf/compiler/java/java_enum_field.cc b/src/google/protobuf/compiler/java/java_enum_field.cc index 2e916c56..279b9da4 100644 --- a/src/google/protobuf/compiler/java/java_enum_field.cc +++ b/src/google/protobuf/compiler/java/java_enum_field.cc @@ -58,7 +58,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["type"] = @@ -68,7 +68,8 @@ void SetEnumVariables(const FieldDescriptor* descriptor, (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver); (*variables)["default_number"] = SimpleItoa( descriptor->default_value_enum()->number()); - (*variables)["tag"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor)); + (*variables)["tag"] = + SimpleItoa(static_cast<int32>(internal::WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor))); // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported diff --git a/src/google/protobuf/compiler/java/java_enum_field.h b/src/google/protobuf/compiler/java/java_enum_field.h index b8ff7343..924ff281 100644 --- a/src/google/protobuf/compiler/java/java_enum_field.h +++ b/src/google/protobuf/compiler/java/java_enum_field.h @@ -82,7 +82,7 @@ class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -143,7 +143,7 @@ class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/src/google/protobuf/compiler/java/java_enum_field_lite.cc index aa0eb5e8..f1dc47fc 100644 --- a/src/google/protobuf/compiler/java/java_enum_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_enum_field_lite.cc @@ -58,7 +58,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["type"] = @@ -68,7 +68,8 @@ void SetEnumVariables(const FieldDescriptor* descriptor, (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver); (*variables)["default_number"] = SimpleItoa( descriptor->default_value_enum()->number()); - (*variables)["tag"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor)); + (*variables)["tag"] = + SimpleItoa(static_cast<int32>(internal::WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor))); // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.h b/src/google/protobuf/compiler/java/java_enum_field_lite.h index 9201b8d6..fa004720 100644 --- a/src/google/protobuf/compiler/java/java_enum_field_lite.h +++ b/src/google/protobuf/compiler/java/java_enum_field_lite.h @@ -81,7 +81,7 @@ class ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -142,7 +142,7 @@ class RepeatedImmutableEnumFieldLiteGenerator private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/java/java_enum_lite.cc b/src/google/protobuf/compiler/java/java_enum_lite.cc index 99f52d40..96815920 100644 --- a/src/google/protobuf/compiler/java/java_enum_lite.cc +++ b/src/google/protobuf/compiler/java/java_enum_lite.cc @@ -95,7 +95,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) { printer->Indent(); for (int i = 0; i < canonical_values_.size(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["name"] = canonical_values_[i]->name(); vars["number"] = SimpleItoa(canonical_values_[i]->number()); WriteEnumValueDocComment(printer, canonical_values_[i]); @@ -117,7 +117,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) { // ----------------------------------------------------------------- for (int i = 0; i < aliases_.size(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = descriptor_->name(); vars["name"] = aliases_[i].value->name(); vars["canonical_name"] = aliases_[i].canonical_value->name(); @@ -127,7 +127,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) { } for (int i = 0; i < descriptor_->value_count(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["name"] = descriptor_->value(i)->name(); vars["number"] = SimpleItoa(descriptor_->value(i)->number()); WriteEnumValueDocComment(printer, descriptor_->value(i)); diff --git a/src/google/protobuf/compiler/java/java_enum_lite.h b/src/google/protobuf/compiler/java/java_enum_lite.h index f27cb76f..b7be912c 100644 --- a/src/google/protobuf/compiler/java/java_enum_lite.h +++ b/src/google/protobuf/compiler/java/java_enum_lite.h @@ -72,13 +72,13 @@ class EnumLiteGenerator { // considered equivalent. We treat the first defined constant for any // given numeric value as "canonical" and the rest as aliases of that // canonical value. - vector<const EnumValueDescriptor*> canonical_values_; + std::vector<const EnumValueDescriptor*> canonical_values_; struct Alias { const EnumValueDescriptor* value; const EnumValueDescriptor* canonical_value; }; - vector<Alias> aliases_; + std::vector<Alias> aliases_; bool immutable_api_; diff --git a/src/google/protobuf/compiler/java/java_extension.cc b/src/google/protobuf/compiler/java/java_extension.cc index 46b5faaa..cb237bf6 100644 --- a/src/google/protobuf/compiler/java/java_extension.cc +++ b/src/google/protobuf/compiler/java/java_extension.cc @@ -61,12 +61,10 @@ ImmutableExtensionGenerator::ImmutableExtensionGenerator( ImmutableExtensionGenerator::~ImmutableExtensionGenerator() {} // Initializes the vars referenced in the generated code templates. -void ExtensionGenerator::InitTemplateVars(const FieldDescriptor* descriptor, - const string& scope, - bool immutable, - ClassNameResolver* name_resolver, - map<string, string>* vars_pointer) { - map<string, string> &vars = *vars_pointer; +void ExtensionGenerator::InitTemplateVars( + const FieldDescriptor* descriptor, const string& scope, bool immutable, + ClassNameResolver* name_resolver, std::map<string, string>* vars_pointer) { + std::map<string, string> &vars = *vars_pointer; vars["scope"] = scope; vars["name"] = UnderscoresToCamelCase(descriptor); vars["containing_type"] = @@ -110,7 +108,7 @@ void ExtensionGenerator::InitTemplateVars(const FieldDescriptor* descriptor, } void ImmutableExtensionGenerator::Generate(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; const bool kUseImmutableNames = true; InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_, &vars); diff --git a/src/google/protobuf/compiler/java/java_extension.h b/src/google/protobuf/compiler/java/java_extension.h index bdd42263..fb8d5201 100644 --- a/src/google/protobuf/compiler/java/java_extension.h +++ b/src/google/protobuf/compiler/java/java_extension.h @@ -79,7 +79,7 @@ class ExtensionGenerator { const string& scope, bool immutable, ClassNameResolver* name_resolver, - map<string, string>* vars_pointer); + std::map<string, string>* vars_pointer); private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); diff --git a/src/google/protobuf/compiler/java/java_extension_lite.cc b/src/google/protobuf/compiler/java/java_extension_lite.cc index 23261bac..c48c92e9 100644 --- a/src/google/protobuf/compiler/java/java_extension_lite.cc +++ b/src/google/protobuf/compiler/java/java_extension_lite.cc @@ -57,7 +57,7 @@ ImmutableExtensionLiteGenerator::ImmutableExtensionLiteGenerator( ImmutableExtensionLiteGenerator::~ImmutableExtensionLiteGenerator() {} void ImmutableExtensionLiteGenerator::Generate(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; const bool kUseImmutableNames = true; InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_, &vars); diff --git a/src/google/protobuf/compiler/java/java_field.cc b/src/google/protobuf/compiler/java/java_field.cc index 3c7bc5c4..04917296 100644 --- a/src/google/protobuf/compiler/java/java_field.cc +++ b/src/google/protobuf/compiler/java/java_field.cc @@ -290,7 +290,7 @@ FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap() {} void SetCommonFieldVariables(const FieldDescriptor* descriptor, const FieldGeneratorInfo* info, - map<string, string>* variables) { + std::map<string, string>* variables) { (*variables)["field_name"] = descriptor->name(); (*variables)["name"] = info->name; (*variables)["capitalized_name"] = info->capitalized_name; @@ -301,7 +301,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, void SetCommonOneofVariables(const FieldDescriptor* descriptor, const OneofGeneratorInfo* info, - map<string, string>* variables) { + std::map<string, string>* variables) { (*variables)["oneof_name"] = info->name; (*variables)["oneof_capitalized_name"] = info->capitalized_name; (*variables)["oneof_index"] = @@ -314,9 +314,9 @@ void SetCommonOneofVariables(const FieldDescriptor* descriptor, "Case_ == " + SimpleItoa(descriptor->number()); } -void PrintExtraFieldInfo(const map<string, string>& variables, +void PrintExtraFieldInfo(const std::map<string, string>& variables, io::Printer* printer) { - const map<string, string>::const_iterator it = + const std::map<string, string>::const_iterator it = variables.find("disambiguated_reason"); if (it != variables.end() && !it->second.empty()) { printer->Print( diff --git a/src/google/protobuf/compiler/java/java_field.h b/src/google/protobuf/compiler/java/java_field.h index 4dd4f57f..434e610c 100644 --- a/src/google/protobuf/compiler/java/java_field.h +++ b/src/google/protobuf/compiler/java/java_field.h @@ -169,7 +169,7 @@ struct FieldGeneratorInfo { string disambiguated_reason; }; -// Oneof information used in OneofFieldGeneartors. +// Oneof information used in OneofFieldGenerators. struct OneofGeneratorInfo { string name; string capitalized_name; @@ -178,15 +178,15 @@ struct OneofGeneratorInfo { // Set some common variables used in variable FieldGenerators. void SetCommonFieldVariables(const FieldDescriptor* descriptor, const FieldGeneratorInfo* info, - map<string, string>* variables); + std::map<string, string>* variables); // Set some common oneof variables used in OneofFieldGenerators. void SetCommonOneofVariables(const FieldDescriptor* descriptor, const OneofGeneratorInfo* info, - map<string, string>* variables); + std::map<string, string>* variables); // Print useful comments before a field's accessors. -void PrintExtraFieldInfo(const map<string, string>& variables, +void PrintExtraFieldInfo(const std::map<string, string>& variables, io::Printer* printer); } // namespace java diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc index 3cbc530e..cb4503f6 100644 --- a/src/google/protobuf/compiler/java/java_file.cc +++ b/src/google/protobuf/compiler/java/java_file.cc @@ -90,7 +90,7 @@ bool CollectExtensions(const Message& message, // There are unknown fields that could be extensions, thus this call fails. if (reflection->GetUnknownFields(message).field_count() > 0) return false; - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message, &fields); for (int i = 0; i < fields.size(); i++) { @@ -541,8 +541,8 @@ static void GenerateSibling(const string& package_dir, const string& java_package, const DescriptorClass* descriptor, GeneratorContext* context, - vector<string>* file_list, bool annotate_code, - vector<string>* annotation_list, + std::vector<string>* file_list, bool annotate_code, + std::vector<string>* annotation_list, const string& name_suffix, GeneratorClass* generator, void (GeneratorClass::*pfn)(io::Printer* printer)) { @@ -581,8 +581,8 @@ static void GenerateSibling(const string& package_dir, void FileGenerator::GenerateSiblings(const string& package_dir, GeneratorContext* context, - vector<string>* file_list, - vector<string>* annotation_list) { + std::vector<string>* file_list, + std::vector<string>* annotation_list) { if (MultipleJavaFiles(file_, immutable_api_)) { for (int i = 0; i < file_->enum_type_count(); i++) { if (HasDescriptorMethods(file_, context_->EnforceLite())) { diff --git a/src/google/protobuf/compiler/java/java_file.h b/src/google/protobuf/compiler/java/java_file.h index 1e643f79..e95aef09 100644 --- a/src/google/protobuf/compiler/java/java_file.h +++ b/src/google/protobuf/compiler/java/java_file.h @@ -84,8 +84,8 @@ class FileGenerator { // service type). void GenerateSiblings(const string& package_dir, GeneratorContext* generator_context, - vector<string>* file_list, - vector<string>* annotation_list); + std::vector<string>* file_list, + std::vector<string>* annotation_list); const string& java_package() { return java_package_; } const string& classname() { return classname_; } diff --git a/src/google/protobuf/compiler/java/java_generator.cc b/src/google/protobuf/compiler/java/java_generator.cc index b1ab4043..2c02d996 100644 --- a/src/google/protobuf/compiler/java/java_generator.cc +++ b/src/google/protobuf/compiler/java/java_generator.cc @@ -66,7 +66,7 @@ bool JavaGenerator::Generate(const FileDescriptor* file, // parse generator options - vector<pair<string, string> > options; + std::vector<std::pair<string, string> > options; ParseGeneratorParameter(parameter, &options); Options file_options; @@ -105,11 +105,11 @@ bool JavaGenerator::Generate(const FileDescriptor* file, // ----------------------------------------------------------------- - vector<string> all_files; - vector<string> all_annotations; + std::vector<string> all_files; + std::vector<string> all_annotations; - vector<FileGenerator*> file_generators; + std::vector<FileGenerator*> file_generators; if (file_options.generate_immutable_code) { file_generators.push_back(new FileGenerator(file, file_options, /* immutable = */ true)); diff --git a/src/google/protobuf/compiler/java/java_helpers.cc b/src/google/protobuf/compiler/java/java_helpers.cc index c31df265..efb5fd45 100644 --- a/src/google/protobuf/compiler/java/java_helpers.cc +++ b/src/google/protobuf/compiler/java/java_helpers.cc @@ -360,6 +360,7 @@ const char* BoxedPrimitiveTypeName(JavaType type) { return NULL; } + const char* FieldTypeName(FieldDescriptor::Type field_type) { switch (field_type) { case FieldDescriptor::TYPE_INT32 : return "INT32"; @@ -415,9 +416,9 @@ string DefaultValue(const FieldDescriptor* field, bool immutable, "L"; case FieldDescriptor::CPPTYPE_DOUBLE: { double value = field->default_value_double(); - if (value == numeric_limits<double>::infinity()) { + if (value == std::numeric_limits<double>::infinity()) { return "Double.POSITIVE_INFINITY"; - } else if (value == -numeric_limits<double>::infinity()) { + } else if (value == -std::numeric_limits<double>::infinity()) { return "Double.NEGATIVE_INFINITY"; } else if (value != value) { return "Double.NaN"; @@ -427,9 +428,9 @@ string DefaultValue(const FieldDescriptor* field, bool immutable, } case FieldDescriptor::CPPTYPE_FLOAT: { float value = field->default_value_float(); - if (value == numeric_limits<float>::infinity()) { + if (value == std::numeric_limits<float>::infinity()) { return "Float.POSITIVE_INFINITY"; - } else if (value == -numeric_limits<float>::infinity()) { + } else if (value == -std::numeric_limits<float>::infinity()) { return "Float.NEGATIVE_INFINITY"; } else if (value != value) { return "Float.NaN"; diff --git a/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc b/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc index dac1b51f..49070ba0 100644 --- a/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc @@ -446,8 +446,7 @@ GenerateMembers(io::Printer* printer) const { " for (com.google.protobuf.LazyFieldLite lf : $name$_) {\n" " list.add(($type$) lf.getValue($type$.getDefaultInstance()));\n" " }\n" - // TODO(dweis): Make this list immutable? - " return list;\n" + " return java.util.Collections.unmodifiableList(list);\n" "}\n"); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, diff --git a/src/google/protobuf/compiler/java/java_map_field.cc b/src/google/protobuf/compiler/java/java_map_field.cc index 07aa3565..3fe68ae3 100644 --- a/src/google/protobuf/compiler/java/java_map_field.cc +++ b/src/google/protobuf/compiler/java/java_map_field.cc @@ -80,7 +80,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, Context* context, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); ClassNameResolver* name_resolver = context->GetNameResolver(); @@ -308,6 +308,16 @@ GenerateMembers(io::Printer* printer) const { " com.google.protobuf.Internal.MapAdapter.newEnumConverter(\n" " $value_enum_type$.internalGetValueMap(),\n" " $unrecognized_value$);\n"); + printer->Print( + variables_, + "private static final java.util.Map<$boxed_key_type$, " + "$value_enum_type$>\n" + "internalGetAdapted$capitalized_name$Map(\n" + " java.util.Map<$boxed_key_type$, $boxed_value_type$> map) {\n" + " return new com.google.protobuf.Internal.MapAdapter<\n" + " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n" + " map, $name$ValueConverter);\n" + "}\n"); } GenerateMapGetters(printer); } @@ -339,23 +349,23 @@ GenerateBuilderMembers(io::Printer* printer) const { " return $name$_;\n" "}\n"); GenerateMapGetters(printer); - printer->Print( - variables_, - "$deprecation$\n" - "public Builder clear$capitalized_name$() {\n" - " getMutable$capitalized_name$().clear();\n" - " return this;\n" - "}\n"); + printer->Print(variables_, + "$deprecation$\n" + "public Builder clear$capitalized_name$() {\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .clear();\n" + " return this;\n" + "}\n"); WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "$deprecation$\n" - "public Builder remove$capitalized_name$(\n" - " $key_type$ key) {\n" - " $key_null_check$\n" - " getMutable$capitalized_name$().remove(key);\n" - " return this;\n" - "}\n"); + printer->Print(variables_, + "$deprecation$\n" + "public Builder remove$capitalized_name$(\n" + " $key_type$ key) {\n" + " $key_null_check$\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .remove(key);\n" + " return this;\n" + "}\n"); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print( variables_, @@ -365,30 +375,28 @@ GenerateBuilderMembers(io::Printer* printer) const { "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" "getMutable$capitalized_name$() {\n" - " return new com.google.protobuf.Internal.MapAdapter<\n" - " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n" - " internalGetMutable$capitalized_name$().getMutableMap(),\n" - " $name$ValueConverter);\n" + " return internalGetAdapted$capitalized_name$Map(\n" + " internalGetMutable$capitalized_name$().getMutableMap());\n" "}\n"); WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "$deprecation$public Builder put$capitalized_name$(\n" - " $key_type$ key,\n" - " $value_enum_type$ value) {\n" - " $key_null_check$\n" - " $value_null_check$\n" - " getMutable$capitalized_name$().put(key, value);\n" - " return this;\n" - "}\n"); + printer->Print(variables_, + "$deprecation$public Builder put$capitalized_name$(\n" + " $key_type$ key,\n" + " $value_enum_type$ value) {\n" + " $key_null_check$\n" + " $value_null_check$\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .put(key, $name$ValueConverter.doBackward(value));\n" + " return this;\n" + "}\n"); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - // TODO(arielb): null check map keys/values here and everywhere else - // related to putAll "$deprecation$public Builder putAll$capitalized_name$(\n" " java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\n" - " getMutable$capitalized_name$().putAll(values);\n" + " internalGetAdapted$capitalized_name$Map(\n" + " internalGetMutable$capitalized_name$().getMutableMap())\n" + " .putAll(values);\n" " return this;\n" "}\n"); if (SupportUnknownEnumValue(descriptor_->file())) { @@ -412,7 +420,8 @@ GenerateBuilderMembers(io::Printer* printer) const { " if ($value_enum_type$.forNumber(value) == null) {\n" " throw new java.lang.IllegalArgumentException();\n" " }\n" - " getMutable$capitalized_name$Value().put(key, value);\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .put(key, value);\n" " return this;\n" "}\n"); WriteFieldDocComment(printer, descriptor_); @@ -420,7 +429,8 @@ GenerateBuilderMembers(io::Printer* printer) const { variables_, "$deprecation$public Builder putAll$capitalized_name$Value(\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n" - " getMutable$capitalized_name$Value().putAll(values);\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .putAll(values);\n" " return this;\n" "}\n"); } @@ -436,26 +446,26 @@ GenerateBuilderMembers(io::Printer* printer) const { " return internalGetMutable$capitalized_name$().getMutableMap();\n" "}\n"); WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "$deprecation$" - "public Builder put$capitalized_name$(\n" - " $key_type$ key,\n" - " $value_type$ value) {\n" - " $key_null_check$\n" - " $value_null_check$\n" - " getMutable$capitalized_name$().put(key, value);\n" - " return this;\n" - "}\n"); + printer->Print(variables_, + "$deprecation$" + "public Builder put$capitalized_name$(\n" + " $key_type$ key,\n" + " $value_type$ value) {\n" + " $key_null_check$\n" + " $value_null_check$\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .put(key, value);\n" + " return this;\n" + "}\n"); WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "$deprecation$\n" - "public Builder putAll$capitalized_name$(\n" - " java.util.Map<$type_parameters$> values) {\n" - " getMutable$capitalized_name$().putAll(values);\n" - " return this;\n" - "}\n"); + printer->Print(variables_, + "$deprecation$\n" + "public Builder putAll$capitalized_name$(\n" + " java.util.Map<$type_parameters$> values) {\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .putAll(values);\n" + " return this;\n" + "}\n"); } } @@ -488,16 +498,13 @@ GenerateMapGetters(io::Printer* printer) const { " return get$capitalized_name$Map();\n" "}\n"); WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "$deprecation$\n" - "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "get$capitalized_name$Map() {\n" - " return new com.google.protobuf.Internal.MapAdapter<\n" - " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n" - " internalGet$capitalized_name$().getMap(),\n" - " $name$ValueConverter);\n" - "}\n"); + printer->Print(variables_, + "$deprecation$\n" + "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" + "get$capitalized_name$Map() {\n" + " return internalGetAdapted$capitalized_name$Map(\n" + " internalGet$capitalized_name$().getMap());" + "}\n"); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, diff --git a/src/google/protobuf/compiler/java/java_map_field.h b/src/google/protobuf/compiler/java/java_map_field.h index ae7ce7c5..47021740 100644 --- a/src/google/protobuf/compiler/java/java_map_field.h +++ b/src/google/protobuf/compiler/java/java_map_field.h @@ -67,7 +67,7 @@ class ImmutableMapFieldGenerator : public ImmutableFieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; ClassNameResolver* name_resolver_; void GenerateMapGetters(io::Printer* printer) const; }; 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 5f102e07..523052cc 100644 --- a/src/google/protobuf/compiler/java/java_map_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_map_field_lite.cc @@ -80,7 +80,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, Context* context, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); ClassNameResolver* name_resolver = context->GetNameResolver(); diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.h b/src/google/protobuf/compiler/java/java_map_field_lite.h index 555b5c5b..63dedbc2 100644 --- a/src/google/protobuf/compiler/java/java_map_field_lite.h +++ b/src/google/protobuf/compiler/java/java_map_field_lite.h @@ -66,7 +66,7 @@ class ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; ClassNameResolver* name_resolver_; }; diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc index 68d28b05..df4db463 100644 --- a/src/google/protobuf/compiler/java/java_message.cc +++ b/src/google/protobuf/compiler/java/java_message.cc @@ -110,7 +110,7 @@ void ImmutableMessageGenerator::GenerateStaticVariables( // the outermost class in the file. This way, they will be initialized in // a deterministic order. - map<string, string> vars; + std::map<string, string> vars; vars["identifier"] = UniqueFileScopeIdentifier(descriptor_); vars["index"] = SimpleItoa(descriptor_->index()); vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_); @@ -154,7 +154,7 @@ void ImmutableMessageGenerator::GenerateStaticVariables( int ImmutableMessageGenerator::GenerateStaticVariableInitializers( io::Printer* printer) { int bytecode_estimate = 0; - map<string, string> vars; + std::map<string, string> vars; vars["identifier"] = UniqueFileScopeIdentifier(descriptor_); vars["index"] = SimpleItoa(descriptor_->index()); vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_); @@ -191,7 +191,7 @@ int ImmutableMessageGenerator::GenerateStaticVariableInitializers( void ImmutableMessageGenerator:: GenerateFieldAccessorTable(io::Printer* printer, int* bytecode_estimate) { - map<string, string> vars; + std::map<string, string> vars; vars["identifier"] = UniqueFileScopeIdentifier(descriptor_); if (MultipleJavaFiles(descriptor_->file(), /* immutable = */ true)) { // We can only make these package-private since the classes that use them @@ -299,7 +299,7 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) { void ImmutableMessageGenerator::Generate(io::Printer* printer) { bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true); - map<string, string> variables; + std::map<string, string> variables; variables["static"] = is_own_file ? " " : " static "; variables["classname"] = descriptor_->name(); variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_); @@ -409,7 +409,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { } // oneof - map<string, string> vars; + std::map<string, string> vars; for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { vars["oneof_name"] = context_->GetOneofGeneratorInfo( descriptor_->oneof_decl(i))->name; @@ -561,13 +561,12 @@ GenerateMessageSerializationMethods(io::Printer* printer) { google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields( SortFieldsByNumber(descriptor_)); - vector<const Descriptor::ExtensionRange*> sorted_extensions; + 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)); } std::sort(sorted_extensions.begin(), sorted_extensions.end(), ExtensionRangeOrdering()); - printer->Print( "public void writeTo(com.google.protobuf.CodedOutputStream output)\n" " throws java.io.IOException {\n"); @@ -799,7 +798,7 @@ GenerateDescriptorMethods(io::Printer* printer) { "fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()), "identifier", UniqueFileScopeIdentifier(descriptor_)); } - vector<const FieldDescriptor*> map_fields; + std::vector<const FieldDescriptor*> map_fields; for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); if (GetJavaType(field) == JAVATYPE_MESSAGE && @@ -1093,7 +1092,12 @@ GenerateEqualsAndHashCode(io::Printer* printer) { "}\n" "int hash = 41;\n"); - printer->Print("hash = (19 * hash) + getDescriptorForType().hashCode();\n"); + // If we output a getDescriptor() method, use that as it is more efficient. + if (descriptor_->options().no_standard_descriptor_accessor()) { + printer->Print("hash = (19 * hash) + getDescriptorForType().hashCode();\n"); + } else { + printer->Print("hash = (19 * hash) + getDescriptor().hashCode();\n"); + } // hashCode non-oneofs. for (int i = 0; i < descriptor_->field_count(); i++) { @@ -1254,7 +1258,7 @@ GenerateParsingConstructor(io::Printer* printer) { printer->Print( "case $tag$: {\n", - "tag", SimpleItoa(tag)); + "tag", SimpleItoa(static_cast<int32>(tag))); printer->Indent(); field_generators_.get(field).GenerateParsingCode(printer); @@ -1271,7 +1275,7 @@ GenerateParsingConstructor(io::Printer* printer) { WireFormatLite::WIRETYPE_LENGTH_DELIMITED); printer->Print( "case $tag$: {\n", - "tag", SimpleItoa(packed_tag)); + "tag", SimpleItoa(static_cast<int32>(packed_tag))); printer->Indent(); field_generators_.get(field).GenerateParsingCodeFromPacked(printer); @@ -1417,7 +1421,7 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) { "}\n" "\n" "/**\n" - " * Packs a message uisng the given type URL prefix. The type URL will\n" + " * Packs a message using the given type URL prefix. The type URL will\n" " * be constructed by concatenating the message type's full name to the\n" " * prefix with an optional \"/\" separator if the prefix doesn't end\n" " * with \"/\" already.\n" diff --git a/src/google/protobuf/compiler/java/java_message_builder.cc b/src/google/protobuf/compiler/java/java_message_builder.cc index cd82c51a..f5643abc 100644 --- a/src/google/protobuf/compiler/java/java_message_builder.cc +++ b/src/google/protobuf/compiler/java/java_message_builder.cc @@ -122,7 +122,7 @@ Generate(io::Printer* printer) { } // oneof - map<string, string> vars; + std::map<string, string> vars; for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { vars["oneof_name"] = context_->GetOneofGeneratorInfo( descriptor_->oneof_decl(i))->name; @@ -225,7 +225,7 @@ GenerateDescriptorMethods(io::Printer* printer) { "fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()), "identifier", UniqueFileScopeIdentifier(descriptor_)); } - vector<const FieldDescriptor*> map_fields; + std::vector<const FieldDescriptor*> map_fields; for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); if (GetJavaType(field) == JAVATYPE_MESSAGE && diff --git a/src/google/protobuf/compiler/java/java_message_builder_lite.cc b/src/google/protobuf/compiler/java/java_message_builder_lite.cc index dd429dc9..7e404ba1 100644 --- a/src/google/protobuf/compiler/java/java_message_builder_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_builder_lite.cc @@ -106,7 +106,7 @@ Generate(io::Printer* printer) { GenerateCommonBuilderMethods(printer); // oneof - map<string, string> vars; + std::map<string, string> vars; for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { vars["oneof_name"] = context_->GetOneofGeneratorInfo( descriptor_->oneof_decl(i))->name; diff --git a/src/google/protobuf/compiler/java/java_message_field.cc b/src/google/protobuf/compiler/java/java_message_field.cc index c9865dda..ae84db1c 100644 --- a/src/google/protobuf/compiler/java/java_message_field.cc +++ b/src/google/protobuf/compiler/java/java_message_field.cc @@ -56,7 +56,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["type"] = diff --git a/src/google/protobuf/compiler/java/java_message_field.h b/src/google/protobuf/compiler/java/java_message_field.h index ea8225a5..7ee0edb2 100644 --- a/src/google/protobuf/compiler/java/java_message_field.h +++ b/src/google/protobuf/compiler/java/java_message_field.h @@ -82,7 +82,7 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -148,7 +148,7 @@ class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; 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 cba18360..fd78f75a 100644 --- a/src/google/protobuf/compiler/java/java_message_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_field_lite.cc @@ -56,7 +56,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["type"] = diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.h b/src/google/protobuf/compiler/java/java_message_field_lite.h index 61321547..dbb263de 100644 --- a/src/google/protobuf/compiler/java/java_message_field_lite.h +++ b/src/google/protobuf/compiler/java/java_message_field_lite.h @@ -81,7 +81,7 @@ class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -139,7 +139,7 @@ class RepeatedImmutableMessageFieldLiteGenerator protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc index 0c5a1f8a..8cc0f01d 100644 --- a/src/google/protobuf/compiler/java/java_message_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_lite.cc @@ -170,7 +170,7 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) { void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true); - map<string, string> variables; + std::map<string, string> variables; variables["static"] = is_own_file ? " " : " static "; variables["classname"] = descriptor_->name(); variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_); @@ -236,13 +236,13 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { } // oneof - map<string, string> vars; + std::map<string, string> vars; for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - vars["oneof_name"] = context_->GetOneofGeneratorInfo( - descriptor_->oneof_decl(i))->name; + const OneofDescriptor* oneof = descriptor_->oneof_decl(i); + vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name; vars["oneof_capitalized_name"] = context_->GetOneofGeneratorInfo( - descriptor_->oneof_decl(i))->capitalized_name; - vars["oneof_index"] = SimpleItoa(descriptor_->oneof_decl(i)->index()); + oneof)->capitalized_name; + vars["oneof_index"] = SimpleItoa(oneof->index()); // oneofCase_ and oneof_ printer->Print(vars, "private int $oneof_name$Case_ = 0;\n" @@ -252,8 +252,8 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { "public enum $oneof_capitalized_name$Case\n" " implements com.google.protobuf.Internal.EnumLite {\n"); printer->Indent(); - for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + for (int j = 0; j < oneof->field_count(); j++) { + const FieldDescriptor* field = oneof->field(j); printer->Print( "$field_name$($field_number$),\n", "field_name", @@ -281,8 +281,8 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { "\n" "public static $oneof_capitalized_name$Case forNumber(int value) {\n" " switch (value) {\n"); - for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + for (int j = 0; j < oneof->field_count(); j++) { + const FieldDescriptor* field = oneof->field(j); printer->Print( " case $field_number$: return $field_name$;\n", "field_number", @@ -467,7 +467,7 @@ GenerateMessageSerializationMethods(io::Printer* printer) { google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields( SortFieldsByNumber(descriptor_)); - vector<const Descriptor::ExtensionRange*> sorted_extensions; + 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)); } @@ -523,8 +523,13 @@ GenerateMessageSerializationMethods(io::Printer* printer) { } if (PreserveUnknownFields(descriptor_)) { - printer->Print( - "unknownFields.writeTo(output);\n"); + if (descriptor_->options().message_set_wire_format()) { + printer->Print( + "unknownFields.writeAsMessageSetTo(output);\n"); + } else { + printer->Print( + "unknownFields.writeTo(output);\n"); + } } printer->Outdent(); @@ -553,8 +558,13 @@ GenerateMessageSerializationMethods(io::Printer* printer) { } if (PreserveUnknownFields(descriptor_)) { - printer->Print( - "size += unknownFields.getSerializedSize();\n"); + if (descriptor_->options().message_set_wire_format()) { + printer->Print( + "size += unknownFields.getSerializedSizeAsMessageSet();\n"); + } else { + printer->Print( + "size += unknownFields.getSerializedSize();\n"); + } } printer->Outdent(); @@ -939,14 +949,26 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream( if (PreserveUnknownFields(descriptor_)) { if (descriptor_->extension_range_count() > 0) { - printer->Print( - "default: {\n" - " if (!parseUnknownField(getDefaultInstanceForType(),\n" - " input, extensionRegistry, tag)) {\n" - " done = true;\n" // it's an endgroup tag - " }\n" - " break;\n" - "}\n"); + if (descriptor_->options().message_set_wire_format()) { + printer->Print( + "default: {\n" + " if (!parseUnknownFieldAsMessageSet(\n" + " getDefaultInstanceForType(), input, extensionRegistry,\n" + " tag)) {\n" + " done = true;\n" // it's an endgroup tag + " }\n" + " break;\n" + "}\n"); + } else { + printer->Print( + "default: {\n" + " if (!parseUnknownField(getDefaultInstanceForType(),\n" + " input, extensionRegistry, tag)) {\n" + " done = true;\n" // it's an endgroup tag + " }\n" + " break;\n" + "}\n"); + } } else { printer->Print( "default: {\n" @@ -975,7 +997,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream( printer->Print( "case $tag$: {\n", - "tag", SimpleItoa(tag)); + "tag", SimpleItoa(static_cast<int32>(tag))); printer->Indent(); field_generators_.get(field).GenerateParsingCode(printer); @@ -992,7 +1014,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream( WireFormatLite::WIRETYPE_LENGTH_DELIMITED); printer->Print( "case $tag$: {\n", - "tag", SimpleItoa(packed_tag)); + "tag", SimpleItoa(static_cast<int32>(packed_tag))); printer->Indent(); field_generators_.get(field).GenerateParsingCodeFromPacked(printer); diff --git a/src/google/protobuf/compiler/java/java_name_resolver.h b/src/google/protobuf/compiler/java/java_name_resolver.h index 570d8d8f..28b049d1 100644 --- a/src/google/protobuf/compiler/java/java_name_resolver.h +++ b/src/google/protobuf/compiler/java/java_name_resolver.h @@ -112,7 +112,7 @@ class ClassNameResolver { const FileDescriptor* file, bool immutable); // Caches the result to provide better performance. - map<const FileDescriptor*, string> file_immutable_outer_class_names_; + std::map<const FileDescriptor*, string> file_immutable_outer_class_names_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ClassNameResolver); }; diff --git a/src/google/protobuf/compiler/java/java_primitive_field.cc b/src/google/protobuf/compiler/java/java_primitive_field.cc index 877baf0a..fa1047e8 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field.cc @@ -61,7 +61,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["type"] = PrimitiveTypeName(GetJavaType(descriptor)); @@ -75,7 +75,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, "" : ("= " + ImmutableDefaultValue(descriptor, name_resolver)); (*variables)["capitalized_type"] = GetCapitalizedType(descriptor, /* immutable = */ true); - (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor)); + (*variables)["tag"] = + SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); if (IsReferenceType(GetJavaType(descriptor))) { diff --git a/src/google/protobuf/compiler/java/java_primitive_field.h b/src/google/protobuf/compiler/java/java_primitive_field.h index d0cd12d9..7ac9bbfb 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field.h +++ b/src/google/protobuf/compiler/java/java_primitive_field.h @@ -82,7 +82,7 @@ class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -143,7 +143,7 @@ class RepeatedImmutablePrimitiveFieldGenerator private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc index ad2db30c..ac39f4cf 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc @@ -61,7 +61,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); JavaType javaType = GetJavaType(descriptor); (*variables)["type"] = PrimitiveTypeName(javaType); @@ -70,7 +70,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver); (*variables)["capitalized_type"] = GetCapitalizedType(descriptor, /* immutable = */ true); - (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor)); + (*variables)["tag"] = + SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.h b/src/google/protobuf/compiler/java/java_primitive_field_lite.h index 6cfbbb98..dc59f0cf 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field_lite.h +++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.h @@ -84,7 +84,7 @@ class ImmutablePrimitiveFieldLiteGenerator protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -146,7 +146,7 @@ class RepeatedImmutablePrimitiveFieldLiteGenerator private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/java/java_service.cc b/src/google/protobuf/compiler/java/java_service.cc index cfa8295d..988e1942 100644 --- a/src/google/protobuf/compiler/java/java_service.cc +++ b/src/google/protobuf/compiler/java/java_service.cc @@ -208,7 +208,7 @@ void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) { for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> vars; + std::map<string, string> vars; vars["index"] = SimpleItoa(i); vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName( @@ -255,7 +255,7 @@ void ImmutableServiceGenerator::GenerateCallBlockingMethod( for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> vars; + std::map<string, string> vars; vars["index"] = SimpleItoa(i); vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName( @@ -301,7 +301,7 @@ void ImmutableServiceGenerator::GenerateGetPrototype(RequestOrResponse which, for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> vars; + std::map<string, string> vars; vars["index"] = SimpleItoa(i); vars["type"] = name_resolver_->GetImmutableClassName( (which == REQUEST) ? method->input_type() : method->output_type()); @@ -353,7 +353,7 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) { printer->Print(" {\n"); printer->Indent(); - map<string, string> vars; + std::map<string, string> vars; vars["index"] = SimpleItoa(i); vars["output"] = GetOutput(method); printer->Print(vars, @@ -417,7 +417,7 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) { printer->Print(" {\n"); printer->Indent(); - map<string, string> vars; + std::map<string, string> vars; vars["index"] = SimpleItoa(i); vars["output"] = GetOutput(method); printer->Print(vars, @@ -440,7 +440,7 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) { void ImmutableServiceGenerator::GenerateMethodSignature(io::Printer* printer, const MethodDescriptor* method, IsAbstract is_abstract) { - map<string, string> vars; + std::map<string, string> vars; vars["name"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName(method->input_type()); vars["output"] = GetOutput(method); @@ -455,7 +455,7 @@ void ImmutableServiceGenerator::GenerateMethodSignature(io::Printer* printer, void ImmutableServiceGenerator::GenerateBlockingMethodSignature( io::Printer* printer, const MethodDescriptor* method) { - map<string, string> vars; + std::map<string, string> vars; vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName(method->input_type()); vars["output"] = GetOutput(method); 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 18bf1f51..5fe68245 100644 --- a/src/google/protobuf/compiler/java/java_shared_code_generator.cc +++ b/src/google/protobuf/compiler/java/java_shared_code_generator.cc @@ -59,8 +59,8 @@ SharedCodeGenerator::~SharedCodeGenerator() { } void SharedCodeGenerator::Generate(GeneratorContext* context, - vector<string>* file_list, - vector<string>* annotation_file_list) { + std::vector<string>* file_list, + std::vector<string>* annotation_file_list) { string java_package = FileJavaPackage(file_); string package_dir = JavaPackageToDir(java_package); @@ -179,7 +179,7 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) { // ----------------------------------------------------------------- // Find out all dependencies. - vector<pair<string, string> > dependencies; + std::vector<std::pair<string, string> > dependencies; for (int i = 0; i < file_->dependency_count(); i++) { if (ShouldIncludeDependency(file_->dependency(i))) { string filename = file_->dependency(i)->name(); diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.h b/src/google/protobuf/compiler/java/java_shared_code_generator.h index 7e1e1f17..c8ead47a 100644 --- a/src/google/protobuf/compiler/java/java_shared_code_generator.h +++ b/src/google/protobuf/compiler/java/java_shared_code_generator.h @@ -70,8 +70,9 @@ class SharedCodeGenerator { SharedCodeGenerator(const FileDescriptor* file, const Options& options); ~SharedCodeGenerator(); - void Generate(GeneratorContext* generator_context, vector<string>* file_list, - vector<string>* annotation_file_list); + void Generate(GeneratorContext* generator_context, + std::vector<string>* file_list, + std::vector<string>* annotation_file_list); void GenerateDescriptors(io::Printer* printer); diff --git a/src/google/protobuf/compiler/java/java_string_field.cc b/src/google/protobuf/compiler/java/java_string_field.cc index ff1865b1..5c2900ce 100644 --- a/src/google/protobuf/compiler/java/java_string_field.cc +++ b/src/google/protobuf/compiler/java/java_string_field.cc @@ -62,7 +62,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["empty_list"] = "com.google.protobuf.LazyStringArrayList.EMPTY"; @@ -71,7 +71,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["default_init"] = "= " + ImmutableDefaultValue(descriptor, name_resolver); (*variables)["capitalized_type"] = "String"; - (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor)); + (*variables)["tag"] = + SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); (*variables)["null_check"] = diff --git a/src/google/protobuf/compiler/java/java_string_field.h b/src/google/protobuf/compiler/java/java_string_field.h index a3b57351..0f7c705b 100644 --- a/src/google/protobuf/compiler/java/java_string_field.h +++ b/src/google/protobuf/compiler/java/java_string_field.h @@ -83,7 +83,7 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -142,7 +142,7 @@ class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.cc b/src/google/protobuf/compiler/java/java_string_field_lite.cc index 0b92c021..4d2dcad8 100644 --- a/src/google/protobuf/compiler/java/java_string_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_string_field_lite.cc @@ -62,7 +62,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["empty_list"] = @@ -72,7 +72,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["default_init"] = "= " + ImmutableDefaultValue(descriptor, name_resolver); (*variables)["capitalized_type"] = "String"; - (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor)); + (*variables)["tag"] = + SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); (*variables)["null_check"] = diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.h b/src/google/protobuf/compiler/java/java_string_field_lite.h index 4148aa4d..80496c87 100644 --- a/src/google/protobuf/compiler/java/java_string_field_lite.h +++ b/src/google/protobuf/compiler/java/java_string_field_lite.h @@ -82,7 +82,7 @@ class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -140,7 +140,7 @@ class RepeatedImmutableStringFieldLiteGenerator private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/js/embed.cc b/src/google/protobuf/compiler/js/embed.cc new file mode 100644 index 00000000..072cccad --- /dev/null +++ b/src/google/protobuf/compiler/js/embed.cc @@ -0,0 +1,111 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <cstdlib> +#include <fstream> +#include <iostream> + +const char output_file[] = "well_known_types_embed.cc"; + +static bool AsciiIsPrint(unsigned char c) { + return c >= 32 && c < 127; +} + +static char ToDecimalDigit(int num) { + assert(num < 10); + return '0' + num; +} + +static std::string CEscape(const std::string& str) { + std::string dest; + + for (unsigned char ch : str) { + switch (ch) { + case '\n': dest += "\\n"; break; + case '\r': dest += "\\r"; break; + case '\t': dest += "\\t"; break; + case '\"': dest += "\\\""; break; + case '\\': dest += "\\\\"; break; + default: + if (AsciiIsPrint(ch)) { + dest += ch; + } else { + dest += "\\"; + dest += ToDecimalDigit(ch / 64); + dest += ToDecimalDigit((ch % 64) / 8); + dest += ToDecimalDigit(ch % 8); + } + break; + } + } + + return dest; +} + +static void AddFile(const char* name, std::basic_ostream<char>* out) { + std::ifstream in(name); + + if (!in.is_open()) { + std::cerr << "Couldn't open input file: " << name << "\n"; + std::exit(EXIT_FAILURE); + } + + // Make canonical name only include the final element. + for (const char *p = name; *p; p++) { + if (*p == '/') { + name = p + 1; + } + } + + *out << "{\"" << CEscape(name) << "\",\n"; + + for (std::string line; std::getline(in, line); ) { + *out << " \"" << CEscape(line) << "\\n\"\n"; + } + + *out << "},\n"; +} + +int main(int argc, char *argv[]) { + auto& out = std::cout; + + out << "#include " + "\"google/protobuf/compiler/js/well_known_types_embed.h\"\n"; + out << "struct FileToc well_known_types_js[] = {\n"; + + for (int i = 1; i < argc; i++) { + AddFile(argv[i], &out); + } + + out << " {NULL, NULL} // Terminate the list.\n"; + out << "};\n"; + + return EXIT_SUCCESS; +} diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index 47ecc537..e6571f6f 100755 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -45,6 +45,7 @@ #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/stringprintf.h> +#include <google/protobuf/compiler/js/well_known_types_embed.h> #include <google/protobuf/io/printer.h> #include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/descriptor.pb.h> @@ -216,8 +217,13 @@ string GetNestedMessageName(const Descriptor* descriptor) { if (descriptor == NULL) { return ""; } - return StripPrefixString(descriptor->full_name(), - descriptor->file()->package()); + string result = + StripPrefixString(descriptor->full_name(), descriptor->file()->package()); + // Add a leading dot if one is not already present. + if (!result.empty() && result[0] != '.') { + result = "." + result; + } + return result; } // Returns the path prefix for a message or enumeration that @@ -225,8 +231,8 @@ string GetNestedMessageName(const Descriptor* descriptor) { string GetPrefix(const GeneratorOptions& options, const FileDescriptor* file_descriptor, const Descriptor* containing_type) { - string prefix = GetPath(options, file_descriptor) + - GetNestedMessageName(containing_type); + string prefix = + GetPath(options, file_descriptor) + GetNestedMessageName(containing_type); if (!prefix.empty()) { prefix += "."; } @@ -278,8 +284,8 @@ string MaybeCrossFileRef(const GeneratorOptions& options, // Cross-file ref in CommonJS needs to use the module alias instead of // the global name. return ModuleAlias(to_message->file()->name()) + - GetNestedMessageName(to_message->containing_type()) + - "." + to_message->name(); + GetNestedMessageName(to_message->containing_type()) + "." + + to_message->name(); } else { // Within a single file we use a full name. return GetPath(options, to_message); @@ -309,8 +315,8 @@ char ToLowerASCII(char c) { } } -vector<string> ParseLowerUnderscore(const string& input) { - vector<string> words; +std::vector<string> ParseLowerUnderscore(const string& input) { + std::vector<string> words; string running = ""; for (int i = 0; i < input.size(); i++) { if (input[i] == '_') { @@ -328,8 +334,8 @@ vector<string> ParseLowerUnderscore(const string& input) { return words; } -vector<string> ParseUpperCamel(const string& input) { - vector<string> words; +std::vector<string> ParseUpperCamel(const string& input) { + std::vector<string> words; string running = ""; for (int i = 0; i < input.size(); i++) { if (input[i] >= 'A' && input[i] <= 'Z' && !running.empty()) { @@ -344,7 +350,7 @@ vector<string> ParseUpperCamel(const string& input) { return words; } -string ToLowerCamel(const vector<string>& words) { +string ToLowerCamel(const std::vector<string>& words) { string result; for (int i = 0; i < words.size(); i++) { string word = words[i]; @@ -358,7 +364,7 @@ string ToLowerCamel(const vector<string>& words) { return result; } -string ToUpperCamel(const vector<string>& words) { +string ToUpperCamel(const std::vector<string>& words) { string result; for (int i = 0; i < words.size(); i++) { string word = words[i]; @@ -927,16 +933,10 @@ string JSTypeName(const GeneratorOptions& options, } } +// Used inside Google only -- do not remove. 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; - } + return false; } // Returns true for fields that return "null" from accessors when they are @@ -1077,22 +1077,14 @@ string JSBinaryReadWriteMethodName(const FieldDescriptor* field, string JSBinaryReaderMethodName(const GeneratorOptions& options, const FieldDescriptor* field) { - if (options.binary) { - return "jspb.BinaryReader.prototype.read" + - JSBinaryReadWriteMethodName(field, /* is_writer = */ false); - } else { - return "null"; - } + return "jspb.BinaryReader.prototype.read" + + JSBinaryReadWriteMethodName(field, /* is_writer = */ false); } string JSBinaryWriterMethodName(const GeneratorOptions& options, const FieldDescriptor* field) { - if (options.binary) { - return "jspb.BinaryWriter.prototype.write" + - JSBinaryReadWriteMethodName(field, /* is_writer = */ true); - } else { - return "null"; - } + return "jspb.BinaryWriter.prototype.write" + + JSBinaryReadWriteMethodName(field, /* is_writer = */ true); } string JSReturnClause(const FieldDescriptor* desc) { @@ -1327,6 +1319,29 @@ bool HasExtensions(const FileDescriptor* file) { return false; } +bool HasMap(const GeneratorOptions& options, const Descriptor* desc) { + for (int i = 0; i < desc->field_count(); i++) { + if (IsMap(options, desc->field(i))) { + return true; + } + } + for (int i = 0; i < desc->nested_type_count(); i++) { + if (HasMap(options, desc->nested_type(i))) { + return true; + } + } + return false; +} + +bool FileHasMap(const GeneratorOptions& options, const FileDescriptor* desc) { + for (int i = 0; i < desc->message_type_count(); i++) { + if (HasMap(options, desc->message_type(i))) { + return true; + } + } + return false; +} + bool IsExtendable(const Descriptor* desc) { return desc->extension_range_count() > 0; } @@ -1398,19 +1413,19 @@ class FileDeduplicator { return true; } - void GetAllowedSet(set<const void*>* allowed_set) { + void GetAllowedSet(std::set<const void*>* allowed_set) { *allowed_set = allowed_descs_; } private: bool error_on_conflict_; - map<string, const void*> descs_by_filename_; - set<const void*> allowed_descs_; + std::map<string, const void*> descs_by_filename_; + std::set<const void*> allowed_descs_; }; void DepthFirstSearch(const FileDescriptor* file, - vector<const FileDescriptor*>* list, - set<const FileDescriptor*>* seen) { + std::vector<const FileDescriptor*>* list, + std::set<const FileDescriptor*>* seen) { if (!seen->insert(file).second) { return; } @@ -1428,7 +1443,7 @@ void DepthFirstSearch(const FileDescriptor* file, // FileDescriptor is not in the given set. class NotInSet { public: - explicit NotInSet(const set<const FileDescriptor*>& file_set) + explicit NotInSet(const std::set<const FileDescriptor*>& file_set) : file_set_(file_set) {} bool operator()(const FileDescriptor* file) { @@ -1436,21 +1451,21 @@ class NotInSet { } private: - const set<const FileDescriptor*>& file_set_; + const std::set<const FileDescriptor*>& file_set_; }; // This function generates an ordering of the input FileDescriptors that matches // the logic of the old code generator. The order is significant because two // different input files can generate the same output file, and the last one // needs to win. -void GenerateJspbFileOrder(const vector<const FileDescriptor*>& input, - vector<const FileDescriptor*>* ordered) { +void GenerateJspbFileOrder(const std::vector<const FileDescriptor*>& input, + std::vector<const FileDescriptor*>* ordered) { // First generate an ordering of all reachable files (including dependencies) // with depth-first search. This mimics the behavior of --include_imports, // which is what the old codegen used. ordered->clear(); - set<const FileDescriptor*> seen; - set<const FileDescriptor*> input_set; + std::set<const FileDescriptor*> seen; + std::set<const FileDescriptor*> input_set; for (int i = 0; i < input.size(); i++) { DepthFirstSearch(input[i], ordered, &seen); input_set.insert(input[i]); @@ -1467,10 +1482,10 @@ void GenerateJspbFileOrder(const vector<const FileDescriptor*>& input, // only those to generate code. bool GenerateJspbAllowedSet(const GeneratorOptions& options, - const vector<const FileDescriptor*>& files, - set<const void*>* allowed_set, + const std::vector<const FileDescriptor*>& files, + std::set<const void*>* allowed_set, string* error) { - vector<const FileDescriptor*> files_ordered; + std::vector<const FileDescriptor*> files_ordered; GenerateJspbFileOrder(files, &files_ordered); // Choose the last descriptor for each filename. @@ -1538,7 +1553,7 @@ void Generator::FindProvidesForFile(const GeneratorOptions& options, void Generator::FindProvides(const GeneratorOptions& options, io::Printer* printer, - const vector<const FileDescriptor*>& files, + const std::vector<const FileDescriptor*>& files, std::set<string>* provided) const { for (int i = 0; i < files.size(); i++) { FindProvidesForFile(options, printer, files[i], provided); @@ -1580,7 +1595,7 @@ void Generator::FindProvidesForEnum(const GeneratorOptions& options, void Generator::FindProvidesForFields( const GeneratorOptions& options, io::Printer* printer, - const vector<const FieldDescriptor*>& fields, + const std::vector<const FieldDescriptor*>& fields, std::set<string>* provided) const { for (int i = 0; i < fields.size(); i++) { const FieldDescriptor* field = fields[i]; @@ -1629,18 +1644,20 @@ void Generator::GenerateRequiresForMessage(const GeneratorOptions& options, GenerateRequiresImpl(options, printer, &required, &forwards, provided, /* require_jspb = */ have_message, - /* require_extension = */ HasExtensions(desc)); + /* require_extension = */ HasExtensions(desc), + /* require_map = */ HasMap(options, desc)); } void Generator::GenerateRequiresForLibrary( const GeneratorOptions& options, io::Printer* printer, - const vector<const FileDescriptor*>& files, + const std::vector<const FileDescriptor*>& files, std::set<string>* provided) const { 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; bool have_extensions = false; + bool have_map = false; bool have_message = false; for (int i = 0; i < files.size(); i++) { @@ -1656,6 +1673,10 @@ void Generator::GenerateRequiresForLibrary( have_extensions = true; } + if (!have_map && FileHasMap(options, files[i])) { + have_map = true; + } + for (int j = 0; j < files[i]->extension_count(); j++) { const FieldDescriptor* extension = files[i]->extension(j); if (IgnoreField(extension)) { @@ -1672,12 +1693,13 @@ void Generator::GenerateRequiresForLibrary( GenerateRequiresImpl(options, printer, &required, &forwards, provided, /* require_jspb = */ have_message, - /* require_extension = */ have_extensions); + /* require_extension = */ have_extensions, + /* require_map = */ have_map); } void Generator::GenerateRequiresForExtensions( const GeneratorOptions& options, io::Printer* printer, - const vector<const FieldDescriptor*>& fields, + const std::vector<const FieldDescriptor*>& fields, std::set<string>* provided) const { std::set<string> required; std::set<string> forwards; @@ -1691,7 +1713,8 @@ void Generator::GenerateRequiresForExtensions( GenerateRequiresImpl(options, printer, &required, &forwards, provided, /* require_jspb = */ false, - /* require_extension = */ fields.size() > 0); + /* require_extension = */ fields.size() > 0, + /* require_map = */ false); } void Generator::GenerateRequiresImpl(const GeneratorOptions& options, @@ -1699,25 +1722,22 @@ void Generator::GenerateRequiresImpl(const GeneratorOptions& options, std::set<string>* required, std::set<string>* forwards, std::set<string>* provided, - bool require_jspb, - bool require_extension) const { + bool require_jspb, bool require_extension, + bool require_map) const { if (require_jspb) { printer->Print( - "goog.require('jspb.Message');\n"); - if (options.binary) { - printer->Print( - "goog.require('jspb.BinaryReader');\n" - "goog.require('jspb.BinaryWriter');\n"); - } + "goog.require('jspb.Message');\n" + "goog.require('jspb.BinaryReader');\n" + "goog.require('jspb.BinaryWriter');\n"); } if (require_extension) { - if (options.binary) { - printer->Print( - "goog.require('jspb.ExtensionFieldBinaryInfo');\n"); - } + printer->Print("goog.require('jspb.ExtensionFieldBinaryInfo');\n"); printer->Print( "goog.require('jspb.ExtensionFieldInfo');\n"); } + if (require_map) { + printer->Print("goog.require('jspb.Map');\n"); + } std::set<string>::iterator it; for (it = required->begin(); it != required->end(); ++it) { @@ -1839,14 +1859,13 @@ void Generator::GenerateClass(const GeneratorOptions& options, GenerateClassToObject(options, printer, desc); - if (options.binary) { - // These must come *before* the extension-field info generation in - // GenerateClassRegistration so that references to the binary - // serialization/deserialization functions may be placed in the extension - // objects. - GenerateClassDeserializeBinary(options, printer, desc); - GenerateClassSerializeBinary(options, printer, desc); - } + // These must come *before* the extension-field info generation in + // GenerateClassRegistration so that references to the binary + // serialization/deserialization functions may be placed in the extension + // objects. + GenerateClassDeserializeBinary(options, printer, desc); + GenerateClassSerializeBinary(options, printer, desc); + GenerateClassRegistration(options, printer, desc); GenerateClassFields(options, printer, desc); if (IsExtendable(desc) && desc->full_name() != "google.protobuf.bridge.MessageSet") { @@ -2143,8 +2162,20 @@ void Generator::GenerateClassFieldToObject(const GeneratorOptions& options, "fieldname", JSObjectFieldName(options, field)); if (IsMap(options, field)) { - printer->Print("(f = msg.get$name$()) ? f.toArray() : []", - "name", JSGetterName(options, field)); + const FieldDescriptor* value_field = MapFieldValue(field); + // If the map values are of a message type, we must provide their static + // toObject() method; otherwise we pass undefined for that argument. + string value_to_object; + if (value_field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + value_to_object = + GetPath(options, value_field->message_type()) + ".toObject"; + } else { + value_to_object = "undefined"; + } + printer->Print( + "(f = msg.get$name$()) ? f.toObject(includeInstance, $valuetoobject$) " + ": []", + "name", JSGetterName(options, field), "valuetoobject", value_to_object); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { // Message field. if (field->is_repeated()) { @@ -2217,14 +2248,27 @@ void Generator::GenerateClassFieldFromObject( io::Printer* printer, const FieldDescriptor* field) const { 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. - printer->Print( - " goog.isDef(obj.$name$) && " - "jspb.Message.setField(msg, $index$, obj.$name$);\n", - "name", JSObjectFieldName(options, field), - "index", JSFieldIndex(field)); + const FieldDescriptor* value_field = MapFieldValue(field); + if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) { + // Since the map values are of message type, we have to do some extra work + // to recursively call fromObject() on them before setting the map field. + printer->Print( + " goog.isDef(obj.$name$) && jspb.Message.setWrapperField(\n" + " msg, $index$, jspb.Map.fromObject(obj.$name$, $fieldclass$, " + "$fieldclass$.fromObject));\n", + "name", JSObjectFieldName(options, field), + "index", JSFieldIndex(field), + "fieldclass", GetPath(options, value_field->message_type())); + } else { + // `msg` is a newly-constructed message object that has not yet built any + // map containers wrapping underlying arrays, so we can simply directly + // set the array here without fear of a stale wrapper. + printer->Print( + " goog.isDef(obj.$name$) && " + "jspb.Message.setField(msg, $index$, obj.$name$);\n", + "name", JSObjectFieldName(options, field), + "index", JSFieldIndex(field)); + } } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { // Message field (singular or repeated) if (field->is_repeated()) { @@ -2358,7 +2402,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options, printer->Print(",\n" " $messageType$", "messageType", GetPath(options, value_field->message_type())); - } else if (options.binary) { + } else { printer->Print(",\n" " null"); } @@ -2711,28 +2755,26 @@ void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options, "\n", "class", GetPath(options, desc)); - if (options.binary) { - printer->Print( - "\n" - "/**\n" - " * The extensions registered with this message class. This is a " - "map of\n" - " * extension field number to fieldInfo object.\n" - " *\n" - " * For example:\n" - " * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, " - "ctor: proto.example.MyMessage} }\n" - " *\n" - " * fieldName contains the JsCompiler renamed field name property " - "so that it\n" - " * works in OPTIMIZED mode.\n" - " *\n" - " * @type {!Object.<number, jspb.ExtensionFieldBinaryInfo>}\n" - " */\n" - "$class$.extensionsBinary = {};\n" - "\n", - "class", GetPath(options, desc)); - } + printer->Print( + "\n" + "/**\n" + " * The extensions registered with this message class. This is a " + "map of\n" + " * extension field number to fieldInfo object.\n" + " *\n" + " * For example:\n" + " * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, " + "ctor: proto.example.MyMessage} }\n" + " *\n" + " * fieldName contains the JsCompiler renamed field name property " + "so that it\n" + " * works in OPTIMIZED mode.\n" + " *\n" + " * @type {!Object.<number, jspb.ExtensionFieldBinaryInfo>}\n" + " */\n" + "$class$.extensionsBinary = {};\n" + "\n", + "class", GetPath(options, desc)); } } @@ -2773,7 +2815,9 @@ void Generator::GenerateClassDeserializeBinary(const GeneratorOptions& options, "class", GetPath(options, desc)); for (int i = 0; i < desc->field_count(); i++) { - GenerateClassDeserializeBinaryField(options, printer, desc->field(i)); + if (!IgnoreField(desc->field(i))) { + GenerateClassDeserializeBinaryField(options, printer, desc->field(i)); + } } printer->Print( @@ -2873,44 +2917,36 @@ void Generator::GenerateClassSerializeBinary(const GeneratorOptions& options, const Descriptor* desc) const { printer->Print( "/**\n" - " * Class method variant: serializes the given message to binary data\n" - " * (in protobuf wire format), writing to the given BinaryWriter.\n" - " * @param {!$class$} message\n" - " * @param {!jspb.BinaryWriter} writer\n" - " */\n" - "$class$.serializeBinaryToWriter = function(message, " - "writer) {\n" - " message.serializeBinaryToWriter(writer);\n" - "};\n" - "\n" - "\n" - "/**\n" " * Serializes the message to binary data (in protobuf wire format).\n" " * @return {!Uint8Array}\n" " */\n" "$class$.prototype.serializeBinary = function() {\n" " var writer = new jspb.BinaryWriter();\n" - " this.serializeBinaryToWriter(writer);\n" + " $class$.serializeBinaryToWriter(this, writer);\n" " return writer.getResultBuffer();\n" "};\n" "\n" "\n" "/**\n" - " * Serializes the message to binary data (in protobuf wire format),\n" - " * writing to the given BinaryWriter.\n" + " * Serializes the given message to binary data (in protobuf wire\n" + " * format), writing to the given BinaryWriter.\n" + " * @param {!$class$} message\n" " * @param {!jspb.BinaryWriter} writer\n" " */\n" - "$class$.prototype.serializeBinaryToWriter = function (writer) {\n" + "$class$.serializeBinaryToWriter = function(message, " + "writer) {\n" " var f = undefined;\n", "class", GetPath(options, desc)); for (int i = 0; i < desc->field_count(); i++) { - GenerateClassSerializeBinaryField(options, printer, desc->field(i)); + if (!IgnoreField(desc->field(i))) { + GenerateClassSerializeBinaryField(options, printer, desc->field(i)); + } } if (IsExtendable(desc)) { printer->Print( - " jspb.Message.serializeBinaryExtensions(this, writer,\n" + " jspb.Message.serializeBinaryExtensions(message, writer,\n" " $extobj$Binary, $class$.prototype.getExtension);\n", "extobj", JSExtensionsObjectName(options, desc->file(), desc), "class", GetPath(options, desc)); @@ -2935,15 +2971,16 @@ void Generator::GenerateClassSerializeBinaryField( /* singular_if_not_packed = */ false, /* bytes_mode = */ BYTES_DEFAULT); printer->Print( - " f = /** @type {$type$} */ (jspb.Message.getField(this, $index$));\n", + " f = /** @type {$type$} */ " + "(jspb.Message.getField(message, $index$));\n", "index", JSFieldIndex(field), "type", typed_annotation); } else { printer->Print( - " f = this.get$name$($nolazy$);\n", + " f = message.get$name$($nolazy$);\n", "name", JSGetterName(options, field, BYTES_U8), // No lazy creation for maps containers -- fastpath the empty case. - "nolazy", (field->is_map()) ? "true" : ""); + "nolazy", IsMap(options, field) ? "true" : ""); } // Print an `if (condition)` statement that evaluates to true if the field @@ -3102,35 +3139,30 @@ void Generator::GenerateExtension(const GeneratorOptions& options, string("null")), "repeated", (field->is_repeated() ? "1" : "0")); - if (options.binary) { - printer->Print( - "\n" - "$extendName$Binary[$index$] = new jspb.ExtensionFieldBinaryInfo(\n" - " $class$.$name$,\n" - " $binaryReaderFn$,\n" - " $binaryWriterFn$,\n" - " $binaryMessageSerializeFn$,\n" - " $binaryMessageDeserializeFn$,\n", - "extendName", JSExtensionsObjectName(options, field->file(), - field->containing_type()), - "index", SimpleItoa(field->number()), - "class", extension_scope, - "name", JSObjectFieldName(options, field), - "binaryReaderFn", JSBinaryReaderMethodName(options, field), - "binaryWriterFn", JSBinaryWriterMethodName(options, field), - "binaryMessageSerializeFn", - (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ? - (SubmessageTypeRef(options, field) + - ".serializeBinaryToWriter") : "undefined", - "binaryMessageDeserializeFn", - (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ? - (SubmessageTypeRef(options, field) + - ".deserializeBinaryFromReader") : "undefined"); - - printer->Print( - " $isPacked$);\n", - "isPacked", (field->is_packed() ? "true" : "false")); - } + printer->Print( + "\n" + "$extendName$Binary[$index$] = new jspb.ExtensionFieldBinaryInfo(\n" + " $class$.$name$,\n" + " $binaryReaderFn$,\n" + " $binaryWriterFn$,\n" + " $binaryMessageSerializeFn$,\n" + " $binaryMessageDeserializeFn$,\n", + "extendName", + JSExtensionsObjectName(options, field->file(), field->containing_type()), + "index", SimpleItoa(field->number()), "class", extension_scope, "name", + JSObjectFieldName(options, field), "binaryReaderFn", + JSBinaryReaderMethodName(options, field), "binaryWriterFn", + JSBinaryWriterMethodName(options, field), "binaryMessageSerializeFn", + (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) + ? (SubmessageTypeRef(options, field) + ".serializeBinaryToWriter") + : "undefined", + "binaryMessageDeserializeFn", + (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) + ? (SubmessageTypeRef(options, field) + ".deserializeBinaryFromReader") + : "undefined"); + + printer->Print(" $isPacked$);\n", "isPacked", + (field->is_packed() ? "true" : "false")); printer->Print( "// This registers the extension field with the extended class, so that\n" @@ -3145,7 +3177,7 @@ void Generator::GenerateExtension(const GeneratorOptions& options, } bool GeneratorOptions::ParseFromOptions( - const vector< pair< string, string > >& options, + const std::vector< std::pair< string, string > >& options, string* error) { for (int i = 0; i < options.size(); i++) { if (options[i].first == "add_require_for_enums") { @@ -3199,12 +3231,6 @@ bool GeneratorOptions::ParseFromOptions( 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. @@ -3218,13 +3244,12 @@ bool GeneratorOptions::ParseFromOptions( 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_on_name_conflict || 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"; + "extension, and one_output_file_per_input_file options should only be " + "used for import_style=closure"; return false; } @@ -3250,7 +3275,7 @@ GeneratorOptions::OutputMode GeneratorOptions::output_mode() const { void Generator::GenerateFilesInDepOrder( const GeneratorOptions& options, io::Printer* printer, - const vector<const FileDescriptor*>& files) const { + const std::vector<const FileDescriptor*>& files) const { // Build a std::set over all files so that the DFS can detect when it recurses // into a dep not specified in the user's command line. std::set<const FileDescriptor*> all_files(files.begin(), files.end()); @@ -3307,8 +3332,8 @@ void Generator::GenerateFile(const GeneratorOptions& options, } } - set<string> provided; - set<const FieldDescriptor*> extensions; + std::set<string> provided; + std::set<const FieldDescriptor*> extensions; for (int i = 0; i < file->extension_count(); i++) { // We honor the jspb::ignore option here only when working with // Closure-style imports. Use of this option is discouraged and so we want @@ -3324,7 +3349,7 @@ void Generator::GenerateFile(const GeneratorOptions& options, FindProvidesForFile(options, printer, file, &provided); GenerateProvides(options, printer, &provided); - vector<const FileDescriptor*> files; + std::vector<const FileDescriptor*> files; files.push_back(file); if (options.import_style == GeneratorOptions::kImportClosure) { GenerateRequiresForLibrary(options, printer, files, &provided); @@ -3334,7 +3359,7 @@ void Generator::GenerateFile(const GeneratorOptions& options, // Generate code for top-level extensions. Extensions nested inside messages // are emitted inside GenerateClassesAndEnums(). - for (set<const FieldDescriptor*>::const_iterator it = extensions.begin(); + for (std::set<const FieldDescriptor*>::const_iterator it = extensions.begin(); it != extensions.end(); ++it) { GenerateExtension(options, printer, *it); } @@ -3343,13 +3368,21 @@ void Generator::GenerateFile(const GeneratorOptions& options, printer->Print("goog.object.extend(exports, $package$);\n", "package", GetPath(options, file)); } + + // Emit well-known type methods. + for (FileToc* toc = well_known_types_js; toc->name != NULL; toc++) { + string name = string("google/protobuf/") + toc->name; + if (name == StripProto(file->name()) + ".js") { + printer->Print(toc->data); + } + } } -bool Generator::GenerateAll(const vector<const FileDescriptor*>& files, +bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files, const string& parameter, GeneratorContext* context, string* error) const { - vector< pair< string, string > > option_pairs; + std::vector< std::pair< string, string > > option_pairs; ParseGeneratorParameter(parameter, &option_pairs); GeneratorOptions options; if (!options.ParseFromOptions(option_pairs, error)) { @@ -3367,7 +3400,7 @@ bool Generator::GenerateAll(const vector<const FileDescriptor*>& files, // Pull out all extensions -- we need these to generate all // provides/requires. - vector<const FieldDescriptor*> extensions; + std::vector<const FieldDescriptor*> extensions; for (int i = 0; i < files.size(); i++) { for (int j = 0; j < files[i]->extension_count(); j++) { const FieldDescriptor* extension = files[i]->extension(j); @@ -3396,7 +3429,7 @@ bool Generator::GenerateAll(const vector<const FileDescriptor*>& files, return false; } } else if (options.output_mode() == GeneratorOptions::kOneOutputFilePerType) { - set<const void*> allowed_set; + std::set<const void*> allowed_set; if (!GenerateJspbAllowedSet(options, files, &allowed_set, error)) { return false; } @@ -3467,7 +3500,7 @@ bool Generator::GenerateAll(const vector<const FileDescriptor*>& files, GenerateHeader(options, &printer); std::set<string> provided; - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; for (int j = 0; j < files[i]->extension_count(); j++) { if (ShouldGenerateExtension(files[i]->extension(j))) { diff --git a/src/google/protobuf/compiler/js/js_generator.h b/src/google/protobuf/compiler/js/js_generator.h index 4ca3493c..6e932d7f 100755 --- a/src/google/protobuf/compiler/js/js_generator.h +++ b/src/google/protobuf/compiler/js/js_generator.h @@ -29,7 +29,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Generates JavaScript code for a given .proto file. - +// #ifndef GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__ #define GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__ @@ -78,12 +78,11 @@ struct GeneratorOptions { testonly(false), library(""), error_on_name_conflict(false), - broken_proto3_semantics(false), extension(".js"), one_output_file_per_input_file(false) {} bool ParseFromOptions( - const vector< pair< string, string > >& options, + const std::vector< std::pair< string, string > >& options, string* error); // Returns the file name extension to use for generated code. @@ -115,10 +114,6 @@ struct GeneratorOptions { 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? @@ -144,7 +139,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { virtual bool HasGenerateAll() const { return true; } - virtual bool GenerateAll(const vector<const FileDescriptor*>& files, + virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files, const string& parameter, GeneratorContext* context, string* error) const; @@ -156,7 +151,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { // Generate goog.provides() calls. void FindProvides(const GeneratorOptions& options, io::Printer* printer, - const vector<const FileDescriptor*>& file, + const std::vector<const FileDescriptor*>& file, std::set<string>* provided) const; void FindProvidesForFile(const GeneratorOptions& options, io::Printer* printer, @@ -173,7 +168,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { // For extension fields at file scope. void FindProvidesForFields(const GeneratorOptions& options, io::Printer* printer, - const vector<const FieldDescriptor*>& fields, + const std::vector<const FieldDescriptor*>& fields, std::set<string>* provided) const; // Print the goog.provides() found by the methods above. void GenerateProvides(const GeneratorOptions& options, @@ -185,10 +180,10 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { io::Printer* printer) const; // Generate goog.requires() calls. - void GenerateRequiresForLibrary(const GeneratorOptions& options, - io::Printer* printer, - const vector<const FileDescriptor*>& files, - std::set<string>* provided) const; + void GenerateRequiresForLibrary( + const GeneratorOptions& options, io::Printer* printer, + const std::vector<const FileDescriptor*>& files, + std::set<string>* provided) const; void GenerateRequiresForMessage(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc, @@ -196,15 +191,13 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { // For extension fields at file scope. void GenerateRequiresForExtensions( const GeneratorOptions& options, io::Printer* printer, - const vector<const FieldDescriptor*>& fields, + const std::vector<const FieldDescriptor*>& fields, std::set<string>* provided) const; void GenerateRequiresImpl(const GeneratorOptions& options, - io::Printer* printer, - std::set<string>* required, + io::Printer* printer, std::set<string>* required, std::set<string>* forwards, - std::set<string>* provided, - bool require_jspb, - bool require_extension) const; + std::set<string>* provided, bool require_jspb, + bool require_extension, bool require_map) const; void FindRequiresForMessage(const GeneratorOptions& options, const Descriptor* desc, std::set<string>* required, @@ -225,9 +218,9 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { // Generate definitions for all message classes and enums in all files, // processing the files in dependence order. - void GenerateFilesInDepOrder(const GeneratorOptions& options, - io::Printer* printer, - const vector<const FileDescriptor*>& file) const; + void GenerateFilesInDepOrder( + const GeneratorOptions& options, io::Printer* printer, + const std::vector<const FileDescriptor*>& file) const; // Helper for above. void GenerateFileAndDeps(const GeneratorOptions& options, io::Printer* printer, diff --git a/src/google/protobuf/compiler/js/well_known_types/any.js b/src/google/protobuf/compiler/js/well_known_types/any.js new file mode 100644 index 00000000..22f18919 --- /dev/null +++ b/src/google/protobuf/compiler/js/well_known_types/any.js @@ -0,0 +1,80 @@ +// 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. + +/* This code will be inserted into generated code for + * google/protobuf/any.proto. */ + +/** + * Returns the type name contained in this instance, if any. + * @return {string|undefined} + */ +proto.google.protobuf.Any.prototype.getTypeName = function() { + return this.getTypeUrl().split('/').pop(); +}; + + +/** + * Packs the given message instance into this Any. + * @param {!Uint8Array} serialized The serialized data to pack. + * @param {string} name The type name of this message object. + * @param {string=} opt_typeUrlPrefix the type URL prefix. + */ +proto.google.protobuf.Any.prototype.pack = function(serialized, name, + opt_typeUrlPrefix) { + if (!opt_typeUrlPrefix) { + opt_typeUrlPrefix = 'type.googleapis.com/'; + } + + if (opt_typeUrlPrefix.substr(-1) != '/') { + this.setTypeUrl(opt_typeUrlPrefix + '/' + name); + } else { + this.setTypeUrl(opt_typeUrlPrefix + name); + } + + this.setValue(serialized); +}; + + +/** + * @template T + * Unpacks this Any into the given message object. + * @param {function(Uint8Array):T} deserialize Function that will deserialize + * the binary data properly. + * @param {string} name The expected type name of this message object. + * @return {?T} If the name matched the expected name, returns the deserialized + * object, otherwise returns undefined. + */ +proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) { + if (this.getTypeName() == name) { + return deserialize(this.getValue_asU8()); + } else { + return null; + } +}; diff --git a/src/google/protobuf/compiler/js/well_known_types/struct.js b/src/google/protobuf/compiler/js/well_known_types/struct.js new file mode 100644 index 00000000..30e3d02a --- /dev/null +++ b/src/google/protobuf/compiler/js/well_known_types/struct.js @@ -0,0 +1,168 @@ +// 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. + +/* This code will be inserted into generated code for + * google/protobuf/struct.proto. */ + +/** + * Typedef representing plain JavaScript values that can go into a + * Struct. + * @typedef {null|number|string|boolean|Array|Object} + */ +proto.google.protobuf.JavaScriptValue; + + +/** + * Converts this Value object to a plain JavaScript value. + * @return {?proto.google.protobuf.JavaScriptValue} a plain JavaScript + * value representing this Struct. + */ +proto.google.protobuf.Value.prototype.toJavaScript = function() { + var kindCase = proto.google.protobuf.Value.KindCase; + switch (this.getKindCase()) { + case kindCase.NULL_VALUE: + return null; + case kindCase.NUMBER_VALUE: + return this.getNumberValue(); + case kindCase.STRING_VALUE: + return this.getStringValue(); + case kindCase.BOOL_VALUE: + return this.getBoolValue(); + case kindCase.STRUCT_VALUE: + return this.getStructValue().toJavaScript(); + case kindCase.LIST_VALUE: + return this.getListValue().toJavaScript(); + default: + throw new Error('Unexpected struct type'); + } +}; + + +/** + * Converts this JavaScript value to a new Value proto. + * @param {!proto.google.protobuf.JavaScriptValue} value The value to + * convert. + * @return {!proto.google.protobuf.Value} The newly constructed value. + */ +proto.google.protobuf.Value.fromJavaScript = function(value) { + var ret = new proto.google.protobuf.Value(); + switch (goog.typeOf(value)) { + case 'string': + ret.setStringValue(/** @type {string} */ (value)); + break; + case 'number': + ret.setNumberValue(/** @type {number} */ (value)); + break; + case 'boolean': + ret.setBoolValue(/** @type {boolean} */ (value)); + break; + case 'null': + ret.setNullValue(proto.google.protobuf.NullValue.NULL_VALUE); + break; + case 'array': + ret.setListValue(proto.google.protobuf.ListValue.fromJavaScript( + /** @type{!Array} */ (value))); + break; + case 'object': + ret.setStructValue(proto.google.protobuf.Struct.fromJavaScript( + /** @type{!Object} */ (value))); + break; + default: + throw new Error('Unexpected struct type.'); + } + + return ret; +}; + + +/** + * Converts this ListValue object to a plain JavaScript array. + * @return {!Array} a plain JavaScript array representing this List. + */ +proto.google.protobuf.ListValue.prototype.toJavaScript = function() { + var ret = []; + var values = this.getValuesList(); + + for (var i = 0; i < values.length; i++) { + ret[i] = values[i].toJavaScript(); + } + + return ret; +}; + + +/** + * Constructs a ListValue protobuf from this plain JavaScript array. + * @param {!Array} array a plain JavaScript array + * @return {proto.google.protobuf.ListValue} a new ListValue object + */ +proto.google.protobuf.ListValue.fromJavaScript = function(array) { + var ret = new proto.google.protobuf.ListValue(); + + for (var i = 0; i < array.length; i++) { + ret.addValues(proto.google.protobuf.Value.fromJavaScript(array[i])); + } + + return ret; +}; + + +/** + * Converts this Struct object to a plain JavaScript object. + * @return {!Object<string, !proto.google.protobuf.JavaScriptValue>} a plain + * JavaScript object representing this Struct. + */ +proto.google.protobuf.Struct.prototype.toJavaScript = function() { + var ret = {}; + + this.getFieldsMap().forEach(function(value, key) { + ret[key] = value.toJavaScript(); + }); + + return ret; +}; + + +/** + * Constructs a Struct protobuf from this plain JavaScript object. + * @param {!Object} obj a plain JavaScript object + * @return {proto.google.protobuf.Struct} a new Struct object + */ +proto.google.protobuf.Struct.fromJavaScript = function(obj) { + var ret = new proto.google.protobuf.Struct(); + var map = ret.getFieldsMap(); + + for (var property in obj) { + var val = obj[property]; + map.set(property, proto.google.protobuf.Value.fromJavaScript(val)); + } + + return ret; +}; diff --git a/src/google/protobuf/compiler/js/well_known_types/timestamp.js b/src/google/protobuf/compiler/js/well_known_types/timestamp.js new file mode 100644 index 00000000..77c07bb4 --- /dev/null +++ b/src/google/protobuf/compiler/js/well_known_types/timestamp.js @@ -0,0 +1,54 @@ +// 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. + +/* This code will be inserted into generated code for + * google/protobuf/timestamp.proto. */ + +/** + * Returns a JavaScript 'Date' object corresponding to this Timestamp. + * @return {!Date} + */ +proto.google.protobuf.Timestamp.prototype.toDate = function() { + var seconds = this.getSeconds(); + var nanos = this.getNanos(); + + return new Date((seconds * 1000) + (nanos / 1000000)); +}; + + +/** + * Sets the value of this Timestamp object to be the given Date. + * @param {!Date} value The value to set. + */ +proto.google.protobuf.Timestamp.prototype.fromDate = function(value) { + var millis = value.getTime(); + this.setSeconds(Math.floor(value.getTime() / 1000)); + this.setNanos(value.getMilliseconds() * 1000000); +}; diff --git a/src/google/protobuf/compiler/js/well_known_types_embed.cc b/src/google/protobuf/compiler/js/well_known_types_embed.cc new file mode 100755 index 00000000..b589ccb5 --- /dev/null +++ b/src/google/protobuf/compiler/js/well_known_types_embed.cc @@ -0,0 +1,314 @@ +#include "google/protobuf/compiler/js/well_known_types_embed.h" +struct FileToc well_known_types_js[] = { +{"any.js", + "// Protocol Buffers - Google's data interchange format\n" + "// Copyright 2008 Google Inc. All rights reserved.\n" + "// https://developers.google.com/protocol-buffers/\n" + "//\n" + "// Redistribution and use in source and binary forms, with or without\n" + "// modification, are permitted provided that the following conditions are\n" + "// met:\n" + "//\n" + "// * Redistributions of source code must retain the above copyright\n" + "// notice, this list of conditions and the following disclaimer.\n" + "// * Redistributions in binary form must reproduce the above\n" + "// copyright notice, this list of conditions and the following disclaimer\n" + "// in the documentation and/or other materials provided with the\n" + "// distribution.\n" + "// * Neither the name of Google Inc. nor the names of its\n" + "// contributors may be used to endorse or promote products derived from\n" + "// this software without specific prior written permission.\n" + "//\n" + "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n" + "// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n" + "// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n" + "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n" + "// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n" + "// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n" + "// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" + "// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n" + "// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" + "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n" + "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" + "\n" + "/* This code will be inserted into generated code for\n" + " * google/protobuf/any.proto. */\n" + "\n" + "/**\n" + " * Returns the type name contained in this instance, if any.\n" + " * @return {string|undefined}\n" + " */\n" + "proto.google.protobuf.Any.prototype.getTypeName = function() {\n" + " return this.getTypeUrl().split('/').pop();\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Packs the given message instance into this Any.\n" + " * @param {!Uint8Array} serialized The serialized data to pack.\n" + " * @param {string} name The type name of this message object.\n" + " * @param {string=} opt_typeUrlPrefix the type URL prefix.\n" + " */\n" + "proto.google.protobuf.Any.prototype.pack = function(serialized, name,\n" + " opt_typeUrlPrefix) {\n" + " if (!opt_typeUrlPrefix) {\n" + " opt_typeUrlPrefix = 'type.googleapis.com/';\n" + " }\n" + "\n" + " if (opt_typeUrlPrefix.substr(-1) != '/') {\n" + " this.setTypeUrl(opt_typeUrlPrefix + '/' + name);\n" + " } else {\n" + " this.setTypeUrl(opt_typeUrlPrefix + name);\n" + " }\n" + "\n" + " this.setValue(serialized);\n" + "};\n" + "\n" + "\n" + "/**\n" + " * @template T\n" + " * Unpacks this Any into the given message object.\n" + " * @param {function(Uint8Array):T} deserialize Function that will deserialize\n" + " * the binary data properly.\n" + " * @param {string} name The expected type name of this message object.\n" + " * @return {?T} If the name matched the expected name, returns the deserialized\n" + " * object, otherwise returns undefined.\n" + " */\n" + "proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) {\n" + " if (this.getTypeName() == name) {\n" + " return deserialize(this.getValue_asU8());\n" + " } else {\n" + " return null;\n" + " }\n" + "};\n" +}, +{"timestamp.js", + "// Protocol Buffers - Google's data interchange format\n" + "// Copyright 2008 Google Inc. All rights reserved.\n" + "// https://developers.google.com/protocol-buffers/\n" + "//\n" + "// Redistribution and use in source and binary forms, with or without\n" + "// modification, are permitted provided that the following conditions are\n" + "// met:\n" + "//\n" + "// * Redistributions of source code must retain the above copyright\n" + "// notice, this list of conditions and the following disclaimer.\n" + "// * Redistributions in binary form must reproduce the above\n" + "// copyright notice, this list of conditions and the following disclaimer\n" + "// in the documentation and/or other materials provided with the\n" + "// distribution.\n" + "// * Neither the name of Google Inc. nor the names of its\n" + "// contributors may be used to endorse or promote products derived from\n" + "// this software without specific prior written permission.\n" + "//\n" + "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n" + "// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n" + "// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n" + "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n" + "// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n" + "// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n" + "// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" + "// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n" + "// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" + "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n" + "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" + "\n" + "/* This code will be inserted into generated code for\n" + " * google/protobuf/timestamp.proto. */\n" + "\n" + "/**\n" + " * Returns a JavaScript 'Date' object corresponding to this Timestamp.\n" + " * @return {!Date}\n" + " */\n" + "proto.google.protobuf.Timestamp.prototype.toDate = function() {\n" + " // The '|| 0' clauses are necessary for as long as\n" + " // broken_proto3_semantics are specified for this rule inside Google.\n" + " var seconds = this.getSeconds() || 0;\n" + " var nanos = this.getNanos() || 0;\n" + "\n" + " return new Date((seconds * 1000) + (nanos / 1000000));\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Sets the value of this Timestamp object to be the given Date.\n" + " * @param {!Date} value The value to set.\n" + " */\n" + "proto.google.protobuf.Timestamp.prototype.fromDate = function(value) {\n" + " var millis = value.getTime();\n" + " this.setSeconds(Math.floor(value.getTime() / 1000));\n" + " this.setNanos(value.getMilliseconds() * 1000000);\n" + "};\n" +}, +{"struct.js", + "// Protocol Buffers - Google's data interchange format\n" + "// Copyright 2008 Google Inc. All rights reserved.\n" + "// https://developers.google.com/protocol-buffers/\n" + "//\n" + "// Redistribution and use in source and binary forms, with or without\n" + "// modification, are permitted provided that the following conditions are\n" + "// met:\n" + "//\n" + "// * Redistributions of source code must retain the above copyright\n" + "// notice, this list of conditions and the following disclaimer.\n" + "// * Redistributions in binary form must reproduce the above\n" + "// copyright notice, this list of conditions and the following disclaimer\n" + "// in the documentation and/or other materials provided with the\n" + "// distribution.\n" + "// * Neither the name of Google Inc. nor the names of its\n" + "// contributors may be used to endorse or promote products derived from\n" + "// this software without specific prior written permission.\n" + "//\n" + "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n" + "// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n" + "// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n" + "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n" + "// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n" + "// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n" + "// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" + "// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n" + "// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" + "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n" + "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" + "\n" + "/* This code will be inserted into generated code for\n" + " * google/protobuf/struct.proto. */\n" + "\n" + "/**\n" + " * Typedef representing plain JavaScript values that can go into a\n" + " * Struct.\n" + " * @typedef {null|number|string|boolean|Array|Object}\n" + " */\n" + "proto.google.protobuf.JavaScriptValue;\n" + "\n" + "\n" + "/**\n" + " * Converts this Value object to a plain JavaScript value.\n" + " * @return {?proto.google.protobuf.JavaScriptValue} a plain JavaScript\n" + " * value representing this Struct.\n" + " */\n" + "proto.google.protobuf.Value.prototype.toJavaScript = function() {\n" + " var kindCase = proto.google.protobuf.Value.KindCase;\n" + " switch (this.getKindCase()) {\n" + " case kindCase.NULL_VALUE:\n" + " return null;\n" + " case kindCase.NUMBER_VALUE:\n" + " return this.getNumberValue();\n" + " case kindCase.STRING_VALUE:\n" + " return this.getStringValue();\n" + " case kindCase.BOOL_VALUE:\n" + " return this.getBoolValue();\n" + " case kindCase.STRUCT_VALUE:\n" + " return this.getStructValue().toJavaScript();\n" + " case kindCase.LIST_VALUE:\n" + " return this.getListValue().toJavaScript();\n" + " default:\n" + " throw new Error('Unexpected struct type');\n" + " }\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Converts this JavaScript value to a new Value proto.\n" + " * @param {!proto.google.protobuf.JavaScriptValue} value The value to\n" + " * convert.\n" + " * @return {!proto.google.protobuf.Value} The newly constructed value.\n" + " */\n" + "proto.google.protobuf.Value.fromJavaScript = function(value) {\n" + " var ret = new proto.google.protobuf.Value();\n" + " switch (goog.typeOf(value)) {\n" + " case 'string':\n" + " ret.setStringValue(/** @type {string} */ (value));\n" + " break;\n" + " case 'number':\n" + " ret.setNumberValue(/** @type {number} */ (value));\n" + " break;\n" + " case 'boolean':\n" + " ret.setBoolValue(/** @type {boolean} */ (value));\n" + " break;\n" + " case 'null':\n" + " ret.setNullValue(proto.google.protobuf.NullValue.NULL_VALUE);\n" + " break;\n" + " case 'array':\n" + " ret.setListValue(proto.google.protobuf.ListValue.fromJavaScript(\n" + " /** @type{!Array} */ (value)));\n" + " break;\n" + " case 'object':\n" + " ret.setStructValue(proto.google.protobuf.Struct.fromJavaScript(\n" + " /** @type{!Object} */ (value)));\n" + " break;\n" + " default:\n" + " throw new Error('Unexpected struct type.');\n" + " }\n" + "\n" + " return ret;\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Converts this ListValue object to a plain JavaScript array.\n" + " * @return {!Array} a plain JavaScript array representing this List.\n" + " */\n" + "proto.google.protobuf.ListValue.prototype.toJavaScript = function() {\n" + " var ret = [];\n" + " var values = this.getValuesList();\n" + "\n" + " for (var i = 0; i < values.length; i++) {\n" + " ret[i] = values[i].toJavaScript();\n" + " }\n" + "\n" + " return ret;\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Constructs a ListValue protobuf from this plain JavaScript array.\n" + " * @param {!Array} array a plain JavaScript array\n" + " * @return {proto.google.protobuf.ListValue} a new ListValue object\n" + " */\n" + "proto.google.protobuf.ListValue.fromJavaScript = function(array) {\n" + " var ret = new proto.google.protobuf.ListValue();\n" + "\n" + " for (var i = 0; i < array.length; i++) {\n" + " ret.addValues(proto.google.protobuf.Value.fromJavaScript(array[i]));\n" + " }\n" + "\n" + " return ret;\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Converts this Struct object to a plain JavaScript object.\n" + " * @return {!Object<string, !proto.google.protobuf.JavaScriptValue>} a plain\n" + " * JavaScript object representing this Struct.\n" + " */\n" + "proto.google.protobuf.Struct.prototype.toJavaScript = function() {\n" + " var ret = {};\n" + "\n" + " this.getFieldsMap().forEach(function(value, key) {\n" + " ret[key] = value.toJavaScript();\n" + " });\n" + "\n" + " return ret;\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Constructs a Struct protobuf from this plain JavaScript object.\n" + " * @param {!Object} obj a plain JavaScript object\n" + " * @return {proto.google.protobuf.Struct} a new Struct object\n" + " */\n" + "proto.google.protobuf.Struct.fromJavaScript = function(obj) {\n" + " var ret = new proto.google.protobuf.Struct();\n" + " var map = ret.getFieldsMap();\n" + "\n" + " for (var property in obj) {\n" + " var val = obj[property];\n" + " map.set(property, proto.google.protobuf.Value.fromJavaScript(val));\n" + " }\n" + "\n" + " return ret;\n" + "};\n" +}, + {NULL, NULL} // Terminate the list. +}; diff --git a/src/google/protobuf/compiler/js/well_known_types_embed.h b/src/google/protobuf/compiler/js/well_known_types_embed.h new file mode 100644 index 00000000..174c665e --- /dev/null +++ b/src/google/protobuf/compiler/js/well_known_types_embed.h @@ -0,0 +1,43 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__ +#define GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__ + +#include <stddef.h> + +struct FileToc { + const char* name; + const char* data; +}; + +extern struct FileToc well_known_types_js[]; + +#endif // GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__ diff --git a/src/google/protobuf/compiler/main.cc b/src/google/protobuf/compiler/main.cc index aca2a5b9..680d6428 100644 --- a/src/google/protobuf/compiler/main.cc +++ b/src/google/protobuf/compiler/main.cc @@ -39,12 +39,12 @@ #endif // ! OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP #ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP +#include <google/protobuf/compiler/csharp/csharp_generator.h> #include <google/protobuf/compiler/javanano/javanano_generator.h> +#include <google/protobuf/compiler/js/js_generator.h> +#include <google/protobuf/compiler/objectivec/objectivec_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[]) { @@ -60,7 +60,7 @@ int main(int argc, char* argv[]) { #ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP // Proto2 Java google::protobuf::compiler::java::JavaGenerator java_generator; - cli.RegisterGenerator("--java_out", &java_generator, + cli.RegisterGenerator("--java_out", "--java_opt", &java_generator, "Generate Java source file."); #endif // !OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP diff --git a/src/google/protobuf/compiler/mock_code_generator.cc b/src/google/protobuf/compiler/mock_code_generator.cc index 1cc932dd..979814ec 100644 --- a/src/google/protobuf/compiler/mock_code_generator.cc +++ b/src/google/protobuf/compiler/mock_code_generator.cc @@ -59,8 +59,8 @@ namespace compiler { // Returns the list of the names of files in all_files in the form of a // comma-separated string. -string CommaSeparatedList(const vector<const FileDescriptor*> all_files) { - vector<string> names; +string CommaSeparatedList(const std::vector<const FileDescriptor*> all_files) { + std::vector<string> names; for (size_t i = 0; i < all_files.size(); i++) { names.push_back(all_files[i]->name()); } @@ -92,7 +92,8 @@ void MockCodeGenerator::ExpectGenerated( File::GetContents(output_directory + "/" + GetOutputFileName(name, file), &content, true)); - vector<string> lines = Split(content, "\n", true); + std::vector<string> lines = + Split(content, "\n", true); while (!lines.empty() && lines.back().empty()) { lines.pop_back(); @@ -101,7 +102,7 @@ void MockCodeGenerator::ExpectGenerated( lines[i] += "\n"; } - vector<string> insertion_list; + std::vector<string> insertion_list; if (!insertions.empty()) { SplitStringUsing(insertions, ",", &insertion_list); } @@ -166,7 +167,7 @@ bool MockCodeGenerator::Generate( } if (HasPrefixString(parameter, "insert=")) { - vector<string> insert_into; + std::vector<string> insert_into; SplitStringUsing(StripPrefixString(parameter, "insert="), ",", &insert_into); @@ -230,7 +231,7 @@ string MockCodeGenerator::GetOutputFileContent( const string& parameter, const FileDescriptor* file, GeneratorContext *context) { - vector<const FileDescriptor*> all_files; + std::vector<const FileDescriptor*> all_files; context->ListParsedFiles(&all_files); return GetOutputFileContent( generator_name, parameter, file->name(), diff --git a/src/google/protobuf/compiler/parser.h b/src/google/protobuf/compiler/parser.h index 0f80e78b..dd8b6586 100644 --- a/src/google/protobuf/compiler/parser.h +++ b/src/google/protobuf/compiler/parser.h @@ -257,7 +257,7 @@ class LIBPROTOBUF_EXPORT Parser { // TODO(kenton): See comment on TryConsumeEndOfDeclaration(), above, for // why this is const. void AttachComments(string* leading, string* trailing, - vector<string>* detached_comments) const; + std::vector<string>* detached_comments) const; private: // Indexes of parent and current location in the parent @@ -520,7 +520,7 @@ class LIBPROTOBUF_EXPORT Parser { // detached comments will be put into the leading_detached_comments field for // the next element (See SourceCodeInfo.Location in descriptor.proto), when // ConsumeEndOfDeclaration() is called. - vector<string> upcoming_detached_comments_; + std::vector<string> upcoming_detached_comments_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser); }; @@ -556,9 +556,9 @@ class LIBPROTOBUF_EXPORT SourceLocationTable { void Clear(); private: - typedef map< - pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>, - pair<int, int> > LocationMap; + typedef std::map< + std::pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>, + std::pair<int, int> > LocationMap; LocationMap location_map_; }; diff --git a/src/google/protobuf/compiler/parser_unittest.cc b/src/google/protobuf/compiler/parser_unittest.cc index 1d623dd9..20140f8e 100644 --- a/src/google/protobuf/compiler/parser_unittest.cc +++ b/src/google/protobuf/compiler/parser_unittest.cc @@ -2218,7 +2218,7 @@ class SourceInfoTest : public ParserTest { const char* expected_leading_comments, const char* expected_trailing_comments, const char* expected_leading_detached_comments) { - pair<SpanMap::iterator, SpanMap::iterator> range = + std::pair<SpanMap::iterator, SpanMap::iterator> range = spans_.equal_range(SpanKey(descriptor_proto, field, index)); if (start_marker == '\0') { @@ -2229,8 +2229,8 @@ class SourceInfoTest : public ParserTest { return true; } } else { - pair<int, int> start_pos = FindOrDie(markers_, start_marker); - pair<int, int> end_pos = FindOrDie(markers_, end_marker); + std::pair<int, int> start_pos = FindOrDie(markers_, start_marker); + std::pair<int, int> end_pos = FindOrDie(markers_, end_marker); RepeatedField<int> expected_span; expected_span.Add(start_pos.first); @@ -2295,9 +2295,9 @@ class SourceInfoTest : public ParserTest { } }; - typedef multimap<SpanKey, const SourceCodeInfo::Location*> SpanMap; + typedef std::multimap<SpanKey, const SourceCodeInfo::Location*> SpanMap; SpanMap spans_; - map<char, pair<int, int> > markers_; + std::map<char, std::pair<int, int> > markers_; string text_without_markers_; void ExtractMarkers(const char* text) { diff --git a/src/google/protobuf/compiler/plugin.cc b/src/google/protobuf/compiler/plugin.cc index e1087601..dcccb3d4 100644 --- a/src/google/protobuf/compiler/plugin.cc +++ b/src/google/protobuf/compiler/plugin.cc @@ -62,10 +62,10 @@ namespace compiler { class GeneratorResponseContext : public GeneratorContext { public: - GeneratorResponseContext(CodeGeneratorResponse* response, - const vector<const FileDescriptor*>& parsed_files) - : response_(response), - parsed_files_(parsed_files) {} + GeneratorResponseContext( + CodeGeneratorResponse* response, + const std::vector<const FileDescriptor*>& parsed_files) + : response_(response), parsed_files_(parsed_files) {} virtual ~GeneratorResponseContext() {} // implements GeneratorContext -------------------------------------- @@ -84,13 +84,13 @@ class GeneratorResponseContext : public GeneratorContext { return new io::StringOutputStream(file->mutable_content()); } - void ListParsedFiles(vector<const FileDescriptor*>* output) { + void ListParsedFiles(std::vector<const FileDescriptor*>* output) { *output = parsed_files_; } private: CodeGeneratorResponse* response_; - const vector<const FileDescriptor*>& parsed_files_; + const std::vector<const FileDescriptor*>& parsed_files_; }; bool GenerateCode(const CodeGeneratorRequest& request, @@ -105,7 +105,7 @@ bool GenerateCode(const CodeGeneratorRequest& request, } } - vector<const FileDescriptor*> parsed_files; + std::vector<const FileDescriptor*> parsed_files; for (int i = 0; i < request.file_to_generate_size(); i++) { parsed_files.push_back(pool.FindFileByName(request.file_to_generate(i))); if (parsed_files.back() == NULL) { diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index a4d4a530..0239e05f 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -20,145 +20,131 @@ namespace google { namespace protobuf { namespace compiler { +class CodeGeneratorRequestDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> {}; +CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; +class CodeGeneratorResponse_FileDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> {}; +CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; +class CodeGeneratorResponseDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> {}; +CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; namespace { -const ::google::protobuf::Descriptor* CodeGeneratorRequest_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - CodeGeneratorRequest_reflection_ = NULL; -const ::google::protobuf::Descriptor* CodeGeneratorResponse_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - CodeGeneratorResponse_reflection_ = NULL; -const ::google::protobuf::Descriptor* CodeGeneratorResponse_File_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - CodeGeneratorResponse_File_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[3]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/compiler/plugin.proto"); - GOOGLE_CHECK(file != NULL); - CodeGeneratorRequest_descriptor_ = file->message_type(0); - static const int CodeGeneratorRequest_offsets_[3] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, file_to_generate_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, parameter_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, proto_file_), - }; - CodeGeneratorRequest_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - CodeGeneratorRequest_descriptor_, - CodeGeneratorRequest::internal_default_instance(), - CodeGeneratorRequest_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_), - -1, - -1, - sizeof(CodeGeneratorRequest), - 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_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_), - }; - CodeGeneratorResponse_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - CodeGeneratorResponse_descriptor_, - CodeGeneratorResponse::internal_default_instance(), - CodeGeneratorResponse_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_), - -1, - -1, - sizeof(CodeGeneratorResponse), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_)); - CodeGeneratorResponse_File_descriptor_ = CodeGeneratorResponse_descriptor_->nested_type(0); - static const int CodeGeneratorResponse_File_offsets_[3] = { + 1, + 0, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, insertion_point_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, content_), + 0, + 1, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_), + 0, + 1, }; - CodeGeneratorResponse_File_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - CodeGeneratorResponse_File_descriptor_, - CodeGeneratorResponse_File::internal_default_instance(), - CodeGeneratorResponse_File_offsets_, - 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_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, 7, sizeof(CodeGeneratorRequest)}, + { 10, 17, sizeof(CodeGeneratorResponse_File)}, + { 20, 26, sizeof(CodeGeneratorResponse)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorRequest_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_File_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/compiler/plugin.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorRequest_descriptor_, CodeGeneratorRequest::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorResponse_descriptor_, CodeGeneratorResponse::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorResponse_File_descriptor_, CodeGeneratorResponse_File::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 3); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - CodeGeneratorRequest_default_instance_.Shutdown(); - delete CodeGeneratorRequest_reflection_; - CodeGeneratorResponse_default_instance_.Shutdown(); - delete CodeGeneratorResponse_reflection_; - CodeGeneratorResponse_File_default_instance_.Shutdown(); - delete CodeGeneratorResponse_File_reflection_; + _CodeGeneratorRequest_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; + _CodeGeneratorResponse_File_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; + _CodeGeneratorResponse_default_instance_.Shutdown(); + delete file_level_metadata[2].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; ::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_); + ::google::protobuf::internal::InitProtobufDefaults(); + _CodeGeneratorRequest_default_instance_.DefaultConstruct(); + _CodeGeneratorResponse_File_default_instance_.DefaultConstruct(); + _CodeGeneratorResponse_default_instance_.DefaultConstruct(); +} + 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); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&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(); + static const char descriptor[] = { + "\n%google/protobuf/compiler/plugin.proto\022" + "\030google.protobuf.compiler\032 google/protob" + "uf/descriptor.proto\"}\n\024CodeGeneratorRequ" + "est\022\030\n\020file_to_generate\030\001 \003(\t\022\021\n\tparamet" + "er\030\002 \001(\t\0228\n\nproto_file\030\017 \003(\0132$.google.pr" + "otobuf.FileDescriptorProto\"\252\001\n\025CodeGener" + "atorResponse\022\r\n\005error\030\001 \001(\t\022B\n\004file\030\017 \003(" + "\01324.google.protobuf.compiler.CodeGenerat" + "orResponse.File\032>\n\004File\022\014\n\004name\030\001 \001(\t\022\027\n" + "\017insertion_point\030\002 \001(\t\022\017\n\007content\030\017 \001(\tB" + "7\n\034com.google.protobuf.compilerB\014PluginP" + "rotosZ\tplugin_go" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n%google/protobuf/compiler/plugin.proto\022" - "\030google.protobuf.compiler\032 google/protob" - "uf/descriptor.proto\"}\n\024CodeGeneratorRequ" - "est\022\030\n\020file_to_generate\030\001 \003(\t\022\021\n\tparamet" - "er\030\002 \001(\t\0228\n\nproto_file\030\017 \003(\0132$.google.pr" - "otobuf.FileDescriptorProto\"\252\001\n\025CodeGener" - "atorResponse\022\r\n\005error\030\001 \001(\t\022B\n\004file\030\017 \003(" - "\01324.google.protobuf.compiler.CodeGenerat" - "orResponse.File\032>\n\004File\022\014\n\004name\030\001 \001(\t\022\027\n" - "\017insertion_point\030\002 \001(\t\022\017\n\007content\030\017 \001(\tB" - "7\n\034com.google.protobuf.compilerB\014PluginP" - "rotosZ\tplugin_go", 456); + descriptor, 456); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/compiler/plugin.proto", &protobuf_RegisterTypes); ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); @@ -177,16 +163,6 @@ 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 @@ -197,19 +173,24 @@ const int CodeGeneratorRequest::kProtoFileFieldNumber; CodeGeneratorRequest::CodeGeneratorRequest() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorRequest) } - -void CodeGeneratorRequest::InitAsDefaultInstance() { -} - CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + file_to_generate_(from.file_to_generate_), + proto_file_(from.proto_file_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + parameter_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_parameter()) { + parameter_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.parameter_); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorRequest) } @@ -234,7 +215,7 @@ void CodeGeneratorRequest::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* CodeGeneratorRequest::descriptor() { protobuf_AssignDescriptorsOnce(); - return CodeGeneratorRequest_descriptor_; + return file_level_metadata[0].descriptor; } const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() { @@ -242,8 +223,6 @@ const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> CodeGeneratorRequest_default_instance_; - CodeGeneratorRequest* CodeGeneratorRequest::New(::google::protobuf::Arena* arena) const { CodeGeneratorRequest* n = new CodeGeneratorRequest; if (arena != NULL) { @@ -254,15 +233,14 @@ CodeGeneratorRequest* CodeGeneratorRequest::New(::google::protobuf::Arena* arena void CodeGeneratorRequest::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorRequest) - if (has_parameter()) { - parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - } file_to_generate_.Clear(); proto_file_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (has_parameter()) { + GOOGLE_DCHECK(!parameter_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*parameter_.UnsafeRawStringPointer())->clear(); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool CodeGeneratorRequest::MergePartialFromCodedStream( @@ -271,14 +249,13 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorRequest) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated string file_to_generate = 1; case 1: { - if (tag == 10) { - parse_file_to_generate: + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_file_to_generate())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -289,15 +266,12 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_file_to_generate; - if (input->ExpectTag(18)) goto parse_parameter; break; } // optional string parameter = 2; case 2: { - if (tag == 18) { - parse_parameter: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_parameter())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -307,24 +281,19 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(122)) goto parse_proto_file; break; } // repeated .google.protobuf.FileDescriptorProto proto_file = 15; case 15: { - if (tag == 122) { - parse_proto_file: + if (tag == 122u) { DO_(input->IncrementRecursionDepth()); - parse_loop_proto_file: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_proto_file())); } else { goto handle_unusual; } - if (input->ExpectTag(122)) goto parse_loop_proto_file; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -430,13 +399,11 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorRequest) size_t total_size = 0; - // optional string parameter = 2; - if (has_parameter()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->parameter()); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } - // repeated string file_to_generate = 1; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->file_to_generate_size()); @@ -456,11 +423,13 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + // optional string parameter = 2; + if (has_parameter()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->parameter()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -470,7 +439,7 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { 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)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const CodeGeneratorRequest* source = ::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorRequest>( &from); @@ -479,32 +448,19 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void CodeGeneratorRequest::UnsafeMergeFrom(const CodeGeneratorRequest& from) { - GOOGLE_DCHECK(&from != this); - file_to_generate_.UnsafeMergeFrom(from.file_to_generate_); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + file_to_generate_.MergeFrom(from.file_to_generate_); proto_file_.MergeFrom(from.proto_file_); - if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) { - if (from.has_parameter()) { - set_has_parameter(); - parameter_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.parameter_); - } - } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + if (from.has_parameter()) { + set_has_parameter(); + parameter_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.parameter_); } } @@ -519,11 +475,10 @@ void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorRequest) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool CodeGeneratorRequest::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->proto_file())) return false; return true; } @@ -534,8 +489,8 @@ void CodeGeneratorRequest::Swap(CodeGeneratorRequest* other) { } void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { file_to_generate_.UnsafeArenaSwap(&other->file_to_generate_); - parameter_.Swap(&other->parameter_); proto_file_.UnsafeArenaSwap(&other->proto_file_); + parameter_.Swap(&other->parameter_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -543,10 +498,7 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { ::google::protobuf::Metadata CodeGeneratorRequest::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = CodeGeneratorRequest_descriptor_; - metadata.reflection = CodeGeneratorRequest_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -609,13 +561,13 @@ CodeGeneratorRequest::mutable_file_to_generate() { // optional string parameter = 2; bool CodeGeneratorRequest::has_parameter() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } void CodeGeneratorRequest::set_has_parameter() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000001u; } void CodeGeneratorRequest::clear_has_parameter() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000001u; } void CodeGeneratorRequest::clear_parameter() { parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -623,7 +575,7 @@ void CodeGeneratorRequest::clear_parameter() { } const ::std::string& CodeGeneratorRequest::parameter() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter) - return parameter_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return parameter_.GetNoArena(); } void CodeGeneratorRequest::set_parameter(const ::std::string& value) { set_has_parameter(); @@ -691,9 +643,6 @@ CodeGeneratorRequest::proto_file() const { return proto_file_; } -inline const CodeGeneratorRequest* CodeGeneratorRequest::internal_default_instance() { - return &CodeGeneratorRequest_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -706,19 +655,30 @@ 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(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse.File) } - -void CodeGeneratorResponse_File::InitAsDefaultInstance() { -} - CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + insertion_point_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_insertion_point()) { + insertion_point_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.insertion_point_); + } + content_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_content()) { + content_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.content_); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File) } @@ -747,7 +707,7 @@ void CodeGeneratorResponse_File::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* CodeGeneratorResponse_File::descriptor() { protobuf_AssignDescriptorsOnce(); - return CodeGeneratorResponse_File_descriptor_; + return file_level_metadata[1].descriptor; } const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() { @@ -755,8 +715,6 @@ const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() return *internal_default_instance(); } -::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; if (arena != NULL) { @@ -769,19 +727,20 @@ void CodeGeneratorResponse_File::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse.File) if (_has_bits_[0 / 32] & 7u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } if (has_insertion_point()) { - insertion_point_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!insertion_point_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*insertion_point_.UnsafeRawStringPointer())->clear(); } if (has_content()) { - content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!content_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*content_.UnsafeRawStringPointer())->clear(); } } _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool CodeGeneratorResponse_File::MergePartialFromCodedStream( @@ -790,13 +749,13 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorResponse.File) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -806,14 +765,12 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_insertion_point; break; } // optional string insertion_point = 2; case 2: { - if (tag == 18) { - parse_insertion_point: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_insertion_point())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -823,14 +780,12 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(122)) goto parse_content; break; } // optional string content = 15; case 15: { - if (tag == 122) { - parse_content: + if (tag == 122u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_content())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -840,7 +795,6 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -955,6 +909,11 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse.File) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 7u) { // optional string name = 1; if (has_name()) { @@ -978,11 +937,6 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -992,7 +946,7 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const { 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)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const CodeGeneratorResponse_File* source = ::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorResponse_File>( &from); @@ -1001,22 +955,15 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*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_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))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 7u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -1030,10 +977,6 @@ void CodeGeneratorResponse_File::UnsafeMergeFrom(const CodeGeneratorResponse_Fil content_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.content_); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void CodeGeneratorResponse_File::CopyFrom(const ::google::protobuf::Message& from) { @@ -1047,11 +990,10 @@ 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(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool CodeGeneratorResponse_File::IsInitialized() const { - return true; } @@ -1070,14 +1012,177 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) ::google::protobuf::Metadata CodeGeneratorResponse_File::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = CodeGeneratorResponse_File_descriptor_; - metadata.reflection = CodeGeneratorResponse_File_reflection_; - return metadata; + return file_level_metadata[1]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// CodeGeneratorResponse_File + +// optional string name = 1; +bool CodeGeneratorResponse_File::has_name() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void CodeGeneratorResponse_File::set_has_name() { + _has_bits_[0] |= 0x00000001u; +} +void CodeGeneratorResponse_File::clear_has_name() { + _has_bits_[0] &= ~0x00000001u; +} +void CodeGeneratorResponse_File::clear_name() { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_name(); +} +const ::std::string& CodeGeneratorResponse_File::name() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name) + return name_.GetNoArena(); +} +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) { + 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) { + 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() { + 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() { + // @@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) { + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name) +} + +// optional string insertion_point = 2; +bool CodeGeneratorResponse_File::has_insertion_point() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void CodeGeneratorResponse_File::set_has_insertion_point() { + _has_bits_[0] |= 0x00000002u; +} +void CodeGeneratorResponse_File::clear_has_insertion_point() { + _has_bits_[0] &= ~0x00000002u; +} +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 { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) + return insertion_point_.GetNoArena(); +} +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) { + 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) { + 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() { + 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() { + // @@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) { + if (insertion_point != NULL) { + set_has_insertion_point(); + } else { + clear_has_insertion_point(); + } + insertion_point_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), insertion_point); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) +} + +// optional string content = 15; +bool CodeGeneratorResponse_File::has_content() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void CodeGeneratorResponse_File::set_has_content() { + _has_bits_[0] |= 0x00000004u; +} +void CodeGeneratorResponse_File::clear_has_content() { + _has_bits_[0] &= ~0x00000004u; +} +void CodeGeneratorResponse_File::clear_content() { + content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_content(); +} +const ::std::string& CodeGeneratorResponse_File::content() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content) + return content_.GetNoArena(); +} +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) { + 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) { + 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() { + 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() { + // @@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) { + if (content != NULL) { + set_has_content(); + } else { + clear_has_content(); + } + content_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), content); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) } +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS -// ------------------------------------------------------------------- +// =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int CodeGeneratorResponse::kErrorFieldNumber; @@ -1086,19 +1191,23 @@ const int CodeGeneratorResponse::kFileFieldNumber; CodeGeneratorResponse::CodeGeneratorResponse() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse) } - -void CodeGeneratorResponse::InitAsDefaultInstance() { -} - CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + file_(from.file_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + error_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_error()) { + error_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.error_); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse) } @@ -1123,7 +1232,7 @@ void CodeGeneratorResponse::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* CodeGeneratorResponse::descriptor() { protobuf_AssignDescriptorsOnce(); - return CodeGeneratorResponse_descriptor_; + return file_level_metadata[2].descriptor; } const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() { @@ -1131,8 +1240,6 @@ const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> CodeGeneratorResponse_default_instance_; - CodeGeneratorResponse* CodeGeneratorResponse::New(::google::protobuf::Arena* arena) const { CodeGeneratorResponse* n = new CodeGeneratorResponse; if (arena != NULL) { @@ -1143,14 +1250,13 @@ CodeGeneratorResponse* CodeGeneratorResponse::New(::google::protobuf::Arena* are void CodeGeneratorResponse::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse) + file_.Clear(); if (has_error()) { - error_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!error_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*error_.UnsafeRawStringPointer())->clear(); } - file_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool CodeGeneratorResponse::MergePartialFromCodedStream( @@ -1159,13 +1265,13 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorResponse) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string error = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_error())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1175,24 +1281,19 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(122)) goto parse_file; break; } // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; case 15: { - if (tag == 122) { - parse_file: + if (tag == 122u) { DO_(input->IncrementRecursionDepth()); - parse_loop_file: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_file())); } else { goto handle_unusual; } - if (input->ExpectTag(122)) goto parse_loop_file; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -1278,13 +1379,11 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse) size_t total_size = 0; - // optional string error = 1; - if (has_error()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->error()); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } - // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; { unsigned int count = this->file_size(); @@ -1296,11 +1395,13 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + // optional string error = 1; + if (has_error()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->error()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -1310,7 +1411,7 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { 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)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const CodeGeneratorResponse* source = ::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorResponse>( &from); @@ -1319,31 +1420,18 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void CodeGeneratorResponse::UnsafeMergeFrom(const CodeGeneratorResponse& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); file_.MergeFrom(from.file_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_error()) { - set_has_error(); - error_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.error_); - } - } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + if (from.has_error()) { + set_has_error(); + error_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.error_); } } @@ -1358,11 +1446,10 @@ void CodeGeneratorResponse::CopyFrom(const CodeGeneratorResponse& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool CodeGeneratorResponse::IsInitialized() const { - return true; } @@ -1371,8 +1458,8 @@ void CodeGeneratorResponse::Swap(CodeGeneratorResponse* other) { InternalSwap(other); } void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { - error_.Swap(&other->error_); file_.UnsafeArenaSwap(&other->file_); + error_.Swap(&other->error_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -1380,182 +1467,10 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { ::google::protobuf::Metadata CodeGeneratorResponse::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = CodeGeneratorResponse_descriptor_; - metadata.reflection = CodeGeneratorResponse_reflection_; - return metadata; + return file_level_metadata[2]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS -// CodeGeneratorResponse_File - -// optional string name = 1; -bool CodeGeneratorResponse_File::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void CodeGeneratorResponse_File::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -void CodeGeneratorResponse_File::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -void CodeGeneratorResponse_File::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -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) { - 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) { - 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) { - 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() { - 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() { - // @@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) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} - -// optional string insertion_point = 2; -bool CodeGeneratorResponse_File::has_insertion_point() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void CodeGeneratorResponse_File::set_has_insertion_point() { - _has_bits_[0] |= 0x00000002u; -} -void CodeGeneratorResponse_File::clear_has_insertion_point() { - _has_bits_[0] &= ~0x00000002u; -} -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 { - // @@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) { - 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) { - 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) { - 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() { - 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() { - // @@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) { - if (insertion_point != NULL) { - set_has_insertion_point(); - } else { - clear_has_insertion_point(); - } - insertion_point_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), insertion_point); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} - -// optional string content = 15; -bool CodeGeneratorResponse_File::has_content() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void CodeGeneratorResponse_File::set_has_content() { - _has_bits_[0] |= 0x00000004u; -} -void CodeGeneratorResponse_File::clear_has_content() { - _has_bits_[0] &= ~0x00000004u; -} -void CodeGeneratorResponse_File::clear_content() { - content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_content(); -} -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) { - 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) { - 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) { - 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() { - 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() { - // @@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) { - if (content != NULL) { - set_has_content(); - } else { - clear_has_content(); - } - content_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), content); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} - -inline const CodeGeneratorResponse_File* CodeGeneratorResponse_File::internal_default_instance() { - return &CodeGeneratorResponse_File_default_instance_.get(); -} -// ------------------------------------------------------------------- - // CodeGeneratorResponse // optional string error = 1; @@ -1574,7 +1489,7 @@ void CodeGeneratorResponse::clear_error() { } const ::std::string& CodeGeneratorResponse::error() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error) - return error_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return error_.GetNoArena(); } void CodeGeneratorResponse::set_error(const ::std::string& value) { set_has_error(); @@ -1642,9 +1557,6 @@ CodeGeneratorResponse::file() const { return file_; } -inline const CodeGeneratorResponse* CodeGeneratorResponse::internal_default_instance() { - return &CodeGeneratorResponse_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index f9a99e75..11c837a3 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -24,11 +24,101 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/descriptor.pb.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class DescriptorProto; +class DescriptorProtoDefaultTypeInternal; +extern DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; +class DescriptorProto_ExtensionRange; +class DescriptorProto_ExtensionRangeDefaultTypeInternal; +extern DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; +class DescriptorProto_ReservedRange; +class DescriptorProto_ReservedRangeDefaultTypeInternal; +extern DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; +class EnumDescriptorProto; +class EnumDescriptorProtoDefaultTypeInternal; +extern EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; +class EnumOptions; +class EnumOptionsDefaultTypeInternal; +extern EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; +class EnumValueDescriptorProto; +class EnumValueDescriptorProtoDefaultTypeInternal; +extern EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; +class EnumValueOptions; +class EnumValueOptionsDefaultTypeInternal; +extern EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; +class FieldDescriptorProto; +class FieldDescriptorProtoDefaultTypeInternal; +extern FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; +class FieldOptions; +class FieldOptionsDefaultTypeInternal; +extern FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; +class FileDescriptorProto; +class FileDescriptorProtoDefaultTypeInternal; +extern FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; +class FileDescriptorSet; +class FileDescriptorSetDefaultTypeInternal; +extern FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; +class FileOptions; +class FileOptionsDefaultTypeInternal; +extern FileOptionsDefaultTypeInternal _FileOptions_default_instance_; +class GeneratedCodeInfo; +class GeneratedCodeInfoDefaultTypeInternal; +extern GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; +class GeneratedCodeInfo_Annotation; +class GeneratedCodeInfo_AnnotationDefaultTypeInternal; +extern GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; +class MessageOptions; +class MessageOptionsDefaultTypeInternal; +extern MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; +class MethodDescriptorProto; +class MethodDescriptorProtoDefaultTypeInternal; +extern MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; +class MethodOptions; +class MethodOptionsDefaultTypeInternal; +extern MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; +class OneofDescriptorProto; +class OneofDescriptorProtoDefaultTypeInternal; +extern OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; +class OneofOptions; +class OneofOptionsDefaultTypeInternal; +extern OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; +class ServiceDescriptorProto; +class ServiceDescriptorProtoDefaultTypeInternal; +extern ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; +class ServiceOptions; +class ServiceOptionsDefaultTypeInternal; +extern ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; +class SourceCodeInfo; +class SourceCodeInfoDefaultTypeInternal; +extern SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; +class SourceCodeInfo_Location; +class SourceCodeInfo_LocationDefaultTypeInternal; +extern SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; +class UninterpretedOption; +class UninterpretedOptionDefaultTypeInternal; +extern UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; +class UninterpretedOption_NamePart; +class UninterpretedOption_NamePartDefaultTypeInternal; +extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; +namespace compiler { +class CodeGeneratorRequest; +class CodeGeneratorRequestDefaultTypeInternal; +extern CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; +class CodeGeneratorResponse; +class CodeGeneratorResponseDefaultTypeInternal; +extern CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; +class CodeGeneratorResponse_File; +class CodeGeneratorResponse_FileDefaultTypeInternal; +extern CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; +} // namespace compiler +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -37,12 +127,6 @@ 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(); - -class CodeGeneratorRequest; -class CodeGeneratorResponse; -class CodeGeneratorResponse_File; // =================================================================== @@ -69,49 +153,52 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorRequest& default_instance(); - static const CodeGeneratorRequest* internal_default_instance(); + static inline const CodeGeneratorRequest* internal_default_instance() { + return reinterpret_cast<const CodeGeneratorRequest*>( + &_CodeGeneratorRequest_default_instance_); + } void Swap(CodeGeneratorRequest* other); // implements Message ---------------------------------------------- - inline CodeGeneratorRequest* New() const { return New(NULL); } + inline CodeGeneratorRequest* New() const PROTOBUF_FINAL { return New(NULL); } - CodeGeneratorRequest* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + CodeGeneratorRequest* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const CodeGeneratorRequest& from); void MergeFrom(const CodeGeneratorRequest& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(CodeGeneratorRequest* other); - void UnsafeMergeFrom(const CodeGeneratorRequest& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -159,8 +246,8 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorRequest) private: - inline void set_has_parameter(); - inline void clear_has_parameter(); + void set_has_parameter(); + void clear_has_parameter(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -170,13 +257,10 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message ::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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> CodeGeneratorRequest_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ { @@ -202,49 +286,52 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorResponse_File& default_instance(); - static const CodeGeneratorResponse_File* internal_default_instance(); + static inline const CodeGeneratorResponse_File* internal_default_instance() { + return reinterpret_cast<const CodeGeneratorResponse_File*>( + &_CodeGeneratorResponse_File_default_instance_); + } void Swap(CodeGeneratorResponse_File* other); // implements Message ---------------------------------------------- - inline CodeGeneratorResponse_File* New() const { return New(NULL); } + inline CodeGeneratorResponse_File* New() const PROTOBUF_FINAL { return New(NULL); } - CodeGeneratorResponse_File* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + CodeGeneratorResponse_File* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const CodeGeneratorResponse_File& from); void MergeFrom(const CodeGeneratorResponse_File& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(CodeGeneratorResponse_File* other); - void UnsafeMergeFrom(const CodeGeneratorResponse_File& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -288,12 +375,12 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse.File) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_insertion_point(); - inline void clear_has_insertion_point(); - inline void set_has_content(); - inline void clear_has_content(); + void set_has_name(); + void clear_has_name(); + void set_has_insertion_point(); + void clear_has_insertion_point(); + void set_has_content(); + void clear_has_content(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -303,13 +390,10 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M ::google::protobuf::internal::ArenaStringPtr content_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> CodeGeneratorResponse_File_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ { @@ -335,49 +419,52 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorResponse& default_instance(); - static const CodeGeneratorResponse* internal_default_instance(); + static inline const CodeGeneratorResponse* internal_default_instance() { + return reinterpret_cast<const CodeGeneratorResponse*>( + &_CodeGeneratorResponse_default_instance_); + } void Swap(CodeGeneratorResponse* other); // implements Message ---------------------------------------------- - inline CodeGeneratorResponse* New() const { return New(NULL); } + inline CodeGeneratorResponse* New() const PROTOBUF_FINAL { return New(NULL); } - CodeGeneratorResponse* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + CodeGeneratorResponse* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const CodeGeneratorResponse& from); void MergeFrom(const CodeGeneratorResponse& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(CodeGeneratorResponse* other); - void UnsafeMergeFrom(const CodeGeneratorResponse& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -411,8 +498,8 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse) private: - inline void set_has_error(); - inline void clear_has_error(); + void set_has_error(); + void clear_has_error(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -421,13 +508,10 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag ::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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> CodeGeneratorResponse_default_instance_; - // =================================================================== @@ -493,13 +577,13 @@ CodeGeneratorRequest::mutable_file_to_generate() { // optional string parameter = 2; inline bool CodeGeneratorRequest::has_parameter() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } inline void CodeGeneratorRequest::set_has_parameter() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000001u; } inline void CodeGeneratorRequest::clear_has_parameter() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000001u; } inline void CodeGeneratorRequest::clear_parameter() { parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -507,7 +591,7 @@ inline void CodeGeneratorRequest::clear_parameter() { } inline const ::std::string& CodeGeneratorRequest::parameter() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter) - return parameter_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return parameter_.GetNoArena(); } inline void CodeGeneratorRequest::set_parameter(const ::std::string& value) { set_has_parameter(); @@ -575,9 +659,6 @@ CodeGeneratorRequest::proto_file() const { return proto_file_; } -inline const CodeGeneratorRequest* CodeGeneratorRequest::internal_default_instance() { - return &CodeGeneratorRequest_default_instance_.get(); -} // ------------------------------------------------------------------- // CodeGeneratorResponse_File @@ -598,7 +679,7 @@ inline void CodeGeneratorResponse_File::clear_name() { } inline 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()); + return name_.GetNoArena(); } inline void CodeGeneratorResponse_File::set_name(const ::std::string& value) { set_has_name(); @@ -652,7 +733,7 @@ inline void CodeGeneratorResponse_File::clear_insertion_point() { } inline 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()); + return insertion_point_.GetNoArena(); } inline void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) { set_has_insertion_point(); @@ -706,7 +787,7 @@ inline void CodeGeneratorResponse_File::clear_content() { } inline 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()); + return content_.GetNoArena(); } inline void CodeGeneratorResponse_File::set_content(const ::std::string& value) { set_has_content(); @@ -744,9 +825,6 @@ inline void CodeGeneratorResponse_File::set_allocated_content(::std::string* con // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) } -inline const CodeGeneratorResponse_File* CodeGeneratorResponse_File::internal_default_instance() { - return &CodeGeneratorResponse_File_default_instance_.get(); -} // ------------------------------------------------------------------- // CodeGeneratorResponse @@ -767,7 +845,7 @@ inline void CodeGeneratorResponse::clear_error() { } inline const ::std::string& CodeGeneratorResponse::error() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error) - return error_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return error_.GetNoArena(); } inline void CodeGeneratorResponse::set_error(const ::std::string& value) { set_has_error(); @@ -835,9 +913,6 @@ CodeGeneratorResponse::file() const { return file_; } -inline const CodeGeneratorResponse* CodeGeneratorResponse::internal_default_instance() { - return &CodeGeneratorResponse_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- @@ -846,6 +921,7 @@ inline const CodeGeneratorResponse* CodeGeneratorResponse::internal_default_inst // @@protoc_insertion_point(namespace_scope) + } // namespace compiler } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc index 3b1b0d1d..f5769128 100644 --- a/src/google/protobuf/compiler/python/python_generator.cc +++ b/src/google/protobuf/compiler/python/python_generator.cc @@ -120,7 +120,7 @@ const char* const* kKeywordsEnd = kKeywords + (sizeof(kKeywords) / sizeof(kKeywords[0])); bool ContainsPythonKeyword(const string& module_name) { - vector<string> tokens = Split(module_name, "."); + std::vector<string> tokens = Split(module_name, "."); for (int i = 0; i < tokens.size(); ++i) { if (std::find(kKeywords, kKeywordsEnd, tokens[i]) != kKeywordsEnd) { return true; @@ -230,11 +230,11 @@ string StringifyDefaultValue(const FieldDescriptor& field) { return SimpleItoa(field.default_value_uint64()); case FieldDescriptor::CPPTYPE_DOUBLE: { double value = field.default_value_double(); - if (value == numeric_limits<double>::infinity()) { + if (value == std::numeric_limits<double>::infinity()) { // Python pre-2.6 on Windows does not parse "inf" correctly. However, // a numeric literal that is too big for a double will become infinity. return "1e10000"; - } else if (value == -numeric_limits<double>::infinity()) { + } else if (value == -std::numeric_limits<double>::infinity()) { // See above. return "-1e10000"; } else if (value != value) { @@ -246,11 +246,11 @@ string StringifyDefaultValue(const FieldDescriptor& field) { } case FieldDescriptor::CPPTYPE_FLOAT: { float value = field.default_value_float(); - if (value == numeric_limits<float>::infinity()) { + if (value == std::numeric_limits<float>::infinity()) { // Python pre-2.6 on Windows does not parse "inf" correctly. However, // a numeric literal that is too big for a double will become infinity. return "1e10000"; - } else if (value == -numeric_limits<float>::infinity()) { + } else if (value == -std::numeric_limits<float>::infinity()) { // See above. return "-1e10000"; } else if (value != value) { @@ -405,7 +405,7 @@ void Generator::PrintImports() const { // Prints the single file descriptor for this file. void Generator::PrintFileDescriptor() const { - map<string, string> m; + std::map<string, string> m; m["descriptor_name"] = kDescriptorKey; m["name"] = file_->name(); m["package"] = file_->package(); @@ -453,7 +453,7 @@ void Generator::PrintFileDescriptor() const { // Prints descriptors and module-level constants for all top-level // enums defined in |file|. void Generator::PrintTopLevelEnums() const { - vector<pair<string, int> > top_level_enum_values; + std::vector<std::pair<string, int> > top_level_enum_values; for (int i = 0; i < file_->enum_type_count(); ++i) { const EnumDescriptor& enum_descriptor = *file_->enum_type(i); PrintEnum(enum_descriptor); @@ -490,7 +490,7 @@ void Generator::PrintAllNestedEnumsInFile() const { // enum name to a Python EnumDescriptor object equivalent to // enum_descriptor. void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const { - map<string, string> m; + std::map<string, string> m; string module_level_descriptor_name = ModuleLevelDescriptorName(enum_descriptor); m["descriptor_name"] = module_level_descriptor_name; @@ -584,7 +584,7 @@ void Generator::PrintServiceDescriptor( "$service_name$ = _descriptor.ServiceDescriptor(\n", "service_name", service_name); printer_->Indent(); - map<string, string> m; + std::map<string, string> m; m["name"] = descriptor.name(); m["full_name"] = descriptor.full_name(); m["file"] = kDescriptorKey; @@ -680,7 +680,7 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const { "descriptor_name", ModuleLevelDescriptorName(message_descriptor)); printer_->Indent(); - map<string, string> m; + std::map<string, string> m; m["name"] = message_descriptor.name(); m["full_name"] = message_descriptor.full_name(); m["file"] = kDescriptorKey; @@ -740,7 +740,7 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const { printer_->Indent(); for (int i = 0; i < message_descriptor.oneof_decl_count(); ++i) { const OneofDescriptor* desc = message_descriptor.oneof_decl(i); - map<string, string> m; + std::map<string, string> m; m["name"] = desc->name(); m["full_name"] = desc->full_name(); m["index"] = SimpleItoa(desc->index()); @@ -781,7 +781,7 @@ void Generator::PrintNestedDescriptors( // Prints all messages in |file|. void Generator::PrintMessages() const { for (int i = 0; i < file_->message_type_count(); ++i) { - vector<string> to_register; + std::vector<string> to_register; PrintMessage(*file_->message_type(i), "", &to_register); for (int j = 0; j < to_register.size(); ++j) { printer_->Print("_sym_db.RegisterMessage($name$)\n", "name", @@ -801,7 +801,7 @@ void Generator::PrintMessages() const { // Collect nested message names to_register for the symbol_database. void Generator::PrintMessage(const Descriptor& message_descriptor, const string& prefix, - vector<string>* to_register) const { + std::vector<string>* to_register) const { string qualified_name(prefix + message_descriptor.name()); to_register->push_back(qualified_name); printer_->Print( @@ -811,7 +811,7 @@ void Generator::PrintMessage(const Descriptor& message_descriptor, printer_->Indent(); PrintNestedMessages(message_descriptor, qualified_name + ".", to_register); - map<string, string> m; + std::map<string, string> m; m["descriptor_key"] = kDescriptorKey; m["descriptor_name"] = ModuleLevelDescriptorName(message_descriptor); printer_->Print(m, "$descriptor_key$ = $descriptor_name$,\n"); @@ -827,7 +827,7 @@ void Generator::PrintMessage(const Descriptor& message_descriptor, // Mutually recursive with PrintMessage(). void Generator::PrintNestedMessages(const Descriptor& containing_descriptor, const string& prefix, - vector<string>* to_register) const { + std::vector<string>* to_register) const { for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) { printer_->Print("\n"); PrintMessage(*containing_descriptor.nested_type(i), prefix, to_register); @@ -860,7 +860,7 @@ void Generator::FixForeignFieldsInDescriptor( FixContainingTypeInDescriptor(enum_descriptor, &descriptor); } for (int i = 0; i < descriptor.oneof_decl_count(); ++i) { - map<string, string> m; + std::map<string, string> m; const OneofDescriptor* oneof = descriptor.oneof_decl(i); m["descriptor_name"] = ModuleLevelDescriptorName(descriptor); m["oneof_name"] = oneof->name(); @@ -879,7 +879,7 @@ void Generator::FixForeignFieldsInDescriptor( } void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const { - map<string, string> m; + std::map<string, string> m; m["descriptor_name"] = kDescriptorKey; m["message_name"] = descriptor.name(); m["message_descriptor_name"] = ModuleLevelDescriptorName(descriptor); @@ -891,7 +891,7 @@ void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const { void Generator::AddEnumToFileDescriptor( const EnumDescriptor& descriptor) const { - map<string, string> m; + std::map<string, string> m; m["descriptor_name"] = kDescriptorKey; m["enum_name"] = descriptor.name(); m["enum_descriptor_name"] = ModuleLevelDescriptorName(descriptor); @@ -903,7 +903,7 @@ void Generator::AddEnumToFileDescriptor( void Generator::AddExtensionToFileDescriptor( const FieldDescriptor& descriptor) const { - map<string, string> m; + std::map<string, string> m; m["descriptor_name"] = kDescriptorKey; m["field_name"] = descriptor.name(); const char file_descriptor_template[] = @@ -926,7 +926,7 @@ void Generator::FixForeignFieldsInField(const Descriptor* containing_type, const string& python_dict_name) const { const string field_referencing_expression = FieldReferencingExpression( containing_type, field, python_dict_name); - map<string, string> m; + std::map<string, string> m; m["field_ref"] = field_referencing_expression; const Descriptor* foreign_message_type = field.message_type(); if (foreign_message_type) { @@ -1025,7 +1025,7 @@ void Generator::FixForeignFieldsInExtension( FixForeignFieldsInField(extension_field.extension_scope(), extension_field, "extensions_by_name"); - map<string, string> m; + std::map<string, string> m; // Confusingly, for FieldDescriptors that happen to be extensions, // containing_type() means "extended type." // On the other hand, extension_scope() will give us what we normally @@ -1058,7 +1058,7 @@ void Generator::PrintEnumValueDescriptor( // More circular references. ::sigh:: string options_string; descriptor.options().SerializeToString(&options_string); - map<string, string> m; + std::map<string, string> m; m["name"] = descriptor.name(); m["index"] = SimpleItoa(descriptor.index()); m["number"] = SimpleItoa(descriptor.number()); @@ -1091,7 +1091,7 @@ void Generator::PrintFieldDescriptor( const FieldDescriptor& field, bool is_extension) const { string options_string; field.options().SerializeToString(&options_string); - map<string, string> m; + std::map<string, string> m; m["name"] = field.name(); m["full_name"] = field.full_name(); m["index"] = SimpleItoa(field.index()); diff --git a/src/google/protobuf/compiler/python/python_generator.h b/src/google/protobuf/compiler/python/python_generator.h index 7583aa65..594260af 100644 --- a/src/google/protobuf/compiler/python/python_generator.h +++ b/src/google/protobuf/compiler/python/python_generator.h @@ -97,10 +97,10 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { void PrintMessages() const; void PrintMessage(const Descriptor& message_descriptor, const string& prefix, - vector<string>* to_register) const; + std::vector<string>* to_register) const; void PrintNestedMessages(const Descriptor& containing_descriptor, const string& prefix, - vector<string>* to_register) const; + std::vector<string>* to_register) const; void FixForeignFieldsInDescriptors() const; void FixForeignFieldsInDescriptor( diff --git a/src/google/protobuf/compiler/subprocess.cc b/src/google/protobuf/compiler/subprocess.cc index e929e4fb..933450fa 100644 --- a/src/google/protobuf/compiler/subprocess.cc +++ b/src/google/protobuf/compiler/subprocess.cc @@ -261,9 +261,8 @@ string Subprocess::Win32ErrorMessage(DWORD error_code) { char* message; // WTF? - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, + FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error_code, 0, (LPSTR)&message, // NOT A BUG! 0, NULL); diff --git a/src/google/protobuf/compiler/zip_writer.h b/src/google/protobuf/compiler/zip_writer.h index 602e508e..03db4d57 100644 --- a/src/google/protobuf/compiler/zip_writer.h +++ b/src/google/protobuf/compiler/zip_writer.h @@ -85,7 +85,7 @@ class ZipWriter { }; io::ZeroCopyOutputStream* raw_output_; - vector<FileInfo> files_; + std::vector<FileInfo> files_; }; } // namespace compiler diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index be1e1d69..7dfdb377 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -315,7 +315,7 @@ class PrefixRemover { // be a lot cleaner but we'd just have to convert it back to const char* // for the open source release. -typedef pair<const void*, const char*> PointerStringPair; +typedef std::pair<const void*, const char*> PointerStringPair; struct PointerStringPairEqual { inline bool operator()(const PointerStringPair& a, @@ -343,8 +343,8 @@ struct PointerIntegerPairHash { } }; -typedef pair<const Descriptor*, int> DescriptorIntPair; -typedef pair<const EnumDescriptor*, int> EnumIntPair; +typedef std::pair<const Descriptor*, int> DescriptorIntPair; +typedef std::pair<const EnumDescriptor*, int> EnumIntPair; struct PointerStringPairHash { size_t operator()(const PointerStringPair& p) const { @@ -452,11 +452,11 @@ typedef hash_map<EnumIntPair, const EnumValueDescriptor*, // through all the extensions that extend a given Descriptor, and an // ordered data structure that implements lower_bound is convenient // for that. -typedef map<DescriptorIntPair, const FieldDescriptor*> +typedef std::map<DescriptorIntPair, const FieldDescriptor*> ExtensionsGroupedByDescriptorMap; typedef hash_map<string, const SourceCodeInfo_Location*> LocationsByPathMap; -set<string>* allowed_proto3_extendees_ = NULL; +std::set<string>* allowed_proto3_extendees_ = NULL; GOOGLE_PROTOBUF_DECLARE_ONCE(allowed_proto3_extendees_init_); void DeleteAllowedProto3Extendee() { @@ -464,7 +464,7 @@ void DeleteAllowedProto3Extendee() { } void InitAllowedProto3Extendee() { - allowed_proto3_extendees_ = new set<string>; + allowed_proto3_extendees_ = new std::set<string>; const char* kOptionNames[] = { "FileOptions", "MessageOptions", "FieldOptions", "EnumOptions", "EnumValueOptions", "ServiceOptions", "MethodOptions"}; @@ -542,7 +542,7 @@ class DescriptorPool::Tables { // The stack of files which are currently being built. Used to detect // cyclic dependencies when loading files from a DescriptorDatabase. Not // used when fallback_database_ == NULL. - vector<string> pending_files_; + std::vector<string> pending_files_; // A set of files which we have tried to load from the fallback database // and encountered errors. We will not attempt to load them again during @@ -580,7 +580,7 @@ class DescriptorPool::Tables { inline const FieldDescriptor* FindExtension(const Descriptor* extendee, int number); inline void FindAllExtensions(const Descriptor* extendee, - vector<const FieldDescriptor*>* out) const; + std::vector<const FieldDescriptor*>* out) const; // ----------------------------------------------------------------- // Adding items. @@ -620,10 +620,11 @@ class DescriptorPool::Tables { FileDescriptorTables* AllocateFileTables(); private: - vector<string*> strings_; // All strings in the pool. - vector<Message*> messages_; // All messages in the pool. - vector<FileDescriptorTables*> file_tables_; // All file tables in the pool. - vector<void*> allocations_; // All other memory allocated in the pool. + std::vector<string*> strings_; // All strings in the pool. + std::vector<Message*> messages_; // All messages in the pool. + std::vector<FileDescriptorTables*> + file_tables_; // All file tables in the pool. + std::vector<void*> allocations_; // All other memory allocated in the pool. SymbolsByNameMap symbols_by_name_; FilesByNameMap files_by_name_; @@ -650,10 +651,10 @@ class DescriptorPool::Tables { int pending_files_before_checkpoint; int pending_extensions_before_checkpoint; }; - vector<CheckPoint> checkpoints_; - vector<const char* > symbols_after_checkpoint_; - vector<const char* > files_after_checkpoint_; - vector<DescriptorIntPair> extensions_after_checkpoint_; + std::vector<CheckPoint> checkpoints_; + std::vector<const char* > symbols_after_checkpoint_; + std::vector<const char* > files_after_checkpoint_; + std::vector<DescriptorIntPair> extensions_after_checkpoint_; // Allocate some bytes which will be reclaimed when the pool is // destroyed. @@ -720,14 +721,14 @@ class FileDescriptorTables { // Populates p->first->locations_by_path_ from p->second. // Unusual signature dictated by GoogleOnceDynamic. static void BuildLocationsByPath( - pair<const FileDescriptorTables*, const SourceCodeInfo*>* p); + std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p); // Returns the location denoted by the specified path through info, // or NULL if not found. // The value of info must be that of the corresponding FileDescriptor. // (Conceptually a pure function, but stateful as an optimisation.) const SourceCodeInfo_Location* GetSourceLocation( - const vector<int>& path, const SourceCodeInfo* info) const; + const std::vector<int>& path, const SourceCodeInfo* info) const; private: SymbolsByParentMap symbols_by_parent_; @@ -1008,7 +1009,8 @@ inline const FieldDescriptor* DescriptorPool::Tables::FindExtension( } inline void DescriptorPool::Tables::FindAllExtensions( - const Descriptor* extendee, vector<const FieldDescriptor*>* out) const { + const Descriptor* extendee, + std::vector<const FieldDescriptor*>* out) const { ExtensionsGroupedByDescriptorMap::const_iterator it = extensions_.lower_bound(std::make_pair(extendee, 0)); for (; it != extensions_.end() && it->first.first == extendee; ++it) { @@ -1128,7 +1130,7 @@ void* DescriptorPool::Tables::AllocateBytes(int size) { } void FileDescriptorTables::BuildLocationsByPath( - pair<const FileDescriptorTables*, const SourceCodeInfo*>* p) { + std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p) { for (int i = 0, len = p->second->location_size(); i < len; ++i) { const SourceCodeInfo_Location* loc = &p->second->location().Get(i); p->first->locations_by_path_[Join(loc->path(), ",")] = loc; @@ -1136,8 +1138,8 @@ void FileDescriptorTables::BuildLocationsByPath( } const SourceCodeInfo_Location* FileDescriptorTables::GetSourceLocation( - const vector<int>& path, const SourceCodeInfo* info) const { - pair<const FileDescriptorTables*, const SourceCodeInfo*> p( + const std::vector<int>& path, const SourceCodeInfo* info) const { + std::pair<const FileDescriptorTables*, const SourceCodeInfo*> p( std::make_pair(this, info)); locations_by_path_once_.Init(&FileDescriptorTables::BuildLocationsByPath, &p); return FindPtrOrNull(locations_by_path_, Join(path, ",")); @@ -1239,6 +1241,7 @@ const DescriptorPool* DescriptorPool::generated_pool() { } + DescriptorPool* DescriptorPool::internal_generated_pool() { InitGeneratedPoolOnce(); return generated_pool_; @@ -1397,7 +1400,8 @@ const FieldDescriptor* DescriptorPool::FindExtensionByNumber( } void DescriptorPool::FindAllExtensions( - const Descriptor* extendee, vector<const FieldDescriptor*>* out) const { + const Descriptor* extendee, + std::vector<const FieldDescriptor*>* out) const { MutexLockMaybe lock(mutex_); tables_->known_bad_symbols_.clear(); tables_->known_bad_files_.clear(); @@ -1406,7 +1410,7 @@ void DescriptorPool::FindAllExtensions( // (but do this only once per descriptor). if (fallback_database_ != NULL && tables_->extensions_loaded_from_db_.count(extendee) == 0) { - vector<int> numbers; + std::vector<int> numbers; if (fallback_database_->FindAllExtensionNumbers(extendee->full_name(), &numbers)) { for (int i = 0; i < numbers.size(); ++i) { @@ -2071,13 +2075,11 @@ void MethodDescriptor::CopyTo(MethodDescriptorProto* proto) const { namespace { -// Used by each of the option formatters. -bool RetrieveOptions(int depth, - const Message &options, - vector<string> *option_entries) { +bool RetrieveOptionsAssumingRightPool(int depth, const Message& options, + std::vector<string>* option_entries) { option_entries->clear(); const Reflection* reflection = options.GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(options, &fields); for (int i = 0; i < fields.size(); i++) { int count = 1; @@ -2114,21 +2116,56 @@ bool RetrieveOptions(int depth, return !option_entries->empty(); } +// Used by each of the option formatters. +bool RetrieveOptions(int depth, const Message& options, + const DescriptorPool* pool, + std::vector<string>* option_entries) { + // When printing custom options for a descriptor, we must use an options + // message built on top of the same DescriptorPool where the descriptor + // is coming from. This is to ensure we are interpreting custom options + // against the right pool. + if (options.GetDescriptor()->file()->pool() == pool) { + return RetrieveOptionsAssumingRightPool(depth, options, option_entries); + } else { + const Descriptor* option_descriptor = + pool->FindMessageTypeByName(options.GetDescriptor()->full_name()); + if (option_descriptor == NULL) { + // google/protobuf/descriptor.proto is not in the pool. This means no + // custom options are used so we are safe to proceed with the compiled + // options message type. + return RetrieveOptionsAssumingRightPool(depth, options, option_entries); + } + DynamicMessageFactory factory; + google::protobuf::scoped_ptr<Message> dynamic_options( + factory.GetPrototype(option_descriptor)->New()); + if (dynamic_options->ParseFromString(options.SerializeAsString())) { + return RetrieveOptionsAssumingRightPool(depth, *dynamic_options, + option_entries); + } else { + GOOGLE_LOG(ERROR) << "Found invalid proto option data for: " + << options.GetDescriptor()->full_name(); + return RetrieveOptionsAssumingRightPool(depth, options, option_entries); + } + } +} + // Formats options that all appear together in brackets. Does not include // brackets. -bool FormatBracketedOptions(int depth, const Message &options, string *output) { - vector<string> all_options; - if (RetrieveOptions(depth, options, &all_options)) { +bool FormatBracketedOptions(int depth, const Message& options, + const DescriptorPool* pool, string* output) { + std::vector<string> all_options; + if (RetrieveOptions(depth, options, pool, &all_options)) { output->append(Join(all_options, ", ")); } return !all_options.empty(); } // Formats options one per line -bool FormatLineOptions(int depth, const Message &options, string *output) { +bool FormatLineOptions(int depth, const Message& options, + const DescriptorPool* pool, string* output) { string prefix(depth * 2, ' '); - vector<string> all_options; - if (RetrieveOptions(depth, options, &all_options)) { + std::vector<string> all_options; + if (RetrieveOptions(depth, options, pool, &all_options)) { for (int i = 0; i < all_options.size(); i++) { strings::SubstituteAndAppend(output, "$0option $1;\n", prefix, all_options[i]); @@ -2150,7 +2187,7 @@ class SourceLocationCommentPrinter { desc->GetSourceLocation(&source_loc_); } SourceLocationCommentPrinter(const FileDescriptor* file, - const vector<int>& path, + const std::vector<int>& path, const string& prefix, const DebugStringOptions& options) : options_(options), prefix_(prefix) { @@ -2183,7 +2220,7 @@ class SourceLocationCommentPrinter { string FormatComment(const string& comment_text) { string stripped_comment = comment_text; StripWhitespace(&stripped_comment); - vector<string> lines = Split(stripped_comment, "\n"); + std::vector<string> lines = Split(stripped_comment, "\n"); string output; for (int i = 0; i < lines.size(); ++i) { const string& line = lines[i]; @@ -2211,7 +2248,7 @@ string FileDescriptor::DebugStringWithOptions( const DebugStringOptions& debug_string_options) const { string contents; { - vector<int> path; + std::vector<int> path; path.push_back(FileDescriptorProto::kSyntaxFieldNumber); SourceLocationCommentPrinter syntax_comment( this, path, "", debug_string_options); @@ -2225,8 +2262,8 @@ string FileDescriptor::DebugStringWithOptions( comment_printer(this, "", debug_string_options); comment_printer.AddPreComment(&contents); - set<int> public_dependencies; - set<int> weak_dependencies; + std::set<int> public_dependencies; + std::set<int> weak_dependencies; public_dependencies.insert(public_dependencies_, public_dependencies_ + public_dependency_count_); weak_dependencies.insert(weak_dependencies_, @@ -2246,7 +2283,7 @@ string FileDescriptor::DebugStringWithOptions( } if (!package().empty()) { - vector<int> path; + std::vector<int> path; path.push_back(FileDescriptorProto::kPackageFieldNumber); SourceLocationCommentPrinter package_comment( this, path, "", debug_string_options); @@ -2255,7 +2292,7 @@ string FileDescriptor::DebugStringWithOptions( package_comment.AddPostComment(&contents); } - if (FormatLineOptions(0, options(), &contents)) { + if (FormatLineOptions(0, options(), pool(), &contents)) { contents.append("\n"); // add some space if we had options } @@ -2266,7 +2303,7 @@ string FileDescriptor::DebugStringWithOptions( // Find all the 'group' type extensions; we will not output their nested // definitions (those will be done with their group field descriptor). - set<const Descriptor*> groups; + std::set<const Descriptor*> groups; for (int i = 0; i < extension_count(); i++) { if (extension(i)->type() == FieldDescriptor::TYPE_GROUP) { groups.insert(extension(i)->message_type()); @@ -2336,12 +2373,12 @@ void Descriptor::DebugString(int depth, string *contents, } contents->append(" {\n"); - FormatLineOptions(depth, options(), contents); + FormatLineOptions(depth, options(), file()->pool(), contents); // Find all the 'group' types for fields and extensions; we will not output // their nested definitions (those will be done with their group field // descriptor). - set<const Descriptor*> groups; + std::set<const Descriptor*> groups; for (int i = 0; i < field_count(); i++) { if (field(i)->type() == FieldDescriptor::TYPE_GROUP) { groups.insert(field(i)->message_type()); @@ -2474,8 +2511,18 @@ void FieldDescriptor::DebugString(int depth, field_type = FieldTypeNameDebugString(); } + bool print_label = true; + // Determine whether to omit label: + // 1. For an optional field, omit label if it's in oneof or in proto3. + // 2. For a repeated field, omit label if it's a map. + if (is_optional() && (print_label_flag == OMIT_LABEL || + file()->syntax() == FileDescriptor::SYNTAX_PROTO3)) { + print_label = false; + } else if (is_map()) { + print_label = false; + } string label; - if (print_label_flag == PRINT_LABEL && !is_map()) { + if (print_label) { label = kLabelToName[this->label()]; label.push_back(' '); } @@ -2511,7 +2558,8 @@ void FieldDescriptor::DebugString(int depth, } string formatted_options; - if (FormatBracketedOptions(depth, options(), &formatted_options)) { + if (FormatBracketedOptions(depth, options(), file()->pool(), + &formatted_options)) { contents->append(bracketed ? ", " : " ["); bracketed = true; contents->append(formatted_options); @@ -2555,14 +2603,15 @@ void OneofDescriptor::DebugString(int depth, string* contents, SourceLocationCommentPrinter comment_printer(this, prefix, debug_string_options); comment_printer.AddPreComment(contents); - strings::SubstituteAndAppend( - contents, "$0 oneof $1 {", prefix, name()); + strings::SubstituteAndAppend(contents, "$0oneof $1 {", prefix, name()); - FormatLineOptions(depth, options(), contents); + FormatLineOptions(depth, options(), containing_type()->file()->pool(), + contents); if (debug_string_options.elide_oneof_body) { contents->append(" ... }\n"); } else { + contents->append("\n"); for (int i = 0; i < field_count(); i++) { field(i)->DebugString(depth, FieldDescriptor::OMIT_LABEL, contents, debug_string_options); @@ -2597,7 +2646,7 @@ void EnumDescriptor::DebugString(int depth, string *contents, strings::SubstituteAndAppend(contents, "$0enum $1 {\n", prefix, name()); - FormatLineOptions(depth, options(), contents); + FormatLineOptions(depth, options(), file()->pool(), contents); for (int i = 0; i < value_count(); i++) { value(i)->DebugString(depth, contents, debug_string_options); @@ -2632,7 +2681,8 @@ void EnumValueDescriptor::DebugString(int depth, string *contents, prefix, name(), number()); string formatted_options; - if (FormatBracketedOptions(depth, options(), &formatted_options)) { + if (FormatBracketedOptions(depth, options(), type()->file()->pool(), + &formatted_options)) { strings::SubstituteAndAppend(contents, " [$0]", formatted_options); } contents->append(";\n"); @@ -2661,7 +2711,7 @@ void ServiceDescriptor::DebugString(string *contents, strings::SubstituteAndAppend(contents, "service $0 {\n", name()); - FormatLineOptions(1, options(), contents); + FormatLineOptions(1, options(), file()->pool(), contents); for (int i = 0; i < method_count(); i++) { method(i)->DebugString(1, contents, debug_string_options); @@ -2702,7 +2752,8 @@ void MethodDescriptor::DebugString(int depth, string *contents, server_streaming() ? "stream " : ""); string formatted_options; - if (FormatLineOptions(depth, options(), &formatted_options)) { + if (FormatLineOptions(depth, options(), service()->file()->pool(), + &formatted_options)) { strings::SubstituteAndAppend(contents, " {\n$0$1}\n", formatted_options, prefix); } else { @@ -2715,7 +2766,7 @@ void MethodDescriptor::DebugString(int depth, string *contents, // Location methods =============================================== -bool FileDescriptor::GetSourceLocation(const vector<int>& path, +bool FileDescriptor::GetSourceLocation(const std::vector<int>& path, SourceLocation* out_location) const { GOOGLE_CHECK_NOTNULL(out_location); if (source_code_info_) { @@ -2741,7 +2792,7 @@ bool FileDescriptor::GetSourceLocation(const vector<int>& path, } bool FileDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; // empty path for root FileDescriptor + std::vector<int> path; // empty path for root FileDescriptor return GetSourceLocation(path, out_location); } @@ -2755,49 +2806,49 @@ bool FieldDescriptor::is_packed() const { } bool Descriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return file()->GetSourceLocation(path, out_location); } bool FieldDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return file()->GetSourceLocation(path, out_location); } bool OneofDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return containing_type()->file()->GetSourceLocation(path, out_location); } bool EnumDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return file()->GetSourceLocation(path, out_location); } bool MethodDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return service()->file()->GetSourceLocation(path, out_location); } bool ServiceDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return file()->GetSourceLocation(path, out_location); } bool EnumValueDescriptor::GetSourceLocation( SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return type()->file()->GetSourceLocation(path, out_location); } -void Descriptor::GetLocationPath(vector<int>* output) const { +void Descriptor::GetLocationPath(std::vector<int>* output) const { if (containing_type()) { containing_type()->GetLocationPath(output); output->push_back(DescriptorProto::kNestedTypeFieldNumber); @@ -2808,7 +2859,7 @@ void Descriptor::GetLocationPath(vector<int>* output) const { } } -void FieldDescriptor::GetLocationPath(vector<int>* output) const { +void FieldDescriptor::GetLocationPath(std::vector<int>* output) const { if (is_extension()) { if (extension_scope() == NULL) { output->push_back(FileDescriptorProto::kExtensionFieldNumber); @@ -2825,13 +2876,13 @@ void FieldDescriptor::GetLocationPath(vector<int>* output) const { } } -void OneofDescriptor::GetLocationPath(vector<int>* output) const { +void OneofDescriptor::GetLocationPath(std::vector<int>* output) const { containing_type()->GetLocationPath(output); output->push_back(DescriptorProto::kOneofDeclFieldNumber); output->push_back(index()); } -void EnumDescriptor::GetLocationPath(vector<int>* output) const { +void EnumDescriptor::GetLocationPath(std::vector<int>* output) const { if (containing_type()) { containing_type()->GetLocationPath(output); output->push_back(DescriptorProto::kEnumTypeFieldNumber); @@ -2842,18 +2893,18 @@ void EnumDescriptor::GetLocationPath(vector<int>* output) const { } } -void EnumValueDescriptor::GetLocationPath(vector<int>* output) const { +void EnumValueDescriptor::GetLocationPath(std::vector<int>* output) const { type()->GetLocationPath(output); output->push_back(EnumDescriptorProto::kValueFieldNumber); output->push_back(index()); } -void ServiceDescriptor::GetLocationPath(vector<int>* output) const { +void ServiceDescriptor::GetLocationPath(std::vector<int>* output) const { output->push_back(FileDescriptorProto::kServiceFieldNumber); output->push_back(index()); } -void MethodDescriptor::GetLocationPath(vector<int>* output) const { +void MethodDescriptor::GetLocationPath(std::vector<int>* output) const { service()->GetLocationPath(output); output->push_back(ServiceDescriptorProto::kMethodFieldNumber); output->push_back(index()); @@ -2908,17 +2959,17 @@ class DescriptorBuilder { // As we build descriptors we store copies of the options messages in // them. We put pointers to those copies in this vector, as we build, so we // can later (after cross-linking) interpret those options. - vector<OptionsToInterpret> options_to_interpret_; + std::vector<OptionsToInterpret> options_to_interpret_; bool had_errors_; string filename_; FileDescriptor* file_; FileDescriptorTables* file_tables_; - set<const FileDescriptor*> dependencies_; + std::set<const FileDescriptor*> dependencies_; // unused_dependency_ is used to record the unused imported files. // Note: public import is not considered. - set<const FileDescriptor*> unused_dependency_; + std::set<const FileDescriptor*> unused_dependency_; // If LookupSymbol() finds a symbol that is in a file which is not a declared // dependency of this file, it will fail, but will set @@ -3171,8 +3222,10 @@ class DescriptorBuilder { // in unknown_fields to check if field innermost_field is set on the // innermost message. Returns false and sets an error if so. bool ExamineIfOptionIsSet( - vector<const FieldDescriptor*>::const_iterator intermediate_fields_iter, - vector<const FieldDescriptor*>::const_iterator intermediate_fields_end, + std::vector<const FieldDescriptor*>::const_iterator + intermediate_fields_iter, + std::vector<const FieldDescriptor*>::const_iterator + intermediate_fields_end, const FieldDescriptor* innermost_field, const string& debug_msg_name, const UnknownFieldSet& unknown_fields); @@ -3498,7 +3551,8 @@ Symbol DescriptorBuilder::FindSymbol(const string& name) { // dependency also defines the same package. We can't really rule out this // symbol unless none of the dependencies define it. if (IsInPackage(file_, name)) return result; - for (set<const FileDescriptor*>::const_iterator it = dependencies_.begin(); + for (std::set<const FileDescriptor*>::const_iterator it = + dependencies_.begin(); it != dependencies_.end(); ++it) { // Note: A dependency may be NULL if it was not found or had errors. if (*it != NULL && IsInPackage(*it, name)) return result; @@ -3717,9 +3771,13 @@ bool DescriptorBuilder::AddSymbol( if (tables_->AddSymbol(full_name, symbol)) { if (!file_tables_->AddAliasUnderParent(parent, name, symbol)) { - GOOGLE_LOG(DFATAL) << "\"" << full_name << "\" not previously defined in " - "symbols_by_name_, but was defined in symbols_by_parent_; " - "this shouldn't be possible."; + // This is only possible if there was already an error adding something of + // the same name. + if (!had_errors_) { + GOOGLE_LOG(DFATAL) << "\"" << full_name << "\" not previously defined in " + "symbols_by_name_, but was defined in " + "symbols_by_parent_; this shouldn't be possible."; + } return false; } return true; @@ -4037,12 +4095,12 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl( } // Make sure all dependencies are loaded. - set<string> seen_dependencies; + std::set<string> seen_dependencies; result->dependency_count_ = proto.dependency_size(); result->dependencies_ = tables_->AllocateArray<const FileDescriptor*>(proto.dependency_size()); unused_dependency_.clear(); - set<int> weak_deps; + std::set<int> weak_deps; for (int i = 0; i < proto.weak_dependency_size(); ++i) { weak_deps.insert(proto.weak_dependency(i)); } @@ -4141,7 +4199,7 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl( // extension options known, so all interpretations should now succeed. if (!had_errors_) { OptionInterpreter option_interpreter(this); - for (vector<OptionsToInterpret>::iterator iter = + for (std::vector<OptionsToInterpret>::iterator iter = options_to_interpret_.begin(); iter != options_to_interpret_.end(); ++iter) { option_interpreter.InterpretOptions(&(*iter)); @@ -4289,7 +4347,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, for (int j = 0; j < result->reserved_range_count(); j++) { const Descriptor::ReservedRange* range2 = result->reserved_range(j); if (range1->end > range2->start && range2->end > range1->start) { - AddError(result->full_name(), proto.extension_range(j), + AddError(result->full_name(), proto.extension_range(i), DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Extension range $0 to $1 overlaps with " "reserved range $2 to $3.", @@ -4300,7 +4358,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, for (int j = i + 1; j < result->extension_range_count(); j++) { const Descriptor::ExtensionRange* range2 = result->extension_range(j); if (range1->end > range2->start && range2->end > range1->start) { - AddError(result->full_name(), proto.extension_range(j), + AddError(result->full_name(), proto.extension_range(i), DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Extension range $0 to $1 overlaps with " "already-defined range $2 to $3.", @@ -4411,11 +4469,14 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, break; case FieldDescriptor::CPPTYPE_FLOAT: if (proto.default_value() == "inf") { - result->default_value_float_ = numeric_limits<float>::infinity(); + result->default_value_float_ = + std::numeric_limits<float>::infinity(); } else if (proto.default_value() == "-inf") { - result->default_value_float_ = -numeric_limits<float>::infinity(); + result->default_value_float_ = + -std::numeric_limits<float>::infinity(); } else if (proto.default_value() == "nan") { - result->default_value_float_ = numeric_limits<float>::quiet_NaN(); + result->default_value_float_ = + std::numeric_limits<float>::quiet_NaN(); } else { result->default_value_float_ = io::SafeDoubleToFloat( io::NoLocaleStrtod(proto.default_value().c_str(), &end_pos)); @@ -4423,11 +4484,14 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, break; case FieldDescriptor::CPPTYPE_DOUBLE: if (proto.default_value() == "inf") { - result->default_value_double_ = numeric_limits<double>::infinity(); + result->default_value_double_ = + std::numeric_limits<double>::infinity(); } else if (proto.default_value() == "-inf") { - result->default_value_double_ = -numeric_limits<double>::infinity(); + result->default_value_double_ = + -std::numeric_limits<double>::infinity(); } else if (proto.default_value() == "nan") { - result->default_value_double_ = numeric_limits<double>::quiet_NaN(); + result->default_value_double_ = + std::numeric_limits<double>::quiet_NaN(); } else { result->default_value_double_ = io::NoLocaleStrtod(proto.default_value().c_str(), &end_pos); @@ -4690,12 +4754,13 @@ void DescriptorBuilder::CheckEnumValueUniqueness( // NAME_TYPE_LAST_NAME = 2, // } PrefixRemover remover(result->name()); - map<string, const google::protobuf::EnumValueDescriptor*> values; + std::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> + std::pair<std::map<string, const google::protobuf::EnumValueDescriptor*>::iterator, + bool> insert_result = values.insert(std::make_pair(stripped, value)); bool inserted = insert_result.second; @@ -5170,13 +5235,16 @@ void DescriptorBuilder::CrossLinkField( const FieldDescriptor* conflicting_field = file_tables_->FindFieldByNumber(field->containing_type(), field->number()); + string containing_type_name = field->containing_type() == NULL + ? "unknown" + : field->containing_type()->full_name(); if (field->is_extension()) { AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Extension number $0 has already been used " "in \"$1\" by extension \"$2\".", field->number(), - field->containing_type()->full_name(), + containing_type_name, conflicting_field->full_name())); } else { AddError(field->full_name(), proto, @@ -5184,7 +5252,7 @@ void DescriptorBuilder::CrossLinkField( strings::Substitute("Field number $0 has already been used in " "\"$1\" by field \"$2\".", field->number(), - field->containing_type()->full_name(), + containing_type_name, conflicting_field->name())); } } else { @@ -5378,7 +5446,7 @@ void DescriptorBuilder::ValidateProto3Message( // In proto3, we reject field names if they conflict in camelCase. // Note that we currently enforce a stricter rule: Field names must be // unique after being converted to lowercase with underscores removed. - map<string, const FieldDescriptor*> name_to_field; + std::map<string, const FieldDescriptor*> name_to_field; for (int i = 0; i < message->field_count(); ++i) { string lowercase_name = ToLowercaseWithoutUnderscores( message->field(i)->name()); @@ -5529,7 +5597,7 @@ void DescriptorBuilder::ValidateEnumOptions(EnumDescriptor* enm, const EnumDescriptorProto& proto) { VALIDATE_OPTIONS_FROM_ARRAY(enm, value, EnumValue); if (!enm->options().has_allow_alias() || !enm->options().allow_alias()) { - map<int, string> used_values; + std::map<int, string> used_values; for (int i = 0; i < enm->value_count(); ++i) { const EnumValueDescriptor* enum_value = enm->value(i); if (used_values.find(enum_value->number()) != used_values.end()) { @@ -5656,10 +5724,10 @@ bool DescriptorBuilder::ValidateMapEntry(FieldDescriptor* field, void DescriptorBuilder::DetectMapConflicts(const Descriptor* message, const DescriptorProto& proto) { - map<string, const Descriptor*> seen_types; + std::map<string, const Descriptor*> seen_types; for (int i = 0; i < message->nested_type_count(); ++i) { const Descriptor* nested = message->nested_type(i); - pair<map<string, const Descriptor*>::iterator, bool> result = + std::pair<std::map<string, const Descriptor*>::iterator, bool> result = seen_types.insert(std::make_pair(nested->name(), nested)); if (!result.second) { if (result.first->second->options().map_entry() || @@ -5676,7 +5744,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message, // Check for conflicted field names. for (int i = 0; i < message->field_count(); ++i) { const FieldDescriptor* field = message->field(i); - map<string, const Descriptor*>::iterator iter = + std::map<string, const Descriptor*>::iterator iter = seen_types.find(field->name()); if (iter != seen_types.end() && iter->second->options().map_entry()) { AddError(message->full_name(), proto, @@ -5688,7 +5756,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message, // Check for conflicted enum names. for (int i = 0; i < message->enum_type_count(); ++i) { const EnumDescriptor* enum_desc = message->enum_type(i); - map<string, const Descriptor*>::iterator iter = + std::map<string, const Descriptor*>::iterator iter = seen_types.find(enum_desc->name()); if (iter != seen_types.end() && iter->second->options().map_entry()) { AddError(message->full_name(), proto, @@ -5700,7 +5768,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message, // Check for conflicted oneof names. for (int i = 0; i < message->oneof_decl_count(); ++i) { const OneofDescriptor* oneof_desc = message->oneof_decl(i); - map<string, const Descriptor*>::iterator iter = + std::map<string, const Descriptor*>::iterator iter = seen_types.find(oneof_desc->name()); if (iter != seen_types.end() && iter->second->options().map_entry()) { AddError(message->full_name(), proto, @@ -5835,7 +5903,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption( // name in |debug_msg_name|, for use in error messages. const Descriptor* descriptor = options_descriptor; const FieldDescriptor* field = NULL; - vector<const FieldDescriptor*> intermediate_fields; + std::vector<const FieldDescriptor*> intermediate_fields; string debug_msg_name = ""; for (int i = 0; i < uninterpreted_option_->name_size(); ++i) { @@ -5943,7 +6011,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption( // Now wrap the UnknownFieldSet with UnknownFieldSets corresponding to all // the intermediate messages. - for (vector<const FieldDescriptor*>::reverse_iterator iter = + for (std::vector<const FieldDescriptor*>::reverse_iterator iter = intermediate_fields.rbegin(); iter != intermediate_fields.rend(); ++iter) { google::protobuf::scoped_ptr<UnknownFieldSet> parent_unknown_fields( @@ -5993,8 +6061,9 @@ void DescriptorBuilder::OptionInterpreter::AddWithoutInterpreting( } bool DescriptorBuilder::OptionInterpreter::ExamineIfOptionIsSet( - vector<const FieldDescriptor*>::const_iterator intermediate_fields_iter, - vector<const FieldDescriptor*>::const_iterator intermediate_fields_end, + std::vector<const FieldDescriptor*>::const_iterator + intermediate_fields_iter, + std::vector<const FieldDescriptor*>::const_iterator intermediate_fields_end, const FieldDescriptor* innermost_field, const string& debug_msg_name, const UnknownFieldSet& unknown_fields) { // We do linear searches of the UnknownFieldSet and its sub-groups. This @@ -6454,7 +6523,7 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto, annotation_extensions.insert("google.protobuf.ServiceOptions"); annotation_extensions.insert("google.protobuf.MethodOptions"); annotation_extensions.insert("google.protobuf.StreamOptions"); - for (set<const FileDescriptor*>::const_iterator + for (std::set<const FileDescriptor*>::const_iterator it = unused_dependency_.begin(); it != unused_dependency_.end(); ++it) { // Do not log warnings for proto files which extend annotations. diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index 0151e1d9..cc099693 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -62,6 +62,7 @@ #include <string> #include <vector> #include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/mutex.h> // TYPE_BOOL is defined in the MacOS's ConditionalMacros.h. #ifdef TYPE_BOOL diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 1e21e230..846c2875 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -19,116 +19,78 @@ namespace google { namespace protobuf { +class FileDescriptorSetDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> {}; +FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; +class FileDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> {}; +FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; +class DescriptorProto_ExtensionRangeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> {}; +DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; +class DescriptorProto_ReservedRangeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> {}; +DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; +class DescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> {}; +DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; +class FieldDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> {}; +FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; +class OneofDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> {}; +OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; +class EnumDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> {}; +EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; +class EnumValueDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> {}; +EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; +class ServiceDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> {}; +ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; +class MethodDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> {}; +MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; +class FileOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileOptions> {}; +FileOptionsDefaultTypeInternal _FileOptions_default_instance_; +class MessageOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> {}; +MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; +class FieldOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> {}; +FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; +class OneofOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> {}; +OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; +class EnumOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> {}; +EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; +class EnumValueOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> {}; +EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; +class ServiceOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> {}; +ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; +class MethodOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> {}; +MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; +class UninterpretedOption_NamePartDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> {}; +UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; +class UninterpretedOptionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> {}; +UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; +class SourceCodeInfo_LocationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> {}; +SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; +class SourceCodeInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> {}; +SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; +class GeneratedCodeInfo_AnnotationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> {}; +GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; +class GeneratedCodeInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> {}; +GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; namespace { -const ::google::protobuf::Descriptor* FileDescriptorSet_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FileDescriptorSet_reflection_ = NULL; -const ::google::protobuf::Descriptor* FileDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FileDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* DescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - DescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - DescriptorProto_ExtensionRange_reflection_ = NULL; -const ::google::protobuf::Descriptor* DescriptorProto_ReservedRange_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - DescriptorProto_ReservedRange_reflection_ = NULL; -const ::google::protobuf::Descriptor* FieldDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FieldDescriptorProto_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor_ = NULL; -const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor_ = NULL; -const ::google::protobuf::Descriptor* OneofDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - OneofDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* EnumDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* EnumValueDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumValueDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* ServiceDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - ServiceDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* MethodDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - MethodDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* FileOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FileOptions_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor_ = NULL; -const ::google::protobuf::Descriptor* MessageOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - MessageOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* FieldOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FieldOptions_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor_ = NULL; -const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor_ = NULL; -const ::google::protobuf::Descriptor* OneofOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - OneofOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* EnumOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* EnumValueOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumValueOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* ServiceOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - ServiceOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* MethodOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - MethodOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* UninterpretedOption_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - UninterpretedOption_reflection_ = NULL; -const ::google::protobuf::Descriptor* UninterpretedOption_NamePart_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - UninterpretedOption_NamePart_reflection_ = NULL; -const ::google::protobuf::Descriptor* SourceCodeInfo_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - SourceCodeInfo_reflection_ = NULL; -const ::google::protobuf::Descriptor* SourceCodeInfo_Location_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - SourceCodeInfo_Location_reflection_ = NULL; -const ::google::protobuf::Descriptor* GeneratedCodeInfo_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - GeneratedCodeInfo_reflection_ = NULL; -const ::google::protobuf::Descriptor* GeneratedCodeInfo_Annotation_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - GeneratedCodeInfo_Annotation_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[25]; +const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[6]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/descriptor.proto"); - GOOGLE_CHECK(file != NULL); - FileDescriptorSet_descriptor_ = file->message_type(0); - static const int FileDescriptorSet_offsets_[1] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, file_), - }; - FileDescriptorSet_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FileDescriptorSet_descriptor_, - FileDescriptorSet::internal_default_instance(), - FileDescriptorSet_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_), - -1, - -1, - sizeof(FileDescriptorSet), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _internal_metadata_)); - FileDescriptorProto_descriptor_ = file->message_type(1); - static const int FileDescriptorProto_offsets_[12] = { + 0, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, package_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, dependency_), @@ -141,19 +103,38 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, source_code_info_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, syntax_), - }; - FileDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FileDescriptorProto_descriptor_, - FileDescriptorProto::internal_default_instance(), - FileDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_), - -1, - -1, - sizeof(FileDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _internal_metadata_)); - DescriptorProto_descriptor_ = file->message_type(2); - static const int DescriptorProto_offsets_[10] = { + 0, + 1, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 3, + 4, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, start_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, end_), + 0, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, start_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, end_), + 0, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, field_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_), @@ -164,49 +145,20 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_range_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_name_), - }; - DescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - DescriptorProto_descriptor_, - DescriptorProto::internal_default_instance(), - DescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_), - -1, - -1, - sizeof(DescriptorProto), - 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_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, end_), - }; - DescriptorProto_ExtensionRange_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - DescriptorProto_ExtensionRange_descriptor_, - DescriptorProto_ExtensionRange::internal_default_instance(), - DescriptorProto_ExtensionRange_offsets_, - 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_)); - DescriptorProto_ReservedRange_descriptor_ = DescriptorProto_descriptor_->nested_type(1); - static const int DescriptorProto_ReservedRange_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, start_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, end_), - }; - DescriptorProto_ReservedRange_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - DescriptorProto_ReservedRange_descriptor_, - DescriptorProto_ReservedRange::internal_default_instance(), - DescriptorProto_ReservedRange_offsets_, - 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_)); - FieldDescriptorProto_descriptor_ = file->message_type(3); - static const int FieldDescriptorProto_offsets_[10] = { + 0, + 2, + 3, + 4, + 5, + 6, + 7, + 1, + 8, + 9, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, number_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, label_), @@ -217,103 +169,74 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, oneof_index_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, json_name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, options_), - }; - FieldDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FieldDescriptorProto_descriptor_, - FieldDescriptorProto::internal_default_instance(), - FieldDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_), - -1, - -1, - sizeof(FieldDescriptorProto), - 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); - static const int OneofDescriptorProto_offsets_[2] = { + 0, + 6, + 8, + 9, + 1, + 2, + 3, + 7, + 4, + 5, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, options_), - }; - OneofDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - OneofDescriptorProto_descriptor_, - OneofDescriptorProto::internal_default_instance(), - OneofDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _has_bits_), - -1, - -1, - sizeof(OneofDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _internal_metadata_)); - EnumDescriptorProto_descriptor_ = file->message_type(5); - static const int EnumDescriptorProto_offsets_[3] = { + 0, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, value_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, options_), - }; - EnumDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - EnumDescriptorProto_descriptor_, - EnumDescriptorProto::internal_default_instance(), - EnumDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_), - -1, - -1, - sizeof(EnumDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _internal_metadata_)); - EnumValueDescriptorProto_descriptor_ = file->message_type(6); - static const int EnumValueDescriptorProto_offsets_[3] = { + 0, + 2, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, number_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, options_), - }; - EnumValueDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - EnumValueDescriptorProto_descriptor_, - EnumValueDescriptorProto::internal_default_instance(), - EnumValueDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_), - -1, - -1, - sizeof(EnumValueDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _internal_metadata_)); - ServiceDescriptorProto_descriptor_ = file->message_type(7); - static const int ServiceDescriptorProto_offsets_[3] = { + 0, + 2, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, method_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, options_), - }; - ServiceDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - ServiceDescriptorProto_descriptor_, - ServiceDescriptorProto::internal_default_instance(), - ServiceDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_), - -1, - -1, - sizeof(ServiceDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _internal_metadata_)); - MethodDescriptorProto_descriptor_ = file->message_type(8); - static const int MethodDescriptorProto_offsets_[6] = { + 0, + 2, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, input_type_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, output_type_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, client_streaming_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, server_streaming_), - }; - MethodDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - MethodDescriptorProto_descriptor_, - MethodDescriptorProto::internal_default_instance(), - MethodDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_), - -1, - -1, - sizeof(MethodDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_)); - FileOptions_descriptor_ = file->message_type(9); - static const int FileOptions_offsets_[15] = { + 0, + 1, + 2, + 3, + 4, + 5, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _extensions_), + ~0u, // no _oneof_case_ 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_), @@ -329,38 +252,39 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, objc_class_prefix_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_namespace_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_), - }; - FileOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FileOptions_descriptor_, - FileOptions::internal_default_instance(), - FileOptions_offsets_, - 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_)); - FileOptions_OptimizeMode_descriptor_ = FileOptions_descriptor_->enum_type(0); - MessageOptions_descriptor_ = file->message_type(10); - static const int MessageOptions_offsets_[5] = { + 0, + 1, + 5, + 6, + 7, + 13, + 2, + 8, + 9, + 10, + 11, + 12, + 3, + 4, + 14, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, message_set_wire_format_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, no_standard_descriptor_accessor_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, map_entry_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, uninterpreted_option_), - }; - MessageOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - MessageOptions_descriptor_, - MessageOptions::internal_default_instance(), - MessageOptions_offsets_, - 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_)); - FieldOptions_descriptor_ = file->message_type(11); - static const int FieldOptions_offsets_[7] = { + 0, + 1, + 2, + 3, + 4, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, ctype_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, packed_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, jstype_), @@ -368,96 +292,67 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, weak_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, uninterpreted_option_), - }; - FieldOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FieldOptions_descriptor_, - FieldOptions::internal_default_instance(), - FieldOptions_offsets_, - 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_)); - FieldOptions_CType_descriptor_ = FieldOptions_descriptor_->enum_type(0); - FieldOptions_JSType_descriptor_ = FieldOptions_descriptor_->enum_type(1); - OneofOptions_descriptor_ = file->message_type(12); - static const int OneofOptions_offsets_[1] = { + 0, + 2, + 1, + 3, + 4, + 5, + 6, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, uninterpreted_option_), - }; - OneofOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - OneofOptions_descriptor_, - OneofOptions::internal_default_instance(), - OneofOptions_offsets_, - 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_)); - EnumOptions_descriptor_ = file->message_type(13); - static const int EnumOptions_offsets_[3] = { + 0, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, allow_alias_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, uninterpreted_option_), - }; - EnumOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - EnumOptions_descriptor_, - EnumOptions::internal_default_instance(), - EnumOptions_offsets_, - 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_)); - EnumValueOptions_descriptor_ = file->message_type(14); - static const int EnumValueOptions_offsets_[2] = { + 0, + 1, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, uninterpreted_option_), - }; - EnumValueOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - EnumValueOptions_descriptor_, - EnumValueOptions::internal_default_instance(), - EnumValueOptions_offsets_, - 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_)); - ServiceOptions_descriptor_ = file->message_type(15); - static const int ServiceOptions_offsets_[2] = { + 0, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, uninterpreted_option_), - }; - ServiceOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - ServiceOptions_descriptor_, - ServiceOptions::internal_default_instance(), - ServiceOptions_offsets_, - 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_)); - MethodOptions_descriptor_ = file->message_type(16); - static const int MethodOptions_offsets_[2] = { + 0, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, deprecated_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, idempotency_level_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, uninterpreted_option_), - }; - MethodOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - MethodOptions_descriptor_, - MethodOptions::internal_default_instance(), - MethodOptions_offsets_, - 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_)); - UninterpretedOption_descriptor_ = file->message_type(17); - static const int UninterpretedOption_offsets_[7] = { + 0, + 1, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, name_part_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, is_extension_), + 0, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, identifier_value_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, positive_int_value_), @@ -465,426 +360,383 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, double_value_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, string_value_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, aggregate_value_), - }; - UninterpretedOption_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - UninterpretedOption_descriptor_, - UninterpretedOption::internal_default_instance(), - UninterpretedOption_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_), - -1, - -1, - sizeof(UninterpretedOption), - 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_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, is_extension_), - }; - UninterpretedOption_NamePart_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - UninterpretedOption_NamePart_descriptor_, - UninterpretedOption_NamePart::internal_default_instance(), - UninterpretedOption_NamePart_offsets_, - 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_)); - SourceCodeInfo_descriptor_ = file->message_type(18); - static const int SourceCodeInfo_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, location_), - }; - SourceCodeInfo_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - SourceCodeInfo_descriptor_, - SourceCodeInfo::internal_default_instance(), - SourceCodeInfo_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_), - -1, - -1, - sizeof(SourceCodeInfo), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _internal_metadata_)); - SourceCodeInfo_Location_descriptor_ = SourceCodeInfo_descriptor_->nested_type(0); - static const int SourceCodeInfo_Location_offsets_[5] = { + 6, + 0, + 3, + 4, + 5, + 1, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, path_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, span_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_comments_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, trailing_comments_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_detached_comments_), - }; - SourceCodeInfo_Location_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - SourceCodeInfo_Location_descriptor_, - SourceCodeInfo_Location::internal_default_instance(), - SourceCodeInfo_Location_offsets_, - 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_)); - GeneratedCodeInfo_descriptor_ = file->message_type(19); - static const int GeneratedCodeInfo_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, annotation_), - }; - GeneratedCodeInfo_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - GeneratedCodeInfo_descriptor_, - GeneratedCodeInfo::internal_default_instance(), - GeneratedCodeInfo_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _has_bits_), - -1, - -1, - sizeof(GeneratedCodeInfo), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _internal_metadata_)); - GeneratedCodeInfo_Annotation_descriptor_ = GeneratedCodeInfo_descriptor_->nested_type(0); - static const int GeneratedCodeInfo_Annotation_offsets_[4] = { + 2, + 3, + 0, + 1, + 4, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, location_), + 0, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, path_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, source_file_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, begin_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, end_), + 3, + 0, + 1, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, annotation_), + 0, }; - GeneratedCodeInfo_Annotation_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - GeneratedCodeInfo_Annotation_descriptor_, - GeneratedCodeInfo_Annotation::internal_default_instance(), - GeneratedCodeInfo_Annotation_offsets_, - 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_)); -} + return offsets; +} + +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, 5, sizeof(FileDescriptorSet)}, + { 6, 22, sizeof(FileDescriptorProto)}, + { 34, 40, sizeof(DescriptorProto_ExtensionRange)}, + { 42, 48, sizeof(DescriptorProto_ReservedRange)}, + { 50, 64, sizeof(DescriptorProto)}, + { 74, 88, sizeof(FieldDescriptorProto)}, + { 98, 104, sizeof(OneofDescriptorProto)}, + { 106, 113, sizeof(EnumDescriptorProto)}, + { 116, 123, sizeof(EnumValueDescriptorProto)}, + { 126, 133, sizeof(ServiceDescriptorProto)}, + { 136, 146, sizeof(MethodDescriptorProto)}, + { 152, 171, sizeof(FileOptions)}, + { 186, 195, sizeof(MessageOptions)}, + { 200, 211, sizeof(FieldOptions)}, + { 218, 223, sizeof(OneofOptions)}, + { 224, 231, sizeof(EnumOptions)}, + { 234, 240, sizeof(EnumValueOptions)}, + { 242, 248, sizeof(ServiceOptions)}, + { 250, 257, sizeof(MethodOptions)}, + { 260, 266, sizeof(UninterpretedOption_NamePart)}, + { 268, 279, sizeof(UninterpretedOption)}, + { 286, 295, sizeof(SourceCodeInfo_Location)}, + { 300, 305, sizeof(SourceCodeInfo)}, + { 306, 314, sizeof(GeneratedCodeInfo_Annotation)}, + { 318, 323, sizeof(GeneratedCodeInfo)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_FileDescriptorSet_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_FileDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_ExtensionRange_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_ReservedRange_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_FieldDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_OneofDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_EnumDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValueDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_ServiceDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_MethodDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_FileOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_MessageOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_FieldOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_OneofOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_EnumOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValueOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_ServiceOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_MethodOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_UninterpretedOption_NamePart_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_UninterpretedOption_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_SourceCodeInfo_Location_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_SourceCodeInfo_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_GeneratedCodeInfo_Annotation_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_GeneratedCodeInfo_default_instance_), NULL}, +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/descriptor.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(), factory, + file_level_metadata, file_level_enum_descriptors, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileDescriptorSet_descriptor_, FileDescriptorSet::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileDescriptorProto_descriptor_, FileDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_descriptor_, DescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_ExtensionRange_descriptor_, DescriptorProto_ExtensionRange::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_ReservedRange_descriptor_, DescriptorProto_ReservedRange::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldDescriptorProto_descriptor_, FieldDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - OneofDescriptorProto_descriptor_, OneofDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumDescriptorProto_descriptor_, EnumDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValueDescriptorProto_descriptor_, EnumValueDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ServiceDescriptorProto_descriptor_, ServiceDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MethodDescriptorProto_descriptor_, MethodDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileOptions_descriptor_, FileOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MessageOptions_descriptor_, MessageOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldOptions_descriptor_, FieldOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - OneofOptions_descriptor_, OneofOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumOptions_descriptor_, EnumOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValueOptions_descriptor_, EnumValueOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ServiceOptions_descriptor_, ServiceOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MethodOptions_descriptor_, MethodOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UninterpretedOption_descriptor_, UninterpretedOption::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UninterpretedOption_NamePart_descriptor_, UninterpretedOption_NamePart::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceCodeInfo_descriptor_, SourceCodeInfo::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceCodeInfo_Location_descriptor_, SourceCodeInfo_Location::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - GeneratedCodeInfo_descriptor_, GeneratedCodeInfo::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - GeneratedCodeInfo_Annotation_descriptor_, GeneratedCodeInfo_Annotation::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 25); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto() { - FileDescriptorSet_default_instance_.Shutdown(); - delete FileDescriptorSet_reflection_; - FileDescriptorProto_default_instance_.Shutdown(); - delete FileDescriptorProto_reflection_; - DescriptorProto_default_instance_.Shutdown(); - delete DescriptorProto_reflection_; - DescriptorProto_ExtensionRange_default_instance_.Shutdown(); - delete DescriptorProto_ExtensionRange_reflection_; - DescriptorProto_ReservedRange_default_instance_.Shutdown(); - delete DescriptorProto_ReservedRange_reflection_; - FieldDescriptorProto_default_instance_.Shutdown(); - delete FieldDescriptorProto_reflection_; - OneofDescriptorProto_default_instance_.Shutdown(); - delete OneofDescriptorProto_reflection_; - EnumDescriptorProto_default_instance_.Shutdown(); - delete EnumDescriptorProto_reflection_; - EnumValueDescriptorProto_default_instance_.Shutdown(); - delete EnumValueDescriptorProto_reflection_; - ServiceDescriptorProto_default_instance_.Shutdown(); - delete ServiceDescriptorProto_reflection_; - MethodDescriptorProto_default_instance_.Shutdown(); - delete MethodDescriptorProto_reflection_; - FileOptions_default_instance_.Shutdown(); - delete FileOptions_reflection_; - MessageOptions_default_instance_.Shutdown(); - delete MessageOptions_reflection_; - FieldOptions_default_instance_.Shutdown(); - delete FieldOptions_reflection_; - OneofOptions_default_instance_.Shutdown(); - delete OneofOptions_reflection_; - EnumOptions_default_instance_.Shutdown(); - delete EnumOptions_reflection_; - EnumValueOptions_default_instance_.Shutdown(); - delete EnumValueOptions_reflection_; - ServiceOptions_default_instance_.Shutdown(); - delete ServiceOptions_reflection_; - MethodOptions_default_instance_.Shutdown(); - delete MethodOptions_reflection_; - UninterpretedOption_default_instance_.Shutdown(); - delete UninterpretedOption_reflection_; - UninterpretedOption_NamePart_default_instance_.Shutdown(); - delete UninterpretedOption_NamePart_reflection_; - SourceCodeInfo_default_instance_.Shutdown(); - delete SourceCodeInfo_reflection_; - SourceCodeInfo_Location_default_instance_.Shutdown(); - delete SourceCodeInfo_Location_reflection_; - GeneratedCodeInfo_default_instance_.Shutdown(); - delete GeneratedCodeInfo_reflection_; - GeneratedCodeInfo_Annotation_default_instance_.Shutdown(); - delete GeneratedCodeInfo_Annotation_reflection_; + _FileDescriptorSet_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; + _FileDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; + _DescriptorProto_ExtensionRange_default_instance_.Shutdown(); + delete file_level_metadata[2].reflection; + _DescriptorProto_ReservedRange_default_instance_.Shutdown(); + delete file_level_metadata[3].reflection; + _DescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[4].reflection; + _FieldDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[5].reflection; + _OneofDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[6].reflection; + _EnumDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[7].reflection; + _EnumValueDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[8].reflection; + _ServiceDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[9].reflection; + _MethodDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[10].reflection; + _FileOptions_default_instance_.Shutdown(); + delete file_level_metadata[11].reflection; + _MessageOptions_default_instance_.Shutdown(); + delete file_level_metadata[12].reflection; + _FieldOptions_default_instance_.Shutdown(); + delete file_level_metadata[13].reflection; + _OneofOptions_default_instance_.Shutdown(); + delete file_level_metadata[14].reflection; + _EnumOptions_default_instance_.Shutdown(); + delete file_level_metadata[15].reflection; + _EnumValueOptions_default_instance_.Shutdown(); + delete file_level_metadata[16].reflection; + _ServiceOptions_default_instance_.Shutdown(); + delete file_level_metadata[17].reflection; + _MethodOptions_default_instance_.Shutdown(); + delete file_level_metadata[18].reflection; + _UninterpretedOption_NamePart_default_instance_.Shutdown(); + delete file_level_metadata[19].reflection; + _UninterpretedOption_default_instance_.Shutdown(); + delete file_level_metadata[20].reflection; + _SourceCodeInfo_Location_default_instance_.Shutdown(); + delete file_level_metadata[21].reflection; + _SourceCodeInfo_default_instance_.Shutdown(); + delete file_level_metadata[22].reflection; + _GeneratedCodeInfo_Annotation_default_instance_.Shutdown(); + delete file_level_metadata[23].reflection; + _GeneratedCodeInfo_default_instance_.Shutdown(); + delete file_level_metadata[24].reflection; } 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_); + ::google::protobuf::internal::InitProtobufDefaults(); + _FileDescriptorSet_default_instance_.DefaultConstruct(); + _FileDescriptorProto_default_instance_.DefaultConstruct(); + _DescriptorProto_ExtensionRange_default_instance_.DefaultConstruct(); + _DescriptorProto_ReservedRange_default_instance_.DefaultConstruct(); + _DescriptorProto_default_instance_.DefaultConstruct(); + _FieldDescriptorProto_default_instance_.DefaultConstruct(); + _OneofDescriptorProto_default_instance_.DefaultConstruct(); + _EnumDescriptorProto_default_instance_.DefaultConstruct(); + _EnumValueDescriptorProto_default_instance_.DefaultConstruct(); + _ServiceDescriptorProto_default_instance_.DefaultConstruct(); + _MethodDescriptorProto_default_instance_.DefaultConstruct(); + _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(); + _UninterpretedOption_NamePart_default_instance_.DefaultConstruct(); + _UninterpretedOption_default_instance_.DefaultConstruct(); + _SourceCodeInfo_Location_default_instance_.DefaultConstruct(); + _SourceCodeInfo_default_instance_.DefaultConstruct(); + _GeneratedCodeInfo_Annotation_default_instance_.DefaultConstruct(); + _GeneratedCodeInfo_default_instance_.DefaultConstruct(); + _FileDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::FileOptions*>( + ::google::protobuf::FileOptions::internal_default_instance()); + _FileDescriptorProto_default_instance_.get_mutable()->source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>( + ::google::protobuf::SourceCodeInfo::internal_default_instance()); + _DescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::MessageOptions*>( + ::google::protobuf::MessageOptions::internal_default_instance()); + _FieldDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::FieldOptions*>( + ::google::protobuf::FieldOptions::internal_default_instance()); + _OneofDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::OneofOptions*>( + ::google::protobuf::OneofOptions::internal_default_instance()); + _EnumDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::EnumOptions*>( + ::google::protobuf::EnumOptions::internal_default_instance()); + _EnumValueDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::EnumValueOptions*>( + ::google::protobuf::EnumValueOptions::internal_default_instance()); + _ServiceDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::ServiceOptions*>( + ::google::protobuf::ServiceOptions::internal_default_instance()); + _MethodDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::MethodOptions*>( + ::google::protobuf::MethodOptions::internal_default_instance()); +} + void protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&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(); + static const char descriptor[] = { + "\n google/protobuf/descriptor.proto\022\017goog" + "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file" + "\030\001 \003(\0132$.google.protobuf.FileDescriptorP" + "roto\"\333\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001" + "(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022" + "\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen" + "dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog" + "le.protobuf.DescriptorProto\0227\n\tenum_type" + "\030\005 \003(\0132$.google.protobuf.EnumDescriptorP" + "roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf." + "ServiceDescriptorProto\0228\n\textension\030\007 \003(" + "\0132%.google.protobuf.FieldDescriptorProto" + "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File" + "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog" + "le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001" + "(\t\"\360\004\n\017DescriptorProto\022\014\n\004name\030\001 \001(\t\0224\n\005" + "field\030\002 \003(\0132%.google.protobuf.FieldDescr" + "iptorProto\0228\n\textension\030\006 \003(\0132%.google.p" + "rotobuf.FieldDescriptorProto\0225\n\013nested_t" + "ype\030\003 \003(\0132 .google.protobuf.DescriptorPr" + "oto\0227\n\tenum_type\030\004 \003(\0132$.google.protobuf" + ".EnumDescriptorProto\022H\n\017extension_range\030" + "\005 \003(\0132/.google.protobuf.DescriptorProto." + "ExtensionRange\0229\n\noneof_decl\030\010 \003(\0132%.goo" + "gle.protobuf.OneofDescriptorProto\0220\n\007opt" + "ions\030\007 \001(\0132\037.google.protobuf.MessageOpti" + "ons\022F\n\016reserved_range\030\t \003(\0132..google.pro" + "tobuf.DescriptorProto.ReservedRange\022\025\n\rr" + "eserved_name\030\n \003(\t\032,\n\016ExtensionRange\022\r\n\005" + "start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\032+\n\rReservedRang" + "e\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"\274\005\n\024FieldD" + "escriptorProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number\030\003" + " \001(\005\022:\n\005label\030\004 \001(\0162+.google.protobuf.Fi" + "eldDescriptorProto.Label\0228\n\004type\030\005 \001(\0162*" + ".google.protobuf.FieldDescriptorProto.Ty" + "pe\022\021\n\ttype_name\030\006 \001(\t\022\020\n\010extendee\030\002 \001(\t\022" + "\025\n\rdefault_value\030\007 \001(\t\022\023\n\013oneof_index\030\t " + "\001(\005\022\021\n\tjson_name\030\n \001(\t\022.\n\007options\030\010 \001(\0132" + "\035.google.protobuf.FieldOptions\"\266\002\n\004Type\022" + "\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE" + "_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020" + "\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n" + "\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GR" + "OUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022" + "\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_" + "SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SI" + "NT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016LABE" + "L_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016LABE" + "L_REPEATED\020\003\"T\n\024OneofDescriptorProto\022\014\n\004" + "name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google.pro" + "tobuf.OneofOptions\"\214\001\n\023EnumDescriptorPro" + "to\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).google" + ".protobuf.EnumValueDescriptorProto\022-\n\007op" + "tions\030\003 \001(\0132\034.google.protobuf.EnumOption" + "s\"l\n\030EnumValueDescriptorProto\022\014\n\004name\030\001 " + "\001(\t\022\016\n\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.g" + "oogle.protobuf.EnumValueOptions\"\220\001\n\026Serv" + "iceDescriptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006meth" + "od\030\002 \003(\0132&.google.protobuf.MethodDescrip" + "torProto\0220\n\007options\030\003 \001(\0132\037.google.proto" + "buf.ServiceOptions\"\301\001\n\025MethodDescriptorP" + "roto\022\014\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023" + "\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\"\204\005\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(\010B\002\030" + "\001\022%\n\026java_string_check_utf8\030\033 \001(\010:\005false" + "\022F\n\014optimize_for\030\t \001(\0162).google.protobuf" + ".FileOptions.OptimizeMode:\005SPEED\022\022\n\ngo_p" + "ackage\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:\005fal" + "se\022\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enab" + "le_arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_pre" + "fix\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022C\n\024u" + "ninterpreted_option\030\347\007 \003(\0132$.google.prot" + "obuf.UninterpretedOption\":\n\014OptimizeMode" + "\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTI" + "ME\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:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tm" + "ap_entry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347" + "\007 \003(\0132$.google.protobuf.UninterpretedOpt" + "ion*\t\010\350\007\020\200\200\200\200\002J\004\010\010\020\t\"\236\003\n\014FieldOptions\022:\n" + "\005ctype\030\001 \001(\0162#.google.protobuf.FieldOpti" + "ons.CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jst" + "ype\030\006 \001(\0162$.google.protobuf.FieldOptions" + ".JSType:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005false\022" + "\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010" + ":\005false\022C\n\024uninterpreted_option\030\347\007 \003(\0132$" + ".google.protobuf.UninterpretedOption\"/\n\005" + "CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PI" + "ECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_STR" + "ING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n" + "\014OneofOptions\022C\n\024uninterpreted_option\030\347\007" + " \003(\0132$.google.protobuf.UninterpretedOpti" + "on*\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013EnumOptions\022\023\n\013allow_a" + "lias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n" + "\024uninterpreted_option\030\347\007 \003(\0132$.google.pr" + "otobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"}\n" + "\020EnumValueOptions\022\031\n\ndeprecated\030\001 \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\"{\n\016ServiceOptions\022\031\n\ndeprecated\030! \001" + "(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(\013" + "2$.google.protobuf.UninterpretedOption*\t" + "\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodOptions\022\031\n\ndeprecate" + "d\030! \001(\010:\005false\022_\n\021idempotency_level\030\" \001(" + "\0162/.google.protobuf.MethodOptions.Idempo" + "tencyLevel:\023IDEMPOTENCY_UNKNOWN\022C\n\024unint" + "erpreted_option\030\347\007 \003(\0132$.google.protobuf" + ".UninterpretedOption\"P\n\020IdempotencyLevel" + "\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_SIDE_EFF" + "ECTS\020\001\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023Un" + "interpretedOption\022;\n\004name\030\002 \003(\0132-.google" + ".protobuf.UninterpretedOption.NamePart\022\030" + "\n\020identifier_value\030\003 \001(\t\022\032\n\022positive_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\014string_value\030\007" + " \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n\010NamePar" + "t\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_extension\030\002 \002" + "(\010\"\325\001\n\016SourceCodeInfo\022:\n\010location\030\001 \003(\0132" + "(.google.protobuf.SourceCodeInfo.Locatio" + "n\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004span" + "\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022\031\n\021" + "trailing_comments\030\004 \001(\t\022!\n\031leading_detac" + "hed_comments\030\006 \003(\t\"\247\001\n\021GeneratedCodeInfo" + "\022A\n\nannotation\030\001 \003(\0132-.google.protobuf.G" + "eneratedCodeInfo.Annotation\032O\n\nAnnotatio" + "n\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(\005BX\n\023com.goog" + "le.protobufB\020DescriptorProtosH\001Z\ndescrip" + "tor\242\002\003GPB\252\002\032Google.Protobuf.Reflection" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n google/protobuf/descriptor.proto\022\017goog" - "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file" - "\030\001 \003(\0132$.google.protobuf.FileDescriptorP" - "roto\"\333\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001" - "(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022" - "\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen" - "dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog" - "le.protobuf.DescriptorProto\0227\n\tenum_type" - "\030\005 \003(\0132$.google.protobuf.EnumDescriptorP" - "roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf." - "ServiceDescriptorProto\0228\n\textension\030\007 \003(" - "\0132%.google.protobuf.FieldDescriptorProto" - "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File" - "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog" - "le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001" - "(\t\"\360\004\n\017DescriptorProto\022\014\n\004name\030\001 \001(\t\0224\n\005" - "field\030\002 \003(\0132%.google.protobuf.FieldDescr" - "iptorProto\0228\n\textension\030\006 \003(\0132%.google.p" - "rotobuf.FieldDescriptorProto\0225\n\013nested_t" - "ype\030\003 \003(\0132 .google.protobuf.DescriptorPr" - "oto\0227\n\tenum_type\030\004 \003(\0132$.google.protobuf" - ".EnumDescriptorProto\022H\n\017extension_range\030" - "\005 \003(\0132/.google.protobuf.DescriptorProto." - "ExtensionRange\0229\n\noneof_decl\030\010 \003(\0132%.goo" - "gle.protobuf.OneofDescriptorProto\0220\n\007opt" - "ions\030\007 \001(\0132\037.google.protobuf.MessageOpti" - "ons\022F\n\016reserved_range\030\t \003(\0132..google.pro" - "tobuf.DescriptorProto.ReservedRange\022\025\n\rr" - "eserved_name\030\n \003(\t\032,\n\016ExtensionRange\022\r\n\005" - "start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\032+\n\rReservedRang" - "e\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"\274\005\n\024FieldD" - "escriptorProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number\030\003" - " \001(\005\022:\n\005label\030\004 \001(\0162+.google.protobuf.Fi" - "eldDescriptorProto.Label\0228\n\004type\030\005 \001(\0162*" - ".google.protobuf.FieldDescriptorProto.Ty" - "pe\022\021\n\ttype_name\030\006 \001(\t\022\020\n\010extendee\030\002 \001(\t\022" - "\025\n\rdefault_value\030\007 \001(\t\022\023\n\013oneof_index\030\t " - "\001(\005\022\021\n\tjson_name\030\n \001(\t\022.\n\007options\030\010 \001(\0132" - "\035.google.protobuf.FieldOptions\"\266\002\n\004Type\022" - "\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE" - "_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020" - "\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n" - "\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GR" - "OUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022" - "\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_" - "SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SI" - "NT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016LABE" - "L_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016LABE" - "L_REPEATED\020\003\"T\n\024OneofDescriptorProto\022\014\n\004" - "name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google.pro" - "tobuf.OneofOptions\"\214\001\n\023EnumDescriptorPro" - "to\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).google" - ".protobuf.EnumValueDescriptorProto\022-\n\007op" - "tions\030\003 \001(\0132\034.google.protobuf.EnumOption" - "s\"l\n\030EnumValueDescriptorProto\022\014\n\004name\030\001 " - "\001(\t\022\016\n\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.g" - "oogle.protobuf.EnumValueOptions\"\220\001\n\026Serv" - "iceDescriptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006meth" - "od\030\002 \003(\0132&.google.protobuf.MethodDescrip" - "torProto\0220\n\007options\030\003 \001(\0132\037.google.proto" - "buf.ServiceOptions\"\301\001\n\025MethodDescriptorP" - "roto\022\014\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023" - "\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\"\204\005\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(\010B\002\030" - "\001\022%\n\026java_string_check_utf8\030\033 \001(\010:\005false" - "\022F\n\014optimize_for\030\t \001(\0162).google.protobuf" - ".FileOptions.OptimizeMode:\005SPEED\022\022\n\ngo_p" - "ackage\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:\005fal" - "se\022\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enab" - "le_arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_pre" - "fix\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022C\n\024u" - "ninterpreted_option\030\347\007 \003(\0132$.google.prot" - "obuf.UninterpretedOption\":\n\014OptimizeMode" - "\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTI" - "ME\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:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tm" - "ap_entry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347" - "\007 \003(\0132$.google.protobuf.UninterpretedOpt" - "ion*\t\010\350\007\020\200\200\200\200\002J\004\010\010\020\t\"\236\003\n\014FieldOptions\022:\n" - "\005ctype\030\001 \001(\0162#.google.protobuf.FieldOpti" - "ons.CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jst" - "ype\030\006 \001(\0162$.google.protobuf.FieldOptions" - ".JSType:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005false\022" - "\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010" - ":\005false\022C\n\024uninterpreted_option\030\347\007 \003(\0132$" - ".google.protobuf.UninterpretedOption\"/\n\005" - "CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PI" - "ECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_STR" - "ING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n" - "\014OneofOptions\022C\n\024uninterpreted_option\030\347\007" - " \003(\0132$.google.protobuf.UninterpretedOpti" - "on*\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013EnumOptions\022\023\n\013allow_a" - "lias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n" - "\024uninterpreted_option\030\347\007 \003(\0132$.google.pr" - "otobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"}\n" - "\020EnumValueOptions\022\031\n\ndeprecated\030\001 \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\"{\n\016ServiceOptions\022\031\n\ndeprecated\030! \001" - "(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(\013" - "2$.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.UninterpretedOpti" - "on*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n" - "\004name\030\002 \003(\0132-.google.protobuf.Uninterpre" - "tedOption.NamePart\022\030\n\020identifier_value\030\003" - " \001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022nega" - "tive_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_va" - "lue\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\016SourceCodeInf" - "o\022:\n\010location\030\001 \003(\0132(.google.protobuf.So" - "urceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004pa" - "th\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leadin" - "g_comments\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\021GeneratedCodeInfo\022A\n\nannotation\030\001 \003(\013" - "2-.google.protobuf.GeneratedCodeInfo.Ann" - "otation\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\003e" - "nd\030\004 \001(\005BX\n\023com.google.protobufB\020Descrip" - "torProtosH\001Z\ndescriptor\242\002\003GPB\252\002\032Google.P" - "rotobuf.Reflection", 5298); + descriptor, 5478); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto); @@ -901,16 +753,174 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto { protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); } } static_descriptor_initializer_google_2fprotobuf_2fdescriptor_2eproto_; +const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[0]; +} +bool FieldDescriptorProto_Type_IsValid(int value) { + switch (value) { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + return true; + default: + return false; + } +} -namespace { +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_DOUBLE; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FLOAT; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT64; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT64; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT32; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED64; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED32; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BOOL; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_STRING; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_GROUP; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_MESSAGE; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BYTES; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT32; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_ENUM; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED32; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED64; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT32; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT64; +const FieldDescriptorProto_Type FieldDescriptorProto::Type_MIN; +const FieldDescriptorProto_Type FieldDescriptorProto::Type_MAX; +const int FieldDescriptorProto::Type_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[1]; +} +bool FieldDescriptorProto_Label_IsValid(int value) { + switch (value) { + case 1: + case 2: + case 3: + return true; + default: + return false; + } +} -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_OPTIONAL; +const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REQUIRED; +const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REPEATED; +const FieldDescriptorProto_Label FieldDescriptorProto::Label_MIN; +const FieldDescriptorProto_Label FieldDescriptorProto::Label_MAX; +const int FieldDescriptorProto::Label_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[2]; +} +bool FileOptions_OptimizeMode_IsValid(int value) { + switch (value) { + case 1: + case 2: + case 3: + return true; + default: + return false; + } } -} // namespace +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const FileOptions_OptimizeMode FileOptions::SPEED; +const FileOptions_OptimizeMode FileOptions::CODE_SIZE; +const FileOptions_OptimizeMode FileOptions::LITE_RUNTIME; +const FileOptions_OptimizeMode FileOptions::OptimizeMode_MIN; +const FileOptions_OptimizeMode FileOptions::OptimizeMode_MAX; +const int FileOptions::OptimizeMode_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[3]; +} +bool FieldOptions_CType_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + return true; + default: + return false; + } +} + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const FieldOptions_CType FieldOptions::STRING; +const FieldOptions_CType FieldOptions::CORD; +const FieldOptions_CType FieldOptions::STRING_PIECE; +const FieldOptions_CType FieldOptions::CType_MIN; +const FieldOptions_CType FieldOptions::CType_MAX; +const int FieldOptions::CType_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[4]; +} +bool FieldOptions_JSType_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + return true; + default: + return false; + } +} + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const FieldOptions_JSType FieldOptions::JS_NORMAL; +const FieldOptions_JSType FieldOptions::JS_STRING; +const FieldOptions_JSType FieldOptions::JS_NUMBER; +const FieldOptions_JSType FieldOptions::JSType_MIN; +const FieldOptions_JSType FieldOptions::JSType_MAX; +const int FieldOptions::JSType_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[5]; +} +bool MethodOptions_IdempotencyLevel_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + return true; + default: + return false; + } +} +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const MethodOptions_IdempotencyLevel MethodOptions::IDEMPOTENCY_UNKNOWN; +const MethodOptions_IdempotencyLevel MethodOptions::NO_SIDE_EFFECTS; +const MethodOptions_IdempotencyLevel MethodOptions::IDEMPOTENT; +const MethodOptions_IdempotencyLevel MethodOptions::IdempotencyLevel_MIN; +const MethodOptions_IdempotencyLevel MethodOptions::IdempotencyLevel_MAX; +const int MethodOptions::IdempotencyLevel_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 // =================================================================== @@ -920,19 +930,19 @@ const int FileDescriptorSet::kFileFieldNumber; FileDescriptorSet::FileDescriptorSet() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorSet) } - -void FileDescriptorSet::InitAsDefaultInstance() { -} - FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + file_(from.file_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorSet) } @@ -955,7 +965,7 @@ void FileDescriptorSet::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FileDescriptorSet::descriptor() { protobuf_AssignDescriptorsOnce(); - return FileDescriptorSet_descriptor_; + return file_level_metadata[0].descriptor; } const FileDescriptorSet& FileDescriptorSet::default_instance() { @@ -963,8 +973,6 @@ const FileDescriptorSet& FileDescriptorSet::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> FileDescriptorSet_default_instance_; - FileDescriptorSet* FileDescriptorSet::New(::google::protobuf::Arena* arena) const { FileDescriptorSet* n = new FileDescriptorSet; if (arena != NULL) { @@ -977,9 +985,7 @@ void FileDescriptorSet::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorSet) file_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool FileDescriptorSet::MergePartialFromCodedStream( @@ -988,23 +994,20 @@ bool FileDescriptorSet::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FileDescriptorSet) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.FileDescriptorProto file = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(input->IncrementRecursionDepth()); - parse_loop_file: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_file())); } else { goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_loop_file; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -1069,6 +1072,11 @@ size_t FileDescriptorSet::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorSet) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } // repeated .google.protobuf.FileDescriptorProto file = 1; { unsigned int count = this->file_size(); @@ -1080,11 +1088,6 @@ size_t FileDescriptorSet::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -1094,7 +1097,7 @@ size_t FileDescriptorSet::ByteSizeLong() const { void FileDescriptorSet::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorSet) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FileDescriptorSet* source = ::google::protobuf::internal::DynamicCastToGenerated<const FileDescriptorSet>( &from); @@ -1103,26 +1106,15 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FileDescriptorSet::MergeFrom(const FileDescriptorSet& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void FileDescriptorSet::UnsafeMergeFrom(const FileDescriptorSet& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); file_.MergeFrom(from.file_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void FileDescriptorSet::CopyFrom(const ::google::protobuf::Message& from) { @@ -1136,11 +1128,10 @@ void FileDescriptorSet::CopyFrom(const FileDescriptorSet& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorSet) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FileDescriptorSet::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->file())) return false; return true; } @@ -1158,10 +1149,7 @@ void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) { ::google::protobuf::Metadata FileDescriptorSet::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FileDescriptorSet_descriptor_; - metadata.reflection = FileDescriptorSet_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -1197,9 +1185,6 @@ FileDescriptorSet::file() const { return file_; } -inline const FileDescriptorSet* FileDescriptorSet::internal_default_instance() { - return &FileDescriptorSet_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1221,23 +1206,47 @@ const int FileDescriptorProto::kSyntaxFieldNumber; FileDescriptorProto::FileDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(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::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(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + dependency_(from.dependency_), + public_dependency_(from.public_dependency_), + weak_dependency_(from.weak_dependency_), + message_type_(from.message_type_), + enum_type_(from.enum_type_), + service_(from.service_), + extension_(from.extension_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_package()) { + package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.package_); + } + syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_syntax()) { + syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::FileOptions(*from.options_); + } else { + options_ = NULL; + } + if (from.has_source_code_info()) { + source_code_info_ = new ::google::protobuf::SourceCodeInfo(*from.source_code_info_); + } else { + source_code_info_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorProto) } @@ -1246,8 +1255,8 @@ void FileDescriptorProto::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - options_ = NULL; - source_code_info_ = NULL; + ::memset(&options_, 0, reinterpret_cast<char*>(&source_code_info_) - + reinterpret_cast<char*>(&options_) + sizeof(source_code_info_)); } FileDescriptorProto::~FileDescriptorProto() { @@ -1259,8 +1268,10 @@ void FileDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); syntax_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &FileDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; + } + if (this != internal_default_instance()) { delete source_code_info_; } } @@ -1272,7 +1283,7 @@ void FileDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FileDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return FileDescriptorProto_descriptor_; + return file_level_metadata[1].descriptor; } const FileDescriptorProto& FileDescriptorProto::default_instance() { @@ -1280,8 +1291,6 @@ const FileDescriptorProto& FileDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> FileDescriptorProto_default_instance_; - FileDescriptorProto* FileDescriptorProto::New(::google::protobuf::Arena* arena) const { FileDescriptorProto* n = new FileDescriptorProto; if (arena != NULL) { @@ -1292,36 +1301,37 @@ FileDescriptorProto* FileDescriptorProto::New(::google::protobuf::Arena* arena) void FileDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorProto) - if (_has_bits_[0 / 32] & 3u) { + dependency_.Clear(); + public_dependency_.Clear(); + weak_dependency_.Clear(); + message_type_.Clear(); + enum_type_.Clear(); + service_.Clear(); + extension_.Clear(); + if (_has_bits_[0 / 32] & 31u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } if (has_package()) { - package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*package_.UnsafeRawStringPointer())->clear(); + } + if (has_syntax()) { + GOOGLE_DCHECK(!syntax_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*syntax_.UnsafeRawStringPointer())->clear(); } - } - if (_has_bits_[8 / 32] & 3584u) { if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::FileOptions::Clear(); } if (has_source_code_info()) { - if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear(); - } - if (has_syntax()) { - syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(source_code_info_ != NULL); + source_code_info_->::google::protobuf::SourceCodeInfo::Clear(); } } - dependency_.Clear(); - public_dependency_.Clear(); - weak_dependency_.Clear(); - message_type_.Clear(); - enum_type_.Clear(); - service_.Clear(); - extension_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool FileDescriptorProto::MergePartialFromCodedStream( @@ -1330,13 +1340,13 @@ bool FileDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FileDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1346,14 +1356,12 @@ bool FileDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_package; break; } // optional string package = 2; case 2: { - if (tag == 18) { - parse_package: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1363,14 +1371,12 @@ bool FileDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_dependency; break; } // repeated string dependency = 3; case 3: { - if (tag == 26) { - parse_dependency: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_dependency())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1381,144 +1387,118 @@ bool FileDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_dependency; - if (input->ExpectTag(34)) goto parse_message_type; break; } // repeated .google.protobuf.DescriptorProto message_type = 4; case 4: { - if (tag == 34) { - parse_message_type: + if (tag == 34u) { DO_(input->IncrementRecursionDepth()); - parse_loop_message_type: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_message_type())); } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_loop_message_type; - if (input->ExpectTag(42)) goto parse_loop_enum_type; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; case 5: { - if (tag == 42) { + if (tag == 42u) { DO_(input->IncrementRecursionDepth()); - parse_loop_enum_type: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_enum_type())); } else { goto handle_unusual; } - if (input->ExpectTag(42)) goto parse_loop_enum_type; - if (input->ExpectTag(50)) goto parse_loop_service; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.ServiceDescriptorProto service = 6; case 6: { - if (tag == 50) { + if (tag == 50u) { DO_(input->IncrementRecursionDepth()); - parse_loop_service: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_service())); } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_loop_service; - if (input->ExpectTag(58)) goto parse_loop_extension; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.FieldDescriptorProto extension = 7; case 7: { - if (tag == 58) { + if (tag == 58u) { DO_(input->IncrementRecursionDepth()); - parse_loop_extension: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_extension())); } else { goto handle_unusual; } - if (input->ExpectTag(58)) goto parse_loop_extension; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(66)) goto parse_options; break; } // optional .google.protobuf.FileOptions options = 8; case 8: { - if (tag == 66) { - parse_options: + if (tag == 66u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectTag(74)) goto parse_source_code_info; break; } // optional .google.protobuf.SourceCodeInfo source_code_info = 9; case 9: { - if (tag == 74) { - parse_source_code_info: + if (tag == 74u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_source_code_info())); } else { goto handle_unusual; } - if (input->ExpectTag(80)) goto parse_public_dependency; break; } // repeated int32 public_dependency = 10; case 10: { - if (tag == 80) { - parse_public_dependency: + if (tag == 80u) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 80, input, this->mutable_public_dependency()))); - } else if (tag == 82) { + 1, 80u, input, this->mutable_public_dependency()))); + } else if (tag == 82u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_public_dependency()))); } else { goto handle_unusual; } - if (input->ExpectTag(80)) goto parse_public_dependency; - if (input->ExpectTag(88)) goto parse_weak_dependency; break; } // repeated int32 weak_dependency = 11; case 11: { - if (tag == 88) { - parse_weak_dependency: + if (tag == 88u) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 88, input, this->mutable_weak_dependency()))); - } else if (tag == 90) { + 1, 88u, input, this->mutable_weak_dependency()))); + } else if (tag == 90u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_weak_dependency()))); } else { goto handle_unusual; } - if (input->ExpectTag(88)) goto parse_weak_dependency; - if (input->ExpectTag(98)) goto parse_syntax; break; } // optional string syntax = 12; case 12: { - if (tag == 98) { - parse_syntax: + if (tag == 98u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_syntax())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1528,7 +1508,6 @@ bool FileDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1765,44 +1744,10 @@ size_t FileDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorProto) size_t total_size = 0; - if (_has_bits_[0 / 32] & 3u) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional string package = 2; - if (has_package()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->package()); - } - - } - if (_has_bits_[9 / 32] & 3584u) { - // optional .google.protobuf.FileOptions options = 8; - if (has_options()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->options_); - } - - // optional .google.protobuf.SourceCodeInfo source_code_info = 9; - if (has_source_code_info()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->source_code_info_); - } - - // optional string syntax = 12; - if (has_syntax()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->syntax()); - } - + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } // repeated string dependency = 3; total_size += 1 * @@ -1882,10 +1827,42 @@ size_t FileDescriptorProto::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + if (_has_bits_[0 / 32] & 31u) { + // optional string name = 1; + if (has_name()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + // optional string package = 2; + if (has_package()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->package()); + } + + // optional string syntax = 12; + if (has_syntax()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->syntax()); + } + + // optional .google.protobuf.FileOptions options = 8; + if (has_options()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->options_); + } + + // optional .google.protobuf.SourceCodeInfo source_code_info = 9; + if (has_source_code_info()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->source_code_info_); + } + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -1896,7 +1873,7 @@ size_t FileDescriptorProto::ByteSizeLong() const { void FileDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FileDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const FileDescriptorProto>( &from); @@ -1905,29 +1882,22 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorProto) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -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_); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + dependency_.MergeFrom(from.dependency_); + public_dependency_.MergeFrom(from.public_dependency_); + weak_dependency_.MergeFrom(from.weak_dependency_); message_type_.MergeFrom(from.message_type_); enum_type_.MergeFrom(from.enum_type_); service_.MergeFrom(from.service_); extension_.MergeFrom(from.extension_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 31u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -1936,22 +1906,16 @@ void FileDescriptorProto::UnsafeMergeFrom(const FileDescriptorProto& from) { set_has_package(); package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.package_); } - } - if (from._has_bits_[9 / 32] & (0xffu << (9 % 32))) { + if (from.has_syntax()) { + set_has_syntax(); + syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_); + } if (from.has_options()) { mutable_options()->::google::protobuf::FileOptions::MergeFrom(from.options()); } if (from.has_source_code_info()) { mutable_source_code_info()->::google::protobuf::SourceCodeInfo::MergeFrom(from.source_code_info()); } - if (from.has_syntax()) { - set_has_syntax(); - syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_); - } - } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); } } @@ -1966,11 +1930,10 @@ void FileDescriptorProto::CopyFrom(const FileDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FileDescriptorProto::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->message_type())) return false; if (!::google::protobuf::internal::AllAreInitialized(this->enum_type())) return false; if (!::google::protobuf::internal::AllAreInitialized(this->service())) return false; @@ -1986,8 +1949,6 @@ void FileDescriptorProto::Swap(FileDescriptorProto* other) { InternalSwap(other); } void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { - name_.Swap(&other->name_); - package_.Swap(&other->package_); dependency_.UnsafeArenaSwap(&other->dependency_); public_dependency_.UnsafeArenaSwap(&other->public_dependency_); weak_dependency_.UnsafeArenaSwap(&other->weak_dependency_); @@ -1995,9 +1956,11 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { enum_type_.UnsafeArenaSwap(&other->enum_type_); service_.UnsafeArenaSwap(&other->service_); extension_.UnsafeArenaSwap(&other->extension_); + name_.Swap(&other->name_); + package_.Swap(&other->package_); + syntax_.Swap(&other->syntax_); std::swap(options_, other->options_); std::swap(source_code_info_, other->source_code_info_); - syntax_.Swap(&other->syntax_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -2005,10 +1968,7 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { ::google::protobuf::Metadata FileDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FileDescriptorProto_descriptor_; - metadata.reflection = FileDescriptorProto_reflection_; - return metadata; + return file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -2030,7 +1990,7 @@ void FileDescriptorProto::clear_name() { } const ::std::string& FileDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void FileDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -2084,7 +2044,7 @@ void FileDescriptorProto::clear_package() { } const ::std::string& FileDescriptorProto::package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package) - return package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return package_.GetNoArena(); } void FileDescriptorProto::set_package(const ::std::string& value) { set_has_package(); @@ -2359,13 +2319,13 @@ FileDescriptorProto::extension() const { // optional .google.protobuf.FileOptions options = 8; bool FileDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } void FileDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000008u; } void FileDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000008u; } void FileDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear(); @@ -2404,13 +2364,13 @@ void FileDescriptorProto::set_allocated_options(::google::protobuf::FileOptions* // optional .google.protobuf.SourceCodeInfo source_code_info = 9; bool FileDescriptorProto::has_source_code_info() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } void FileDescriptorProto::set_has_source_code_info() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00000010u; } void FileDescriptorProto::clear_has_source_code_info() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00000010u; } void FileDescriptorProto::clear_source_code_info() { if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear(); @@ -2449,13 +2409,13 @@ void FileDescriptorProto::set_allocated_source_code_info(::google::protobuf::Sou // optional string syntax = 12; bool FileDescriptorProto::has_syntax() const { - return (_has_bits_[0] & 0x00000800u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } void FileDescriptorProto::set_has_syntax() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00000004u; } void FileDescriptorProto::clear_has_syntax() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00000004u; } void FileDescriptorProto::clear_syntax() { syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -2463,7 +2423,7 @@ void FileDescriptorProto::clear_syntax() { } const ::std::string& FileDescriptorProto::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax) - return syntax_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return syntax_.GetNoArena(); } void FileDescriptorProto::set_syntax(const ::std::string& value) { set_has_syntax(); @@ -2501,9 +2461,6 @@ void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax) } -inline const FileDescriptorProto* FileDescriptorProto::internal_default_instance() { - return &FileDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -2515,19 +2472,21 @@ 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(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ExtensionRange) } - -void DescriptorProto_ExtensionRange::InitAsDefaultInstance() { -} - DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::memcpy(&start_, &from.start_, + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_) + sizeof(end_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ExtensionRange) } @@ -2552,7 +2511,7 @@ void DescriptorProto_ExtensionRange::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange::descriptor() { protobuf_AssignDescriptorsOnce(); - return DescriptorProto_ExtensionRange_descriptor_; + return file_level_metadata[2].descriptor; } const DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_instance() { @@ -2560,8 +2519,6 @@ const DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_in return *internal_default_instance(); } -::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; if (arena != NULL) { @@ -2572,31 +2529,12 @@ DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::New(::google::pr void DescriptorProto_ExtensionRange::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ExtensionRange) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(DescriptorProto_ExtensionRange, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<DescriptorProto_ExtensionRange*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(start_, end_); - -#undef ZR_HELPER_ -#undef ZR_ - - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 3u) { + ::memset(&start_, 0, reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_) + sizeof(end_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( @@ -2605,13 +2543,13 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto.ExtensionRange) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional int32 start = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2619,14 +2557,12 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_end; break; } // optional int32 end = 2; case 2: { - if (tag == 16) { - parse_end: + if (tag == 16u) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2634,7 +2570,6 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2706,6 +2641,11 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ExtensionRange) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 3u) { // optional int32 start = 1; if (has_start()) { @@ -2722,11 +2662,6 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -2736,7 +2671,7 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const { 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)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const DescriptorProto_ExtensionRange* source = ::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto_ExtensionRange>( &from); @@ -2745,22 +2680,15 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void DescriptorProto_ExtensionRange::MergeFrom(const DescriptorProto_ExtensionRange& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange) - 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))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 3u) { if (from.has_start()) { set_start(from.start()); } @@ -2768,10 +2696,6 @@ void DescriptorProto_ExtensionRange::UnsafeMergeFrom(const DescriptorProto_Exten set_end(from.end()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void DescriptorProto_ExtensionRange::CopyFrom(const ::google::protobuf::Message& from) { @@ -2785,11 +2709,10 @@ void DescriptorProto_ExtensionRange::CopyFrom(const DescriptorProto_ExtensionRan // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ExtensionRange) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool DescriptorProto_ExtensionRange::IsInitialized() const { - return true; } @@ -2807,14 +2730,63 @@ void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange ::google::protobuf::Metadata DescriptorProto_ExtensionRange::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DescriptorProto_ExtensionRange_descriptor_; - metadata.reflection = DescriptorProto_ExtensionRange_reflection_; - return metadata; + return file_level_metadata[2]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// DescriptorProto_ExtensionRange + +// optional int32 start = 1; +bool DescriptorProto_ExtensionRange::has_start() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void DescriptorProto_ExtensionRange::set_has_start() { + _has_bits_[0] |= 0x00000001u; +} +void DescriptorProto_ExtensionRange::clear_has_start() { + _has_bits_[0] &= ~0x00000001u; +} +void DescriptorProto_ExtensionRange::clear_start() { + start_ = 0; + clear_has_start(); +} +::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) { + set_has_start(); + start_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.start) +} + +// optional int32 end = 2; +bool DescriptorProto_ExtensionRange::has_end() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void DescriptorProto_ExtensionRange::set_has_end() { + _has_bits_[0] |= 0x00000002u; +} +void DescriptorProto_ExtensionRange::clear_has_end() { + _has_bits_[0] &= ~0x00000002u; +} +void DescriptorProto_ExtensionRange::clear_end() { + end_ = 0; + clear_has_end(); +} +::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) { + set_has_end(); + end_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end) } +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS -// ------------------------------------------------------------------- +// =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int DescriptorProto_ReservedRange::kStartFieldNumber; @@ -2823,19 +2795,21 @@ 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(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ReservedRange) } - -void DescriptorProto_ReservedRange::InitAsDefaultInstance() { -} - DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::memcpy(&start_, &from.start_, + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_) + sizeof(end_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ReservedRange) } @@ -2860,7 +2834,7 @@ void DescriptorProto_ReservedRange::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* DescriptorProto_ReservedRange::descriptor() { protobuf_AssignDescriptorsOnce(); - return DescriptorProto_ReservedRange_descriptor_; + return file_level_metadata[3].descriptor; } const DescriptorProto_ReservedRange& DescriptorProto_ReservedRange::default_instance() { @@ -2868,8 +2842,6 @@ const DescriptorProto_ReservedRange& DescriptorProto_ReservedRange::default_inst return *internal_default_instance(); } -::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; if (arena != NULL) { @@ -2880,31 +2852,12 @@ DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::New(::google::prot void DescriptorProto_ReservedRange::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ReservedRange) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(DescriptorProto_ReservedRange, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<DescriptorProto_ReservedRange*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(start_, end_); - -#undef ZR_HELPER_ -#undef ZR_ - - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 3u) { + ::memset(&start_, 0, reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_) + sizeof(end_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( @@ -2913,13 +2866,13 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto.ReservedRange) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional int32 start = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2927,14 +2880,12 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_end; break; } // optional int32 end = 2; case 2: { - if (tag == 16) { - parse_end: + if (tag == 16u) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2942,7 +2893,6 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -3014,6 +2964,11 @@ size_t DescriptorProto_ReservedRange::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ReservedRange) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 3u) { // optional int32 start = 1; if (has_start()) { @@ -3030,11 +2985,6 @@ size_t DescriptorProto_ReservedRange::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -3044,7 +2994,7 @@ size_t DescriptorProto_ReservedRange::ByteSizeLong() const { 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)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const DescriptorProto_ReservedRange* source = ::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto_ReservedRange>( &from); @@ -3053,22 +3003,15 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void DescriptorProto_ReservedRange::MergeFrom(const DescriptorProto_ReservedRange& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange) - 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))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 3u) { if (from.has_start()) { set_start(from.start()); } @@ -3076,10 +3019,6 @@ void DescriptorProto_ReservedRange::UnsafeMergeFrom(const DescriptorProto_Reserv set_end(from.end()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void DescriptorProto_ReservedRange::CopyFrom(const ::google::protobuf::Message& from) { @@ -3093,11 +3032,10 @@ void DescriptorProto_ReservedRange::CopyFrom(const DescriptorProto_ReservedRange // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ReservedRange) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool DescriptorProto_ReservedRange::IsInitialized() const { - return true; } @@ -3115,14 +3053,63 @@ void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange* ::google::protobuf::Metadata DescriptorProto_ReservedRange::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DescriptorProto_ReservedRange_descriptor_; - metadata.reflection = DescriptorProto_ReservedRange_reflection_; - return metadata; + return file_level_metadata[3]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// DescriptorProto_ReservedRange + +// optional int32 start = 1; +bool DescriptorProto_ReservedRange::has_start() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void DescriptorProto_ReservedRange::set_has_start() { + _has_bits_[0] |= 0x00000001u; +} +void DescriptorProto_ReservedRange::clear_has_start() { + _has_bits_[0] &= ~0x00000001u; +} +void DescriptorProto_ReservedRange::clear_start() { + start_ = 0; + clear_has_start(); +} +::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) { + set_has_start(); + start_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.start) +} + +// optional int32 end = 2; +bool DescriptorProto_ReservedRange::has_end() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void DescriptorProto_ReservedRange::set_has_end() { + _has_bits_[0] |= 0x00000002u; +} +void DescriptorProto_ReservedRange::clear_has_end() { + _has_bits_[0] &= ~0x00000002u; +} +void DescriptorProto_ReservedRange::clear_end() { + end_ = 0; + clear_has_end(); +} +::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) { + set_has_end(); + end_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end) } +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS -// ------------------------------------------------------------------- +// =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int DescriptorProto::kNameFieldNumber; @@ -3139,21 +3126,35 @@ const int DescriptorProto::kReservedNameFieldNumber; DescriptorProto::DescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(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::internal_default_instance()); -} - DescriptorProto::DescriptorProto(const DescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + field_(from.field_), + extension_(from.extension_), + nested_type_(from.nested_type_), + enum_type_(from.enum_type_), + extension_range_(from.extension_range_), + oneof_decl_(from.oneof_decl_), + reserved_range_(from.reserved_range_), + reserved_name_(from.reserved_name_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::MessageOptions(*from.options_); + } else { + options_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto) } @@ -3170,7 +3171,7 @@ DescriptorProto::~DescriptorProto() { void DescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &DescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -3182,7 +3183,7 @@ void DescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* DescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return DescriptorProto_descriptor_; + return file_level_metadata[4].descriptor; } const DescriptorProto& DescriptorProto::default_instance() { @@ -3190,8 +3191,6 @@ const DescriptorProto& DescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> DescriptorProto_default_instance_; - DescriptorProto* DescriptorProto::New(::google::protobuf::Arena* arena) const { DescriptorProto* n = new DescriptorProto; if (arena != NULL) { @@ -3202,14 +3201,6 @@ DescriptorProto* DescriptorProto::New(::google::protobuf::Arena* arena) const { void DescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto) - if (_has_bits_[0 / 32] & 129u) { - if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - } - if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear(); - } - } field_.Clear(); extension_.Clear(); nested_type_.Clear(); @@ -3218,10 +3209,18 @@ void DescriptorProto::Clear() { oneof_decl_.Clear(); reserved_range_.Clear(); reserved_name_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 3u) { + if (has_name()) { + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); + } + if (has_options()) { + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::MessageOptions::Clear(); + } } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool DescriptorProto::MergePartialFromCodedStream( @@ -3230,13 +3229,13 @@ bool DescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -3246,141 +3245,114 @@ bool DescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_field; break; } // repeated .google.protobuf.FieldDescriptorProto field = 2; case 2: { - if (tag == 18) { - parse_field: + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_field: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_field())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_field; - if (input->ExpectTag(26)) goto parse_loop_nested_type; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.DescriptorProto nested_type = 3; case 3: { - if (tag == 26) { + if (tag == 26u) { DO_(input->IncrementRecursionDepth()); - parse_loop_nested_type: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_nested_type())); } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_loop_nested_type; - if (input->ExpectTag(34)) goto parse_loop_enum_type; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; case 4: { - if (tag == 34) { + if (tag == 34u) { DO_(input->IncrementRecursionDepth()); - parse_loop_enum_type: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_enum_type())); } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_loop_enum_type; - if (input->ExpectTag(42)) goto parse_loop_extension_range; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; case 5: { - if (tag == 42) { + if (tag == 42u) { DO_(input->IncrementRecursionDepth()); - parse_loop_extension_range: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_extension_range())); } else { goto handle_unusual; } - if (input->ExpectTag(42)) goto parse_loop_extension_range; - if (input->ExpectTag(50)) goto parse_loop_extension; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.FieldDescriptorProto extension = 6; case 6: { - if (tag == 50) { + if (tag == 50u) { DO_(input->IncrementRecursionDepth()); - parse_loop_extension: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_extension())); } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_loop_extension; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(58)) goto parse_options; break; } // optional .google.protobuf.MessageOptions options = 7; case 7: { - if (tag == 58) { - parse_options: + if (tag == 58u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectTag(66)) goto parse_oneof_decl; break; } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; case 8: { - if (tag == 66) { - parse_oneof_decl: + if (tag == 66u) { DO_(input->IncrementRecursionDepth()); - parse_loop_oneof_decl: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_oneof_decl())); } else { goto handle_unusual; } - if (input->ExpectTag(66)) goto parse_loop_oneof_decl; - if (input->ExpectTag(74)) goto parse_loop_reserved_range; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; case 9: { - if (tag == 74) { + if (tag == 74u) { DO_(input->IncrementRecursionDepth()); - parse_loop_reserved_range: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_reserved_range())); } else { goto handle_unusual; } - if (input->ExpectTag(74)) goto parse_loop_reserved_range; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(82)) goto parse_reserved_name; break; } // repeated string reserved_name = 10; case 10: { - if (tag == 82) { - parse_reserved_name: + if (tag == 82u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_reserved_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -3391,8 +3363,6 @@ bool DescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(82)) goto parse_reserved_name; - if (input->ExpectAtEnd()) goto success; break; } @@ -3589,21 +3559,10 @@ size_t DescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto) size_t total_size = 0; - if (_has_bits_[0 / 32] & 129u) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional .google.protobuf.MessageOptions options = 7; - if (has_options()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->options_); - } - + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } // repeated .google.protobuf.FieldDescriptorProto field = 2; { @@ -3690,10 +3649,21 @@ size_t DescriptorProto::ByteSizeLong() const { this->reserved_name(i)); } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + if (_has_bits_[0 / 32] & 3u) { + // optional string name = 1; + if (has_name()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + // optional .google.protobuf.MessageOptions options = 7; + if (has_options()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->options_); + } + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -3704,7 +3674,7 @@ size_t DescriptorProto::ByteSizeLong() const { void DescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const DescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto>( &from); @@ -3713,21 +3683,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void DescriptorProto::MergeFrom(const DescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void DescriptorProto::UnsafeMergeFrom(const DescriptorProto& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); field_.MergeFrom(from.field_); extension_.MergeFrom(from.extension_); nested_type_.MergeFrom(from.nested_type_); @@ -3735,8 +3698,8 @@ void DescriptorProto::UnsafeMergeFrom(const DescriptorProto& from) { extension_range_.MergeFrom(from.extension_range_); oneof_decl_.MergeFrom(from.oneof_decl_); reserved_range_.MergeFrom(from.reserved_range_); - reserved_name_.UnsafeMergeFrom(from.reserved_name_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + reserved_name_.MergeFrom(from.reserved_name_); + if (from._has_bits_[0 / 32] & 3u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -3745,10 +3708,6 @@ void DescriptorProto::UnsafeMergeFrom(const DescriptorProto& from) { mutable_options()->::google::protobuf::MessageOptions::MergeFrom(from.options()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void DescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { @@ -3762,11 +3721,10 @@ void DescriptorProto::CopyFrom(const DescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool DescriptorProto::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->field())) return false; if (!::google::protobuf::internal::AllAreInitialized(this->extension())) return false; if (!::google::protobuf::internal::AllAreInitialized(this->nested_type())) return false; @@ -3783,16 +3741,16 @@ void DescriptorProto::Swap(DescriptorProto* other) { InternalSwap(other); } void DescriptorProto::InternalSwap(DescriptorProto* other) { - name_.Swap(&other->name_); field_.UnsafeArenaSwap(&other->field_); extension_.UnsafeArenaSwap(&other->extension_); nested_type_.UnsafeArenaSwap(&other->nested_type_); enum_type_.UnsafeArenaSwap(&other->enum_type_); extension_range_.UnsafeArenaSwap(&other->extension_range_); oneof_decl_.UnsafeArenaSwap(&other->oneof_decl_); - std::swap(options_, other->options_); reserved_range_.UnsafeArenaSwap(&other->reserved_range_); reserved_name_.UnsafeArenaSwap(&other->reserved_name_); + name_.Swap(&other->name_); + std::swap(options_, other->options_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -3800,123 +3758,10 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) { ::google::protobuf::Metadata DescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DescriptorProto_descriptor_; - metadata.reflection = DescriptorProto_reflection_; - return metadata; + return file_level_metadata[4]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS -// DescriptorProto_ExtensionRange - -// optional int32 start = 1; -bool DescriptorProto_ExtensionRange::has_start() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void DescriptorProto_ExtensionRange::set_has_start() { - _has_bits_[0] |= 0x00000001u; -} -void DescriptorProto_ExtensionRange::clear_has_start() { - _has_bits_[0] &= ~0x00000001u; -} -void DescriptorProto_ExtensionRange::clear_start() { - start_ = 0; - clear_has_start(); -} -::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) { - set_has_start(); - start_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.start) -} - -// optional int32 end = 2; -bool DescriptorProto_ExtensionRange::has_end() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void DescriptorProto_ExtensionRange::set_has_end() { - _has_bits_[0] |= 0x00000002u; -} -void DescriptorProto_ExtensionRange::clear_has_end() { - _has_bits_[0] &= ~0x00000002u; -} -void DescriptorProto_ExtensionRange::clear_end() { - end_ = 0; - clear_has_end(); -} -::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) { - set_has_end(); - end_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end) -} - -inline const DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::internal_default_instance() { - return &DescriptorProto_ExtensionRange_default_instance_.get(); -} -// ------------------------------------------------------------------- - -// DescriptorProto_ReservedRange - -// optional int32 start = 1; -bool DescriptorProto_ReservedRange::has_start() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void DescriptorProto_ReservedRange::set_has_start() { - _has_bits_[0] |= 0x00000001u; -} -void DescriptorProto_ReservedRange::clear_has_start() { - _has_bits_[0] &= ~0x00000001u; -} -void DescriptorProto_ReservedRange::clear_start() { - start_ = 0; - clear_has_start(); -} -::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) { - set_has_start(); - start_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.start) -} - -// optional int32 end = 2; -bool DescriptorProto_ReservedRange::has_end() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void DescriptorProto_ReservedRange::set_has_end() { - _has_bits_[0] |= 0x00000002u; -} -void DescriptorProto_ReservedRange::clear_has_end() { - _has_bits_[0] &= ~0x00000002u; -} -void DescriptorProto_ReservedRange::clear_end() { - end_ = 0; - clear_has_end(); -} -::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) { - set_has_end(); - end_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end) -} - -inline const DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::internal_default_instance() { - return &DescriptorProto_ReservedRange_default_instance_.get(); -} -// ------------------------------------------------------------------- - // DescriptorProto // optional string name = 1; @@ -3935,7 +3780,7 @@ void DescriptorProto::clear_name() { } const ::std::string& DescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void DescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -4155,13 +4000,13 @@ DescriptorProto::oneof_decl() const { // optional .google.protobuf.MessageOptions options = 7; bool DescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000080u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void DescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000002u; } void DescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000002u; } void DescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear(); @@ -4283,89 +4128,10 @@ DescriptorProto::mutable_reserved_name() { return &reserved_name_; } -inline const DescriptorProto* DescriptorProto::internal_default_instance() { - return &DescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldDescriptorProto_Type_descriptor_; -} -bool FieldDescriptorProto_Type_IsValid(int value) { - switch (value) { - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_DOUBLE; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FLOAT; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT64; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT64; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED64; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BOOL; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_STRING; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_GROUP; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_MESSAGE; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BYTES; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_ENUM; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED64; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT64; -const FieldDescriptorProto_Type FieldDescriptorProto::Type_MIN; -const FieldDescriptorProto_Type FieldDescriptorProto::Type_MAX; -const int FieldDescriptorProto::Type_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 -const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldDescriptorProto_Label_descriptor_; -} -bool FieldDescriptorProto_Label_IsValid(int value) { - switch (value) { - case 1: - case 2: - case 3: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_OPTIONAL; -const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REQUIRED; -const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REPEATED; -const FieldDescriptorProto_Label FieldDescriptorProto::Label_MIN; -const FieldDescriptorProto_Label FieldDescriptorProto::Label_MAX; -const int FieldDescriptorProto::Label_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FieldDescriptorProto::kNameFieldNumber; const int FieldDescriptorProto::kNumberFieldNumber; @@ -4381,21 +4147,46 @@ const int FieldDescriptorProto::kOptionsFieldNumber; FieldDescriptorProto::FieldDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(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::internal_default_instance()); -} - FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + type_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_type_name()) { + type_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_name_); + } + extendee_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_extendee()) { + extendee_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.extendee_); + } + default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_default_value()) { + default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_); + } + json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_json_name()) { + json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::FieldOptions(*from.options_); + } else { + options_ = NULL; + } + ::memcpy(&number_, &from.number_, + reinterpret_cast<char*>(&type_) - + reinterpret_cast<char*>(&number_) + sizeof(type_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldDescriptorProto) } @@ -4406,9 +4197,8 @@ void FieldDescriptorProto::SharedCtor() { extendee_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - options_ = NULL; - ::memset(&number_, 0, reinterpret_cast<char*>(&oneof_index_) - - reinterpret_cast<char*>(&number_) + sizeof(oneof_index_)); + ::memset(&options_, 0, reinterpret_cast<char*>(&oneof_index_) - + reinterpret_cast<char*>(&options_) + sizeof(oneof_index_)); label_ = 1; type_ = 1; } @@ -4424,7 +4214,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 != &FieldDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -4436,7 +4226,7 @@ void FieldDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FieldDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return FieldDescriptorProto_descriptor_; + return file_level_metadata[5].descriptor; } const FieldDescriptorProto& FieldDescriptorProto::default_instance() { @@ -4444,8 +4234,6 @@ const FieldDescriptorProto& FieldDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> FieldDescriptorProto_default_instance_; - FieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena) const { FieldDescriptorProto* n = new FieldDescriptorProto; if (arena != NULL) { @@ -4456,55 +4244,42 @@ 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_bits_[0 / 32] & 63u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } - label_ = 1; - type_ = 1; if (has_type_name()) { - type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!type_name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*type_name_.UnsafeRawStringPointer())->clear(); } if (has_extendee()) { - extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!extendee_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*extendee_.UnsafeRawStringPointer())->clear(); } if (has_default_value()) { - default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!default_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*default_value_.UnsafeRawStringPointer())->clear(); } - } - if (_has_bits_[8 / 32] & 768u) { if (has_json_name()) { - json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!json_name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*json_name_.UnsafeRawStringPointer())->clear(); } if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::FieldOptions::Clear(); } } - -#undef ZR_HELPER_ -#undef ZR_ - - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 192u) { + ::memset(&number_, 0, reinterpret_cast<char*>(&oneof_index_) - + reinterpret_cast<char*>(&number_) + sizeof(oneof_index_)); } + if (_has_bits_[8 / 32] & 768u) { + label_ = 1; + type_ = 1; + } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool FieldDescriptorProto::MergePartialFromCodedStream( @@ -4513,13 +4288,13 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FieldDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4529,14 +4304,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_extendee; break; } // optional string extendee = 2; case 2: { - if (tag == 18) { - parse_extendee: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_extendee())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4546,14 +4319,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_number; break; } // optional int32 number = 3; case 3: { - if (tag == 24) { - parse_number: + if (tag == 24u) { set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -4561,14 +4332,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(32)) goto parse_label; break; } // optional .google.protobuf.FieldDescriptorProto.Label label = 4; case 4: { - if (tag == 32) { - parse_label: + if (tag == 32u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -4581,14 +4350,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(40)) goto parse_type; break; } // optional .google.protobuf.FieldDescriptorProto.Type type = 5; case 5: { - if (tag == 40) { - parse_type: + if (tag == 40u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -4601,14 +4368,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_type_name; break; } // optional string type_name = 6; case 6: { - if (tag == 50) { - parse_type_name: + if (tag == 50u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4618,14 +4383,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(58)) goto parse_default_value; break; } // optional string default_value = 7; case 7: { - if (tag == 58) { - parse_default_value: + if (tag == 58u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_default_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4635,27 +4398,23 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(66)) goto parse_options; break; } // optional .google.protobuf.FieldOptions options = 8; case 8: { - if (tag == 66) { - parse_options: + if (tag == 66u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectTag(72)) goto parse_oneof_index; break; } // optional int32 oneof_index = 9; case 9: { - if (tag == 72) { - parse_oneof_index: + if (tag == 72u) { set_has_oneof_index(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -4663,14 +4422,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(82)) goto parse_json_name; break; } // optional string json_name = 10; case 10: { - if (tag == 82) { - parse_json_name: + if (tag == 82u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_json_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4680,7 +4437,6 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -4894,6 +4650,11 @@ size_t FieldDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldDescriptorProto) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 255u) { // optional string name = 1; if (has_name()) { @@ -4902,25 +4663,6 @@ size_t FieldDescriptorProto::ByteSizeLong() const { this->name()); } - // optional int32 number = 3; - if (has_number()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->number()); - } - - // optional .google.protobuf.FieldDescriptorProto.Label label = 4; - if (has_label()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->label()); - } - - // optional .google.protobuf.FieldDescriptorProto.Type type = 5; - if (has_type()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); - } - // optional string type_name = 6; if (has_type_name()) { total_size += 1 + @@ -4942,15 +4684,6 @@ size_t FieldDescriptorProto::ByteSizeLong() const { this->default_value()); } - // optional int32 oneof_index = 9; - if (has_oneof_index()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->oneof_index()); - } - - } - if (_has_bits_[8 / 32] & 768u) { // optional string json_name = 10; if (has_json_name()) { total_size += 1 + @@ -4965,11 +4698,34 @@ size_t FieldDescriptorProto::ByteSizeLong() const { *this->options_); } + // optional int32 number = 3; + if (has_number()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->number()); + } + + // optional int32 oneof_index = 9; + if (has_oneof_index()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->oneof_index()); + } + } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + if (_has_bits_[8 / 32] & 768u) { + // optional .google.protobuf.FieldDescriptorProto.Label label = 4; + if (has_label()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->label()); + } + + // optional .google.protobuf.FieldDescriptorProto.Type type = 5; + if (has_type()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); + } + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -4980,7 +4736,7 @@ size_t FieldDescriptorProto::ByteSizeLong() const { void FieldDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FieldDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const FieldDescriptorProto>( &from); @@ -4989,35 +4745,19 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldDescriptorProto) - 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))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 255u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); } - if (from.has_number()) { - set_number(from.number()); - } - if (from.has_label()) { - set_label(from.label()); - } - if (from.has_type()) { - set_type(from.type()); - } if (from.has_type_name()) { set_has_type_name(); type_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_name_); @@ -5030,11 +4770,6 @@ void FieldDescriptorProto::UnsafeMergeFrom(const FieldDescriptorProto& from) { set_has_default_value(); default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_); } - if (from.has_oneof_index()) { - set_oneof_index(from.oneof_index()); - } - } - if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (from.has_json_name()) { set_has_json_name(); json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_); @@ -5042,10 +4777,20 @@ void FieldDescriptorProto::UnsafeMergeFrom(const FieldDescriptorProto& from) { if (from.has_options()) { mutable_options()->::google::protobuf::FieldOptions::MergeFrom(from.options()); } + if (from.has_number()) { + set_number(from.number()); + } + if (from.has_oneof_index()) { + set_oneof_index(from.oneof_index()); + } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + if (from._has_bits_[8 / 32] & 768u) { + if (from.has_label()) { + set_label(from.label()); + } + if (from.has_type()) { + set_type(from.type()); + } } } @@ -5060,11 +4805,10 @@ void FieldDescriptorProto::CopyFrom(const FieldDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FieldDescriptorProto::IsInitialized() const { - if (has_options()) { if (!this->options_->IsInitialized()) return false; } @@ -5077,15 +4821,15 @@ void FieldDescriptorProto::Swap(FieldDescriptorProto* other) { } void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) { name_.Swap(&other->name_); - std::swap(number_, other->number_); - std::swap(label_, other->label_); - std::swap(type_, other->type_); type_name_.Swap(&other->type_name_); extendee_.Swap(&other->extendee_); default_value_.Swap(&other->default_value_); - std::swap(oneof_index_, other->oneof_index_); json_name_.Swap(&other->json_name_); std::swap(options_, other->options_); + std::swap(number_, other->number_); + std::swap(oneof_index_, other->oneof_index_); + std::swap(label_, other->label_); + std::swap(type_, other->type_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -5093,10 +4837,7 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) { ::google::protobuf::Metadata FieldDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FieldDescriptorProto_descriptor_; - metadata.reflection = FieldDescriptorProto_reflection_; - return metadata; + return file_level_metadata[5]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -5118,7 +4859,7 @@ void FieldDescriptorProto::clear_name() { } const ::std::string& FieldDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void FieldDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5158,13 +4899,13 @@ void FieldDescriptorProto::set_allocated_name(::std::string* name) { // optional int32 number = 3; bool FieldDescriptorProto::has_number() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } void FieldDescriptorProto::set_has_number() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000040u; } void FieldDescriptorProto::clear_has_number() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000040u; } void FieldDescriptorProto::clear_number() { number_ = 0; @@ -5182,13 +4923,13 @@ void FieldDescriptorProto::set_number(::google::protobuf::int32 value) { // optional .google.protobuf.FieldDescriptorProto.Label label = 4; bool FieldDescriptorProto::has_label() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000100u) != 0; } void FieldDescriptorProto::set_has_label() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000100u; } void FieldDescriptorProto::clear_has_label() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000100u; } void FieldDescriptorProto::clear_label() { label_ = 1; @@ -5207,13 +4948,13 @@ void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorProto_La // optional .google.protobuf.FieldDescriptorProto.Type type = 5; bool FieldDescriptorProto::has_type() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000200u) != 0; } void FieldDescriptorProto::set_has_type() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000200u; } void FieldDescriptorProto::clear_has_type() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000200u; } void FieldDescriptorProto::clear_type() { type_ = 1; @@ -5232,13 +4973,13 @@ void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorProto_Typ // optional string type_name = 6; bool FieldDescriptorProto::has_type_name() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void FieldDescriptorProto::set_has_type_name() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000002u; } void FieldDescriptorProto::clear_has_type_name() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000002u; } void FieldDescriptorProto::clear_type_name() { type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5246,7 +4987,7 @@ void FieldDescriptorProto::clear_type_name() { } 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()); + return type_name_.GetNoArena(); } void FieldDescriptorProto::set_type_name(const ::std::string& value) { set_has_type_name(); @@ -5286,13 +5027,13 @@ void FieldDescriptorProto::set_allocated_type_name(::std::string* type_name) { // optional string extendee = 2; bool FieldDescriptorProto::has_extendee() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } void FieldDescriptorProto::set_has_extendee() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000004u; } void FieldDescriptorProto::clear_has_extendee() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000004u; } void FieldDescriptorProto::clear_extendee() { extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5300,7 +5041,7 @@ void FieldDescriptorProto::clear_extendee() { } const ::std::string& FieldDescriptorProto::extendee() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee) - return extendee_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return extendee_.GetNoArena(); } void FieldDescriptorProto::set_extendee(const ::std::string& value) { set_has_extendee(); @@ -5340,13 +5081,13 @@ void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee) { // optional string default_value = 7; bool FieldDescriptorProto::has_default_value() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } void FieldDescriptorProto::set_has_default_value() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000008u; } void FieldDescriptorProto::clear_has_default_value() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000008u; } void FieldDescriptorProto::clear_default_value() { default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5354,7 +5095,7 @@ void FieldDescriptorProto::clear_default_value() { } 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()); + return default_value_.GetNoArena(); } void FieldDescriptorProto::set_default_value(const ::std::string& value) { set_has_default_value(); @@ -5418,13 +5159,13 @@ void FieldDescriptorProto::set_oneof_index(::google::protobuf::int32 value) { // optional string json_name = 10; bool FieldDescriptorProto::has_json_name() const { - return (_has_bits_[0] & 0x00000100u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } void FieldDescriptorProto::set_has_json_name() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000010u; } void FieldDescriptorProto::clear_has_json_name() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000010u; } void FieldDescriptorProto::clear_json_name() { json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5432,7 +5173,7 @@ void FieldDescriptorProto::clear_json_name() { } 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()); + return json_name_.GetNoArena(); } void FieldDescriptorProto::set_json_name(const ::std::string& value) { set_has_json_name(); @@ -5472,13 +5213,13 @@ void FieldDescriptorProto::set_allocated_json_name(::std::string* json_name) { // optional .google.protobuf.FieldOptions options = 8; bool FieldDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } void FieldDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000020u; } void FieldDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000020u; } void FieldDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear(); @@ -5515,9 +5256,6 @@ void FieldDescriptorProto::set_allocated_options(::google::protobuf::FieldOption // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.options) } -inline const FieldDescriptorProto* FieldDescriptorProto::internal_default_instance() { - return &FieldDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -5529,21 +5267,27 @@ const int OneofDescriptorProto::kOptionsFieldNumber; OneofDescriptorProto::OneofDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(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::internal_default_instance()); -} - OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::OneofOptions(*from.options_); + } else { + options_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.OneofDescriptorProto) } @@ -5560,7 +5304,7 @@ OneofDescriptorProto::~OneofDescriptorProto() { void OneofDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &OneofDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -5572,7 +5316,7 @@ void OneofDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* OneofDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return OneofDescriptorProto_descriptor_; + return file_level_metadata[6].descriptor; } const OneofDescriptorProto& OneofDescriptorProto::default_instance() { @@ -5580,8 +5324,6 @@ const OneofDescriptorProto& OneofDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> OneofDescriptorProto_default_instance_; - OneofDescriptorProto* OneofDescriptorProto::New(::google::protobuf::Arena* arena) const { OneofDescriptorProto* n = new OneofDescriptorProto; if (arena != NULL) { @@ -5594,16 +5336,16 @@ void OneofDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.OneofDescriptorProto) if (_has_bits_[0 / 32] & 3u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::OneofOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::OneofOptions::Clear(); } } _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool OneofDescriptorProto::MergePartialFromCodedStream( @@ -5612,13 +5354,13 @@ bool OneofDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.OneofDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -5628,20 +5370,17 @@ bool OneofDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_options; break; } // optional .google.protobuf.OneofOptions options = 2; case 2: { - if (tag == 18) { - parse_options: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -5727,6 +5466,11 @@ size_t OneofDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofDescriptorProto) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 3u) { // optional string name = 1; if (has_name()) { @@ -5743,11 +5487,6 @@ size_t OneofDescriptorProto::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -5757,7 +5496,7 @@ size_t OneofDescriptorProto::ByteSizeLong() const { void OneofDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const OneofDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const OneofDescriptorProto>( &from); @@ -5766,22 +5505,15 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void OneofDescriptorProto::MergeFrom(const OneofDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofDescriptorProto) - 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))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 3u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -5790,10 +5522,6 @@ void OneofDescriptorProto::UnsafeMergeFrom(const OneofDescriptorProto& from) { mutable_options()->::google::protobuf::OneofOptions::MergeFrom(from.options()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void OneofDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { @@ -5807,11 +5535,10 @@ void OneofDescriptorProto::CopyFrom(const OneofDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool OneofDescriptorProto::IsInitialized() const { - if (has_options()) { if (!this->options_->IsInitialized()) return false; } @@ -5832,10 +5559,7 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) { ::google::protobuf::Metadata OneofDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = OneofDescriptorProto_descriptor_; - metadata.reflection = OneofDescriptorProto_reflection_; - return metadata; + return file_level_metadata[6]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -5857,7 +5581,7 @@ void OneofDescriptorProto::clear_name() { } const ::std::string& OneofDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void OneofDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5940,9 +5664,6 @@ void OneofDescriptorProto::set_allocated_options(::google::protobuf::OneofOption // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.options) } -inline const OneofDescriptorProto* OneofDescriptorProto::internal_default_instance() { - return &OneofDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -5955,21 +5676,28 @@ const int EnumDescriptorProto::kOptionsFieldNumber; EnumDescriptorProto::EnumDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(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::internal_default_instance()); -} - EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + value_(from.value_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::EnumOptions(*from.options_); + } else { + options_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumDescriptorProto) } @@ -5986,7 +5714,7 @@ EnumDescriptorProto::~EnumDescriptorProto() { void EnumDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &EnumDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -5998,7 +5726,7 @@ void EnumDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* EnumDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return EnumDescriptorProto_descriptor_; + return file_level_metadata[7].descriptor; } const EnumDescriptorProto& EnumDescriptorProto::default_instance() { @@ -6006,8 +5734,6 @@ const EnumDescriptorProto& EnumDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> EnumDescriptorProto_default_instance_; - EnumDescriptorProto* EnumDescriptorProto::New(::google::protobuf::Arena* arena) const { EnumDescriptorProto* n = new EnumDescriptorProto; if (arena != NULL) { @@ -6018,19 +5744,19 @@ EnumDescriptorProto* EnumDescriptorProto::New(::google::protobuf::Arena* arena) void EnumDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto) - if (_has_bits_[0 / 32] & 5u) { + value_.Clear(); + if (_has_bits_[0 / 32] & 3u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::EnumOptions::Clear(); } } - value_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool EnumDescriptorProto::MergePartialFromCodedStream( @@ -6039,13 +5765,13 @@ bool EnumDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.EnumDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -6055,37 +5781,30 @@ bool EnumDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_value; break; } // repeated .google.protobuf.EnumValueDescriptorProto value = 2; case 2: { - if (tag == 18) { - parse_value: + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_value: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_value())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_value; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(26)) goto parse_options; break; } // optional .google.protobuf.EnumOptions options = 3; case 3: { - if (tag == 26) { - parse_options: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -6184,7 +5903,23 @@ size_t EnumDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumDescriptorProto) size_t total_size = 0; - if (_has_bits_[0 / 32] & 5u) { + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.EnumValueDescriptorProto value = 2; + { + 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 (_has_bits_[0 / 32] & 3u) { // optional string name = 1; if (has_name()) { total_size += 1 + @@ -6200,22 +5935,6 @@ size_t EnumDescriptorProto::ByteSizeLong() const { } } - // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - { - 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()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -6225,7 +5944,7 @@ size_t EnumDescriptorProto::ByteSizeLong() const { void EnumDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const EnumDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumDescriptorProto>( &from); @@ -6234,23 +5953,16 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void EnumDescriptorProto::UnsafeMergeFrom(const EnumDescriptorProto& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); value_.MergeFrom(from.value_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 3u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -6259,10 +5971,6 @@ void EnumDescriptorProto::UnsafeMergeFrom(const EnumDescriptorProto& from) { mutable_options()->::google::protobuf::EnumOptions::MergeFrom(from.options()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void EnumDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { @@ -6276,11 +5984,10 @@ void EnumDescriptorProto::CopyFrom(const EnumDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool EnumDescriptorProto::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->value())) return false; if (has_options()) { if (!this->options_->IsInitialized()) return false; @@ -6293,8 +6000,8 @@ void EnumDescriptorProto::Swap(EnumDescriptorProto* other) { InternalSwap(other); } void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) { - name_.Swap(&other->name_); value_.UnsafeArenaSwap(&other->value_); + name_.Swap(&other->name_); std::swap(options_, other->options_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); @@ -6303,10 +6010,7 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) { ::google::protobuf::Metadata EnumDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumDescriptorProto_descriptor_; - metadata.reflection = EnumDescriptorProto_reflection_; - return metadata; + return file_level_metadata[7]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -6328,7 +6032,7 @@ void EnumDescriptorProto::clear_name() { } const ::std::string& EnumDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void EnumDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -6398,13 +6102,13 @@ EnumDescriptorProto::value() const { // optional .google.protobuf.EnumOptions options = 3; bool EnumDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void EnumDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } void EnumDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } void EnumDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear(); @@ -6441,9 +6145,6 @@ void EnumDescriptorProto::set_allocated_options(::google::protobuf::EnumOptions* // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.options) } -inline const EnumDescriptorProto* EnumDescriptorProto::internal_default_instance() { - return &EnumDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -6456,29 +6157,36 @@ const int EnumValueDescriptorProto::kOptionsFieldNumber; EnumValueDescriptorProto::EnumValueDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(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::internal_default_instance()); -} - EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::EnumValueOptions(*from.options_); + } else { + options_ = NULL; + } + number_ = from.number_; // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueDescriptorProto) } void EnumValueDescriptorProto::SharedCtor() { _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - options_ = NULL; - number_ = 0; + ::memset(&options_, 0, reinterpret_cast<char*>(&number_) - + reinterpret_cast<char*>(&options_) + sizeof(number_)); } EnumValueDescriptorProto::~EnumValueDescriptorProto() { @@ -6488,7 +6196,7 @@ EnumValueDescriptorProto::~EnumValueDescriptorProto() { void EnumValueDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &EnumValueDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -6500,7 +6208,7 @@ void EnumValueDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* EnumValueDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return EnumValueDescriptorProto_descriptor_; + return file_level_metadata[8].descriptor; } const EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() { @@ -6508,8 +6216,6 @@ const EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> EnumValueDescriptorProto_default_instance_; - EnumValueDescriptorProto* EnumValueDescriptorProto::New(::google::protobuf::Arena* arena) const { EnumValueDescriptorProto* n = new EnumValueDescriptorProto; if (arena != NULL) { @@ -6520,19 +6226,19 @@ EnumValueDescriptorProto* EnumValueDescriptorProto::New(::google::protobuf::Aren void EnumValueDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueDescriptorProto) - if (_has_bits_[0 / 32] & 7u) { + if (_has_bits_[0 / 32] & 3u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } - number_ = 0; if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::EnumValueOptions::Clear(); } } + number_ = 0; _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool EnumValueDescriptorProto::MergePartialFromCodedStream( @@ -6541,13 +6247,13 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.EnumValueDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -6557,14 +6263,12 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_number; break; } // optional int32 number = 2; case 2: { - if (tag == 16) { - parse_number: + if (tag == 16u) { set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -6572,20 +6276,17 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_options; break; } // optional .google.protobuf.EnumValueOptions options = 3; case 3: { - if (tag == 26) { - parse_options: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -6681,6 +6382,11 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueDescriptorProto) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 7u) { // optional string name = 1; if (has_name()) { @@ -6689,13 +6395,6 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const { this->name()); } - // optional int32 number = 2; - if (has_number()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->number()); - } - // optional .google.protobuf.EnumValueOptions options = 3; if (has_options()) { total_size += 1 + @@ -6703,11 +6402,13 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const { *this->options_); } - } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + // optional int32 number = 2; + if (has_number()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->number()); + } + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -6718,7 +6419,7 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const { void EnumValueDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const EnumValueDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumValueDescriptorProto>( &from); @@ -6727,36 +6428,25 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueDescriptorProto) - 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))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 7u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); } - if (from.has_number()) { - set_number(from.number()); - } if (from.has_options()) { mutable_options()->::google::protobuf::EnumValueOptions::MergeFrom(from.options()); } - } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + if (from.has_number()) { + set_number(from.number()); + } } } @@ -6771,11 +6461,10 @@ void EnumValueDescriptorProto::CopyFrom(const EnumValueDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool EnumValueDescriptorProto::IsInitialized() const { - if (has_options()) { if (!this->options_->IsInitialized()) return false; } @@ -6788,8 +6477,8 @@ void EnumValueDescriptorProto::Swap(EnumValueDescriptorProto* other) { } void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) { name_.Swap(&other->name_); - std::swap(number_, other->number_); std::swap(options_, other->options_); + std::swap(number_, other->number_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -6797,10 +6486,7 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) { ::google::protobuf::Metadata EnumValueDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumValueDescriptorProto_descriptor_; - metadata.reflection = EnumValueDescriptorProto_reflection_; - return metadata; + return file_level_metadata[8]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -6822,7 +6508,7 @@ void EnumValueDescriptorProto::clear_name() { } const ::std::string& EnumValueDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void EnumValueDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -6862,13 +6548,13 @@ void EnumValueDescriptorProto::set_allocated_name(::std::string* name) { // optional int32 number = 2; bool EnumValueDescriptorProto::has_number() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } void EnumValueDescriptorProto::set_has_number() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000004u; } void EnumValueDescriptorProto::clear_has_number() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000004u; } void EnumValueDescriptorProto::clear_number() { number_ = 0; @@ -6886,13 +6572,13 @@ void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value) { // optional .google.protobuf.EnumValueOptions options = 3; bool EnumValueDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void EnumValueDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } void EnumValueDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } void EnumValueDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear(); @@ -6929,9 +6615,6 @@ void EnumValueDescriptorProto::set_allocated_options(::google::protobuf::EnumVal // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.options) } -inline const EnumValueDescriptorProto* EnumValueDescriptorProto::internal_default_instance() { - return &EnumValueDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -6944,21 +6627,28 @@ const int ServiceDescriptorProto::kOptionsFieldNumber; ServiceDescriptorProto::ServiceDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(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::internal_default_instance()); -} - ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + method_(from.method_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::ServiceOptions(*from.options_); + } else { + options_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceDescriptorProto) } @@ -6975,7 +6665,7 @@ ServiceDescriptorProto::~ServiceDescriptorProto() { void ServiceDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &ServiceDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -6987,7 +6677,7 @@ void ServiceDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* ServiceDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return ServiceDescriptorProto_descriptor_; + return file_level_metadata[9].descriptor; } const ServiceDescriptorProto& ServiceDescriptorProto::default_instance() { @@ -6995,8 +6685,6 @@ const ServiceDescriptorProto& ServiceDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> ServiceDescriptorProto_default_instance_; - ServiceDescriptorProto* ServiceDescriptorProto::New(::google::protobuf::Arena* arena) const { ServiceDescriptorProto* n = new ServiceDescriptorProto; if (arena != NULL) { @@ -7007,19 +6695,19 @@ ServiceDescriptorProto* ServiceDescriptorProto::New(::google::protobuf::Arena* a void ServiceDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceDescriptorProto) - if (_has_bits_[0 / 32] & 5u) { + method_.Clear(); + if (_has_bits_[0 / 32] & 3u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::ServiceOptions::Clear(); } } - method_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool ServiceDescriptorProto::MergePartialFromCodedStream( @@ -7028,13 +6716,13 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.ServiceDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7044,37 +6732,30 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_method; break; } // repeated .google.protobuf.MethodDescriptorProto method = 2; case 2: { - if (tag == 18) { - parse_method: + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_method: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_method())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_method; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(26)) goto parse_options; break; } // optional .google.protobuf.ServiceOptions options = 3; case 3: { - if (tag == 26) { - parse_options: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -7173,7 +6854,23 @@ size_t ServiceDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceDescriptorProto) size_t total_size = 0; - if (_has_bits_[0 / 32] & 5u) { + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.MethodDescriptorProto method = 2; + { + 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 (_has_bits_[0 / 32] & 3u) { // optional string name = 1; if (has_name()) { total_size += 1 + @@ -7189,22 +6886,6 @@ size_t ServiceDescriptorProto::ByteSizeLong() const { } } - // repeated .google.protobuf.MethodDescriptorProto method = 2; - { - 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()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -7214,7 +6895,7 @@ size_t ServiceDescriptorProto::ByteSizeLong() const { void ServiceDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const ServiceDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const ServiceDescriptorProto>( &from); @@ -7223,23 +6904,16 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceDescriptorProto) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void ServiceDescriptorProto::UnsafeMergeFrom(const ServiceDescriptorProto& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); method_.MergeFrom(from.method_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 3u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -7248,10 +6922,6 @@ void ServiceDescriptorProto::UnsafeMergeFrom(const ServiceDescriptorProto& from) mutable_options()->::google::protobuf::ServiceOptions::MergeFrom(from.options()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void ServiceDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { @@ -7265,11 +6935,10 @@ void ServiceDescriptorProto::CopyFrom(const ServiceDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool ServiceDescriptorProto::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->method())) return false; if (has_options()) { if (!this->options_->IsInitialized()) return false; @@ -7282,8 +6951,8 @@ void ServiceDescriptorProto::Swap(ServiceDescriptorProto* other) { InternalSwap(other); } void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) { - name_.Swap(&other->name_); method_.UnsafeArenaSwap(&other->method_); + name_.Swap(&other->name_); std::swap(options_, other->options_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); @@ -7292,10 +6961,7 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) { ::google::protobuf::Metadata ServiceDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = ServiceDescriptorProto_descriptor_; - metadata.reflection = ServiceDescriptorProto_reflection_; - return metadata; + return file_level_metadata[9]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -7317,7 +6983,7 @@ void ServiceDescriptorProto::clear_name() { } const ::std::string& ServiceDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void ServiceDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -7387,13 +7053,13 @@ ServiceDescriptorProto::method() const { // optional .google.protobuf.ServiceOptions options = 3; bool ServiceDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void ServiceDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } void ServiceDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } void ServiceDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear(); @@ -7430,9 +7096,6 @@ void ServiceDescriptorProto::set_allocated_options(::google::protobuf::ServiceOp // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.options) } -inline const ServiceDescriptorProto* ServiceDescriptorProto::internal_default_instance() { - return &ServiceDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -7448,21 +7111,38 @@ const int MethodDescriptorProto::kServerStreamingFieldNumber; MethodDescriptorProto::MethodDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(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::internal_default_instance()); -} - MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + input_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_input_type()) { + input_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.input_type_); + } + output_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_output_type()) { + output_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.output_type_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::MethodOptions(*from.options_); + } else { + options_ = NULL; + } + ::memcpy(&client_streaming_, &from.client_streaming_, + reinterpret_cast<char*>(&server_streaming_) - + reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodDescriptorProto) } @@ -7471,9 +7151,8 @@ void MethodDescriptorProto::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); input_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); output_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - options_ = NULL; - ::memset(&client_streaming_, 0, reinterpret_cast<char*>(&server_streaming_) - - reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_)); + ::memset(&options_, 0, reinterpret_cast<char*>(&server_streaming_) - + reinterpret_cast<char*>(&options_) + sizeof(server_streaming_)); } MethodDescriptorProto::~MethodDescriptorProto() { @@ -7485,7 +7164,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 != &MethodDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -7497,7 +7176,7 @@ void MethodDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* MethodDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return MethodDescriptorProto_descriptor_; + return file_level_metadata[10].descriptor; } const MethodDescriptorProto& MethodDescriptorProto::default_instance() { @@ -7505,8 +7184,6 @@ const MethodDescriptorProto& MethodDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> MethodDescriptorProto_default_instance_; - MethodDescriptorProto* MethodDescriptorProto::New(::google::protobuf::Arena* arena) const { MethodDescriptorProto* n = new MethodDescriptorProto; if (arena != NULL) { @@ -7517,45 +7194,30 @@ MethodDescriptorProto* MethodDescriptorProto::New(::google::protobuf::Arena* are void MethodDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MethodDescriptorProto) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(MethodDescriptorProto, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<MethodDescriptorProto*>(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] & 63u) { - ZR_(client_streaming_, server_streaming_); + if (_has_bits_[0 / 32] & 15u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } if (has_input_type()) { - input_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!input_type_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*input_type_.UnsafeRawStringPointer())->clear(); } if (has_output_type()) { - output_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!output_type_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*output_type_.UnsafeRawStringPointer())->clear(); } if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::MethodOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::MethodOptions::Clear(); } } - -#undef ZR_HELPER_ -#undef ZR_ - - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 48u) { + ::memset(&client_streaming_, 0, reinterpret_cast<char*>(&server_streaming_) - + reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool MethodDescriptorProto::MergePartialFromCodedStream( @@ -7564,13 +7226,13 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.MethodDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7580,14 +7242,12 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_input_type; break; } // optional string input_type = 2; case 2: { - if (tag == 18) { - parse_input_type: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_input_type())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7597,14 +7257,12 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_output_type; break; } // optional string output_type = 3; case 3: { - if (tag == 26) { - parse_output_type: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_output_type())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7614,27 +7272,23 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_options; break; } // optional .google.protobuf.MethodOptions options = 4; case 4: { - if (tag == 34) { - parse_options: + if (tag == 34u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectTag(40)) goto parse_client_streaming; break; } // optional bool client_streaming = 5 [default = false]; case 5: { - if (tag == 40) { - parse_client_streaming: + if (tag == 40u) { set_has_client_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -7642,14 +7296,12 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(48)) goto parse_server_streaming; break; } // optional bool server_streaming = 6 [default = false]; case 6: { - if (tag == 48) { - parse_server_streaming: + if (tag == 48u) { set_has_server_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -7657,7 +7309,6 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -7805,6 +7456,11 @@ size_t MethodDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodDescriptorProto) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 63u) { // optional string name = 1; if (has_name()) { @@ -7845,11 +7501,6 @@ size_t MethodDescriptorProto::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -7859,7 +7510,7 @@ size_t MethodDescriptorProto::ByteSizeLong() const { void MethodDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const MethodDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const MethodDescriptorProto>( &from); @@ -7868,22 +7519,15 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodDescriptorProto) - 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))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 63u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -7906,10 +7550,6 @@ void MethodDescriptorProto::UnsafeMergeFrom(const MethodDescriptorProto& from) { set_server_streaming(from.server_streaming()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void MethodDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { @@ -7923,11 +7563,10 @@ void MethodDescriptorProto::CopyFrom(const MethodDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool MethodDescriptorProto::IsInitialized() const { - if (has_options()) { if (!this->options_->IsInitialized()) return false; } @@ -7952,10 +7591,7 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) { ::google::protobuf::Metadata MethodDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = MethodDescriptorProto_descriptor_; - metadata.reflection = MethodDescriptorProto_reflection_; - return metadata; + return file_level_metadata[10]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -7977,7 +7613,7 @@ void MethodDescriptorProto::clear_name() { } const ::std::string& MethodDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void MethodDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -8031,7 +7667,7 @@ void MethodDescriptorProto::clear_input_type() { } 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()); + return input_type_.GetNoArena(); } void MethodDescriptorProto::set_input_type(const ::std::string& value) { set_has_input_type(); @@ -8085,7 +7721,7 @@ void MethodDescriptorProto::clear_output_type() { } 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()); + return output_type_.GetNoArena(); } void MethodDescriptorProto::set_output_type(const ::std::string& value) { set_has_output_type(); @@ -8216,36 +7852,10 @@ void MethodDescriptorProto::set_server_streaming(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.server_streaming) } -inline const MethodDescriptorProto* MethodDescriptorProto::internal_default_instance() { - return &MethodDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FileOptions_OptimizeMode_descriptor_; -} -bool FileOptions_OptimizeMode_IsValid(int value) { - switch (value) { - case 1: - case 2: - case 3: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const FileOptions_OptimizeMode FileOptions::SPEED; -const FileOptions_OptimizeMode FileOptions::CODE_SIZE; -const FileOptions_OptimizeMode FileOptions::LITE_RUNTIME; -const FileOptions_OptimizeMode FileOptions::OptimizeMode_MIN; -const FileOptions_OptimizeMode FileOptions::OptimizeMode_MAX; -const int FileOptions::OptimizeMode_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FileOptions::kJavaPackageFieldNumber; const int FileOptions::kJavaOuterClassnameFieldNumber; @@ -8266,19 +7876,43 @@ const int FileOptions::kUninterpretedOptionFieldNumber; FileOptions::FileOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileOptions) } - -void FileOptions::InitAsDefaultInstance() { -} - FileOptions::FileOptions(const FileOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + java_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_java_package()) { + java_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_package_); + } + java_outer_classname_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_java_outer_classname()) { + java_outer_classname_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_outer_classname_); + } + go_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_go_package()) { + go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_); + } + objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_objc_class_prefix()) { + objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_); + } + csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_csharp_namespace()) { + csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_); + } + ::memcpy(&java_multiple_files_, &from.java_multiple_files_, + reinterpret_cast<char*>(&optimize_for_) - + reinterpret_cast<char*>(&java_multiple_files_) + sizeof(optimize_for_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileOptions) } @@ -8314,7 +7948,7 @@ void FileOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FileOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return FileOptions_descriptor_; + return file_level_metadata[11].descriptor; } const FileOptions& FileOptions::default_instance() { @@ -8322,8 +7956,6 @@ const FileOptions& FileOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FileOptions> FileOptions_default_instance_; - FileOptions* FileOptions::New(::google::protobuf::Arena* arena) const { FileOptions* n = new FileOptions; if (arena != NULL) { @@ -8335,53 +7967,40 @@ FileOptions* FileOptions::New(::google::protobuf::Arena* arena) const { void FileOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileOptions) _extensions_.Clear(); -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(FileOptions, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<FileOptions*>(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_(java_multiple_files_, cc_generic_services_); + uninterpreted_option_.Clear(); + if (_has_bits_[0 / 32] & 31u) { if (has_java_package()) { - java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!java_package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*java_package_.UnsafeRawStringPointer())->clear(); } if (has_java_outer_classname()) { - java_outer_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!java_outer_classname_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*java_outer_classname_.UnsafeRawStringPointer())->clear(); } - optimize_for_ = 1; if (has_go_package()) { - go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!go_package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*go_package_.UnsafeRawStringPointer())->clear(); } - } - if (_has_bits_[8 / 32] & 16128u) { - ZR_(java_generic_services_, cc_enable_arenas_); if (has_objc_class_prefix()) { - objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!objc_class_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*objc_class_prefix_.UnsafeRawStringPointer())->clear(); } if (has_csharp_namespace()) { - csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!csharp_namespace_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*csharp_namespace_.UnsafeRawStringPointer())->clear(); } } - -#undef ZR_HELPER_ -#undef ZR_ - - uninterpreted_option_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 224u) { + ::memset(&java_multiple_files_, 0, reinterpret_cast<char*>(&java_string_check_utf8_) - + reinterpret_cast<char*>(&java_multiple_files_) + sizeof(java_string_check_utf8_)); + } + if (_has_bits_[8 / 32] & 16128u) { + ::memset(&cc_generic_services_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) - + reinterpret_cast<char*>(&cc_generic_services_) + sizeof(cc_enable_arenas_)); + optimize_for_ = 1; } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool FileOptions::MergePartialFromCodedStream( @@ -8390,13 +8009,13 @@ bool FileOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FileOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string java_package = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_java_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8406,14 +8025,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(66)) goto parse_java_outer_classname; break; } // optional string java_outer_classname = 8; case 8: { - if (tag == 66) { - parse_java_outer_classname: + if (tag == 66u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_java_outer_classname())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8423,14 +8040,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(72)) goto parse_optimize_for; break; } // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; case 9: { - if (tag == 72) { - parse_optimize_for: + if (tag == 72u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -8443,14 +8058,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(80)) goto parse_java_multiple_files; break; } // optional bool java_multiple_files = 10 [default = false]; case 10: { - if (tag == 80) { - parse_java_multiple_files: + if (tag == 80u) { set_has_java_multiple_files(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8458,14 +8071,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(90)) goto parse_go_package; break; } // optional string go_package = 11; case 11: { - if (tag == 90) { - parse_go_package: + if (tag == 90u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_go_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8475,14 +8086,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(128)) goto parse_cc_generic_services; break; } // optional bool cc_generic_services = 16 [default = false]; case 16: { - if (tag == 128) { - parse_cc_generic_services: + if (tag == 128u) { set_has_cc_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8490,14 +8099,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(136)) goto parse_java_generic_services; break; } // optional bool java_generic_services = 17 [default = false]; case 17: { - if (tag == 136) { - parse_java_generic_services: + if (tag == 136u) { set_has_java_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8505,14 +8112,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(144)) goto parse_py_generic_services; break; } // optional bool py_generic_services = 18 [default = false]; case 18: { - if (tag == 144) { - parse_py_generic_services: + if (tag == 144u) { set_has_py_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8520,14 +8125,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(160)) goto parse_java_generate_equals_and_hash; break; } // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; case 20: { - if (tag == 160) { - parse_java_generate_equals_and_hash: + if (tag == 160u) { set_has_java_generate_equals_and_hash(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8535,14 +8138,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(184)) goto parse_deprecated; break; } // optional bool deprecated = 23 [default = false]; case 23: { - if (tag == 184) { - parse_deprecated: + if (tag == 184u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8550,14 +8151,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(216)) goto parse_java_string_check_utf8; break; } // optional bool java_string_check_utf8 = 27 [default = false]; case 27: { - if (tag == 216) { - parse_java_string_check_utf8: + if (tag == 216u) { set_has_java_string_check_utf8(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8565,14 +8164,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(248)) goto parse_cc_enable_arenas; break; } // optional bool cc_enable_arenas = 31 [default = false]; case 31: { - if (tag == 248) { - parse_cc_enable_arenas: + if (tag == 248u) { set_has_cc_enable_arenas(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8580,14 +8177,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(290)) goto parse_objc_class_prefix; break; } // optional string objc_class_prefix = 36; case 36: { - if (tag == 290) { - parse_objc_class_prefix: + if (tag == 290u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_objc_class_prefix())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8597,14 +8192,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(298)) goto parse_csharp_namespace; break; } // optional string csharp_namespace = 37; case 37: { - if (tag == 298) { - parse_csharp_namespace: + if (tag == 298u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_csharp_namespace())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8614,24 +8207,19 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -8906,6 +8494,24 @@ size_t FileOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileOptions) size_t total_size = 0; + total_size += _extensions_.ByteSize(); + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + { + 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)); + } + } + if (_has_bits_[0 / 32] & 255u) { // optional string java_package = 1; if (has_java_package()) { @@ -8921,6 +8527,27 @@ size_t FileOptions::ByteSizeLong() const { this->java_outer_classname()); } + // optional string go_package = 11; + if (has_go_package()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->go_package()); + } + + // optional string objc_class_prefix = 36; + if (has_objc_class_prefix()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->objc_class_prefix()); + } + + // optional string csharp_namespace = 37; + if (has_csharp_namespace()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->csharp_namespace()); + } + // optional bool java_multiple_files = 10 [default = false]; if (has_java_multiple_files()) { total_size += 1 + 1; @@ -8936,26 +8563,13 @@ size_t FileOptions::ByteSizeLong() const { total_size += 2 + 1; } - // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - if (has_optimize_for()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for()); - } - - // optional string go_package = 11; - if (has_go_package()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->go_package()); - } - + } + if (_has_bits_[8 / 32] & 16128u) { // optional bool cc_generic_services = 16 [default = false]; if (has_cc_generic_services()) { 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; @@ -8976,38 +8590,12 @@ size_t FileOptions::ByteSizeLong() const { total_size += 2 + 1; } - // optional string objc_class_prefix = 36; - if (has_objc_class_prefix()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->objc_class_prefix()); - } - - // optional string csharp_namespace = 37; - if (has_csharp_namespace()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->csharp_namespace()); - } - - } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - 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)); + // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; + if (has_optimize_for()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for()); } - } - total_size += _extensions_.ByteSize(); - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -9018,7 +8606,7 @@ size_t FileOptions::ByteSizeLong() const { void FileOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FileOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const FileOptions>( &from); @@ -9027,23 +8615,17 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FileOptions::MergeFrom(const FileOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileOptions) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void FileOptions::UnsafeMergeFrom(const FileOptions& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _extensions_.MergeFrom(from._extensions_); + _internal_metadata_.MergeFrom(from._internal_metadata_); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 255u) { if (from.has_java_package()) { set_has_java_package(); java_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_package_); @@ -9052,6 +8634,18 @@ void FileOptions::UnsafeMergeFrom(const FileOptions& from) { set_has_java_outer_classname(); java_outer_classname_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_outer_classname_); } + if (from.has_go_package()) { + set_has_go_package(); + go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_); + } + if (from.has_objc_class_prefix()) { + set_has_objc_class_prefix(); + objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_); + } + if (from.has_csharp_namespace()) { + set_has_csharp_namespace(); + csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_); + } if (from.has_java_multiple_files()) { set_java_multiple_files(from.java_multiple_files()); } @@ -9061,18 +8655,11 @@ void FileOptions::UnsafeMergeFrom(const FileOptions& from) { if (from.has_java_string_check_utf8()) { set_java_string_check_utf8(from.java_string_check_utf8()); } - if (from.has_optimize_for()) { - set_optimize_for(from.optimize_for()); - } - if (from.has_go_package()) { - set_has_go_package(); - go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_); - } + } + if (from._has_bits_[8 / 32] & 16128u) { 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()); } @@ -9085,20 +8672,10 @@ void FileOptions::UnsafeMergeFrom(const FileOptions& from) { if (from.has_cc_enable_arenas()) { set_cc_enable_arenas(from.cc_enable_arenas()); } - if (from.has_objc_class_prefix()) { - set_has_objc_class_prefix(); - objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_); - } - if (from.has_csharp_namespace()) { - set_has_csharp_namespace(); - csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_); + if (from.has_optimize_for()) { + set_optimize_for(from.optimize_for()); } } - _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void FileOptions::CopyFrom(const ::google::protobuf::Message& from) { @@ -9112,16 +8689,15 @@ void FileOptions::CopyFrom(const FileOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FileOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -9130,21 +8706,21 @@ void FileOptions::Swap(FileOptions* other) { InternalSwap(other); } void FileOptions::InternalSwap(FileOptions* other) { + uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); java_package_.Swap(&other->java_package_); java_outer_classname_.Swap(&other->java_outer_classname_); + go_package_.Swap(&other->go_package_); + objc_class_prefix_.Swap(&other->objc_class_prefix_); + csharp_namespace_.Swap(&other->csharp_namespace_); 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_); std::swap(cc_generic_services_, other->cc_generic_services_); std::swap(java_generic_services_, other->java_generic_services_); std::swap(py_generic_services_, other->py_generic_services_); std::swap(deprecated_, other->deprecated_); std::swap(cc_enable_arenas_, other->cc_enable_arenas_); - objc_class_prefix_.Swap(&other->objc_class_prefix_); - csharp_namespace_.Swap(&other->csharp_namespace_); - uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); + std::swap(optimize_for_, other->optimize_for_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -9153,10 +8729,7 @@ void FileOptions::InternalSwap(FileOptions* other) { ::google::protobuf::Metadata FileOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FileOptions_descriptor_; - metadata.reflection = FileOptions_reflection_; - return metadata; + return file_level_metadata[11]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -9178,7 +8751,7 @@ void FileOptions::clear_java_package() { } 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()); + return java_package_.GetNoArena(); } void FileOptions::set_java_package(const ::std::string& value) { set_has_java_package(); @@ -9232,7 +8805,7 @@ void FileOptions::clear_java_outer_classname() { } 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()); + return java_outer_classname_.GetNoArena(); } void FileOptions::set_java_outer_classname(const ::std::string& value) { set_has_java_outer_classname(); @@ -9272,13 +8845,13 @@ void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_c // optional bool java_multiple_files = 10 [default = false]; bool FileOptions::has_java_multiple_files() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } void FileOptions::set_has_java_multiple_files() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000020u; } void FileOptions::clear_has_java_multiple_files() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000020u; } void FileOptions::clear_java_multiple_files() { java_multiple_files_ = false; @@ -9296,13 +8869,13 @@ void FileOptions::set_java_multiple_files(bool value) { // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; bool FileOptions::has_java_generate_equals_and_hash() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000040u; } void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000040u; } void FileOptions::clear_java_generate_equals_and_hash() { java_generate_equals_and_hash_ = false; @@ -9320,13 +8893,13 @@ void FileOptions::set_java_generate_equals_and_hash(bool value) { // 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] & 0x00000080u) != 0; } void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000080u; } void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000080u; } void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; @@ -9344,13 +8917,13 @@ void FileOptions::set_java_string_check_utf8(bool value) { // 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] & 0x00002000u) != 0; } void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00002000u; } void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00002000u; } void FileOptions::clear_optimize_for() { optimize_for_ = 1; @@ -9369,13 +8942,13 @@ void FileOptions::set_optimize_for(::google::protobuf::FileOptions_OptimizeMode // optional string go_package = 11; bool FileOptions::has_go_package() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } void FileOptions::set_has_go_package() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000004u; } void FileOptions::clear_has_go_package() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000004u; } void FileOptions::clear_go_package() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -9383,7 +8956,7 @@ void FileOptions::clear_go_package() { } 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()); + return go_package_.GetNoArena(); } void FileOptions::set_go_package(const ::std::string& value) { set_has_go_package(); @@ -9423,13 +8996,13 @@ void FileOptions::set_allocated_go_package(::std::string* 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] & 0x00000100u) != 0; } void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000100u; } void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000100u; } void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; @@ -9447,13 +9020,13 @@ void FileOptions::set_cc_generic_services(bool value) { // 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] & 0x00000200u) != 0; } void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000200u; } void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000200u; } void FileOptions::clear_java_generic_services() { java_generic_services_ = false; @@ -9471,13 +9044,13 @@ void FileOptions::set_java_generic_services(bool value) { // 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] & 0x00000400u) != 0; } void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000400u; } void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000400u; } void FileOptions::clear_py_generic_services() { py_generic_services_ = false; @@ -9495,13 +9068,13 @@ void FileOptions::set_py_generic_services(bool value) { // optional bool deprecated = 23 [default = false]; bool FileOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00000800u) != 0; } void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00000800u; } void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00000800u; } void FileOptions::clear_deprecated() { deprecated_ = false; @@ -9519,13 +9092,13 @@ void FileOptions::set_deprecated(bool value) { // 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] & 0x00001000u) != 0; } void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00001000u; } void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00001000u; } void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; @@ -9543,13 +9116,13 @@ void FileOptions::set_cc_enable_arenas(bool value) { // optional string objc_class_prefix = 36; bool FileOptions::has_objc_class_prefix() const { - return (_has_bits_[0] & 0x00001000u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } void FileOptions::set_has_objc_class_prefix() { - _has_bits_[0] |= 0x00001000u; + _has_bits_[0] |= 0x00000008u; } void FileOptions::clear_has_objc_class_prefix() { - _has_bits_[0] &= ~0x00001000u; + _has_bits_[0] &= ~0x00000008u; } void FileOptions::clear_objc_class_prefix() { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -9557,7 +9130,7 @@ void FileOptions::clear_objc_class_prefix() { } 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()); + return objc_class_prefix_.GetNoArena(); } void FileOptions::set_objc_class_prefix(const ::std::string& value) { set_has_objc_class_prefix(); @@ -9597,13 +9170,13 @@ void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_class_pref // optional string csharp_namespace = 37; bool FileOptions::has_csharp_namespace() const { - return (_has_bits_[0] & 0x00002000u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } void FileOptions::set_has_csharp_namespace() { - _has_bits_[0] |= 0x00002000u; + _has_bits_[0] |= 0x00000010u; } void FileOptions::clear_has_csharp_namespace() { - _has_bits_[0] &= ~0x00002000u; + _has_bits_[0] &= ~0x00000010u; } void FileOptions::clear_csharp_namespace() { csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -9611,7 +9184,7 @@ void FileOptions::clear_csharp_namespace() { } 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()); + return csharp_namespace_.GetNoArena(); } void FileOptions::set_csharp_namespace(const ::std::string& value) { set_has_csharp_namespace(); @@ -9679,9 +9252,6 @@ FileOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const FileOptions* FileOptions::internal_default_instance() { - return &FileOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -9696,19 +9266,23 @@ const int MessageOptions::kUninterpretedOptionFieldNumber; MessageOptions::MessageOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MessageOptions) } - -void MessageOptions::InitAsDefaultInstance() { -} - MessageOptions::MessageOptions(const MessageOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + ::memcpy(&message_set_wire_format_, &from.message_set_wire_format_, + reinterpret_cast<char*>(&map_entry_) - + reinterpret_cast<char*>(&message_set_wire_format_) + sizeof(map_entry_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.MessageOptions) } @@ -9733,7 +9307,7 @@ void MessageOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* MessageOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return MessageOptions_descriptor_; + return file_level_metadata[12].descriptor; } const MessageOptions& MessageOptions::default_instance() { @@ -9741,8 +9315,6 @@ const MessageOptions& MessageOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> MessageOptions_default_instance_; - MessageOptions* MessageOptions::New(::google::protobuf::Arena* arena) const { MessageOptions* n = new MessageOptions; if (arena != NULL) { @@ -9754,32 +9326,13 @@ MessageOptions* MessageOptions::New(::google::protobuf::Arena* arena) const { void MessageOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MessageOptions) _extensions_.Clear(); -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(MessageOptions, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<MessageOptions*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(message_set_wire_format_, map_entry_); - -#undef ZR_HELPER_ -#undef ZR_ - uninterpreted_option_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 15u) { + ::memset(&message_set_wire_format_, 0, reinterpret_cast<char*>(&map_entry_) - + reinterpret_cast<char*>(&message_set_wire_format_) + sizeof(map_entry_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool MessageOptions::MergePartialFromCodedStream( @@ -9788,13 +9341,13 @@ bool MessageOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.MessageOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool message_set_wire_format = 1 [default = false]; case 1: { - if (tag == 8) { + if (tag == 8u) { set_has_message_set_wire_format(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9802,14 +9355,12 @@ bool MessageOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_no_standard_descriptor_accessor; break; } // optional bool no_standard_descriptor_accessor = 2 [default = false]; case 2: { - if (tag == 16) { - parse_no_standard_descriptor_accessor: + if (tag == 16u) { set_has_no_standard_descriptor_accessor(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9817,14 +9368,12 @@ bool MessageOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_deprecated; break; } // optional bool deprecated = 3 [default = false]; case 3: { - if (tag == 24) { - parse_deprecated: + if (tag == 24u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9832,14 +9381,12 @@ bool MessageOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(56)) goto parse_map_entry; break; } // optional bool map_entry = 7; case 7: { - if (tag == 56) { - parse_map_entry: + if (tag == 56u) { set_has_map_entry(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9847,24 +9394,19 @@ bool MessageOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -9982,6 +9524,24 @@ size_t MessageOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MessageOptions) size_t total_size = 0; + total_size += _extensions_.ByteSize(); + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + { + 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)); + } + } + if (_has_bits_[0 / 32] & 15u) { // optional bool message_set_wire_format = 1 [default = false]; if (has_message_set_wire_format()) { @@ -10004,24 +9564,6 @@ size_t MessageOptions::ByteSizeLong() const { } } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - 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(); - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -10031,7 +9573,7 @@ size_t MessageOptions::ByteSizeLong() const { void MessageOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MessageOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const MessageOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const MessageOptions>( &from); @@ -10040,23 +9582,17 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void MessageOptions::MergeFrom(const MessageOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MessageOptions) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void MessageOptions::UnsafeMergeFrom(const MessageOptions& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _extensions_.MergeFrom(from._extensions_); + _internal_metadata_.MergeFrom(from._internal_metadata_); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 15u) { if (from.has_message_set_wire_format()) { set_message_set_wire_format(from.message_set_wire_format()); } @@ -10070,11 +9606,6 @@ void MessageOptions::UnsafeMergeFrom(const MessageOptions& from) { set_map_entry(from.map_entry()); } } - _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void MessageOptions::CopyFrom(const ::google::protobuf::Message& from) { @@ -10088,16 +9619,15 @@ void MessageOptions::CopyFrom(const MessageOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MessageOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool MessageOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -10106,11 +9636,11 @@ void MessageOptions::Swap(MessageOptions* other) { InternalSwap(other); } void MessageOptions::InternalSwap(MessageOptions* other) { + uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(message_set_wire_format_, other->message_set_wire_format_); std::swap(no_standard_descriptor_accessor_, other->no_standard_descriptor_accessor_); std::swap(deprecated_, other->deprecated_); std::swap(map_entry_, other->map_entry_); - uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -10119,10 +9649,7 @@ void MessageOptions::InternalSwap(MessageOptions* other) { ::google::protobuf::Metadata MessageOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = MessageOptions_descriptor_; - metadata.reflection = MessageOptions_reflection_; - return metadata; + return file_level_metadata[12]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -10254,59 +9781,10 @@ MessageOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const MessageOptions* MessageOptions::internal_default_instance() { - return &MessageOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldOptions_CType_descriptor_; -} -bool FieldOptions_CType_IsValid(int value) { - switch (value) { - case 0: - case 1: - case 2: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const FieldOptions_CType FieldOptions::STRING; -const FieldOptions_CType FieldOptions::CORD; -const FieldOptions_CType FieldOptions::STRING_PIECE; -const FieldOptions_CType FieldOptions::CType_MIN; -const FieldOptions_CType FieldOptions::CType_MAX; -const int FieldOptions::CType_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 -const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldOptions_JSType_descriptor_; -} -bool FieldOptions_JSType_IsValid(int value) { - switch (value) { - case 0: - case 1: - case 2: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const FieldOptions_JSType FieldOptions::JS_NORMAL; -const FieldOptions_JSType FieldOptions::JS_STRING; -const FieldOptions_JSType FieldOptions::JS_NUMBER; -const FieldOptions_JSType FieldOptions::JSType_MIN; -const FieldOptions_JSType FieldOptions::JSType_MAX; -const int FieldOptions::JSType_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FieldOptions::kCtypeFieldNumber; const int FieldOptions::kPackedFieldNumber; @@ -10319,19 +9797,23 @@ const int FieldOptions::kUninterpretedOptionFieldNumber; FieldOptions::FieldOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldOptions) } - -void FieldOptions::InitAsDefaultInstance() { -} - FieldOptions::FieldOptions(const FieldOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + ::memcpy(&ctype_, &from.ctype_, + reinterpret_cast<char*>(&weak_) - + reinterpret_cast<char*>(&ctype_) + sizeof(weak_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldOptions) } @@ -10356,7 +9838,7 @@ void FieldOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FieldOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return FieldOptions_descriptor_; + return file_level_metadata[13].descriptor; } const FieldOptions& FieldOptions::default_instance() { @@ -10364,8 +9846,6 @@ const FieldOptions& FieldOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> FieldOptions_default_instance_; - FieldOptions* FieldOptions::New(::google::protobuf::Arena* arena) const { FieldOptions* n = new FieldOptions; if (arena != NULL) { @@ -10377,32 +9857,13 @@ FieldOptions* FieldOptions::New(::google::protobuf::Arena* arena) const { void FieldOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldOptions) _extensions_.Clear(); -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(FieldOptions, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<FieldOptions*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(ctype_, weak_); - -#undef ZR_HELPER_ -#undef ZR_ - uninterpreted_option_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 63u) { + ::memset(&ctype_, 0, reinterpret_cast<char*>(&weak_) - + reinterpret_cast<char*>(&ctype_) + sizeof(weak_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool FieldOptions::MergePartialFromCodedStream( @@ -10411,13 +9872,13 @@ bool FieldOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FieldOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; case 1: { - if (tag == 8) { + if (tag == 8u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -10430,14 +9891,12 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_packed; break; } // optional bool packed = 2; case 2: { - if (tag == 16) { - parse_packed: + if (tag == 16u) { set_has_packed(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10445,14 +9904,12 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_deprecated; break; } // optional bool deprecated = 3 [default = false]; case 3: { - if (tag == 24) { - parse_deprecated: + if (tag == 24u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10460,14 +9917,12 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(40)) goto parse_lazy; break; } // optional bool lazy = 5 [default = false]; case 5: { - if (tag == 40) { - parse_lazy: + if (tag == 40u) { set_has_lazy(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10475,14 +9930,12 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(48)) goto parse_jstype; break; } // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; case 6: { - if (tag == 48) { - parse_jstype: + if (tag == 48u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -10495,14 +9948,12 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(80)) goto parse_weak; break; } // optional bool weak = 10 [default = false]; case 10: { - if (tag == 80) { - parse_weak: + if (tag == 80u) { set_has_weak(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10510,24 +9961,19 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -10669,6 +10115,24 @@ size_t FieldOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldOptions) size_t total_size = 0; + total_size += _extensions_.ByteSize(); + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + { + 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)); + } + } + if (_has_bits_[0 / 32] & 63u) { // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; if (has_ctype()) { @@ -10676,17 +10140,17 @@ size_t FieldOptions::ByteSizeLong() const { ::google::protobuf::internal::WireFormatLite::EnumSize(this->ctype()); } - // optional bool packed = 2; - if (has_packed()) { - total_size += 1 + 1; - } - // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; if (has_jstype()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::EnumSize(this->jstype()); } + // optional bool packed = 2; + if (has_packed()) { + total_size += 1 + 1; + } + // optional bool lazy = 5 [default = false]; if (has_lazy()) { total_size += 1 + 1; @@ -10703,24 +10167,6 @@ size_t FieldOptions::ByteSizeLong() const { } } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - 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(); - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -10730,7 +10176,7 @@ size_t FieldOptions::ByteSizeLong() const { void FieldOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FieldOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const FieldOptions>( &from); @@ -10739,32 +10185,26 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FieldOptions::MergeFrom(const FieldOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void FieldOptions::UnsafeMergeFrom(const FieldOptions& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _extensions_.MergeFrom(from._extensions_); + _internal_metadata_.MergeFrom(from._internal_metadata_); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 63u) { if (from.has_ctype()) { set_ctype(from.ctype()); } - if (from.has_packed()) { - set_packed(from.packed()); - } if (from.has_jstype()) { set_jstype(from.jstype()); } + if (from.has_packed()) { + set_packed(from.packed()); + } if (from.has_lazy()) { set_lazy(from.lazy()); } @@ -10775,11 +10215,6 @@ void FieldOptions::UnsafeMergeFrom(const FieldOptions& from) { set_weak(from.weak()); } } - _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void FieldOptions::CopyFrom(const ::google::protobuf::Message& from) { @@ -10793,16 +10228,15 @@ void FieldOptions::CopyFrom(const FieldOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FieldOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -10811,13 +10245,13 @@ void FieldOptions::Swap(FieldOptions* other) { InternalSwap(other); } void FieldOptions::InternalSwap(FieldOptions* other) { + uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(ctype_, other->ctype_); - std::swap(packed_, other->packed_); std::swap(jstype_, other->jstype_); + std::swap(packed_, other->packed_); std::swap(lazy_, other->lazy_); std::swap(deprecated_, other->deprecated_); std::swap(weak_, other->weak_); - uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -10826,10 +10260,7 @@ void FieldOptions::InternalSwap(FieldOptions* other) { ::google::protobuf::Metadata FieldOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FieldOptions_descriptor_; - metadata.reflection = FieldOptions_reflection_; - return metadata; + return file_level_metadata[13]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -10862,13 +10293,13 @@ void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value) { // optional bool packed = 2; bool FieldOptions::has_packed() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } void FieldOptions::set_has_packed() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000004u; } void FieldOptions::clear_has_packed() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000004u; } void FieldOptions::clear_packed() { packed_ = false; @@ -10886,13 +10317,13 @@ void FieldOptions::set_packed(bool value) { // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; bool FieldOptions::has_jstype() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void FieldOptions::set_has_jstype() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } void FieldOptions::clear_has_jstype() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } void FieldOptions::clear_jstype() { jstype_ = 0; @@ -11011,9 +10442,6 @@ FieldOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const FieldOptions* FieldOptions::internal_default_instance() { - return &FieldOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -11024,19 +10452,20 @@ const int OneofOptions::kUninterpretedOptionFieldNumber; OneofOptions::OneofOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.OneofOptions) } - -void OneofOptions::InitAsDefaultInstance() { -} - OneofOptions::OneofOptions(const OneofOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); // @@protoc_insertion_point(copy_constructor:google.protobuf.OneofOptions) } @@ -11059,7 +10488,7 @@ void OneofOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* OneofOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return OneofOptions_descriptor_; + return file_level_metadata[14].descriptor; } const OneofOptions& OneofOptions::default_instance() { @@ -11067,8 +10496,6 @@ const OneofOptions& OneofOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> OneofOptions_default_instance_; - OneofOptions* OneofOptions::New(::google::protobuf::Arena* arena) const { OneofOptions* n = new OneofOptions; if (arena != NULL) { @@ -11082,9 +10509,7 @@ void OneofOptions::Clear() { _extensions_.Clear(); uninterpreted_option_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool OneofOptions::MergePartialFromCodedStream( @@ -11093,23 +10518,20 @@ bool OneofOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.OneofOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -11187,6 +10609,13 @@ size_t OneofOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofOptions) size_t total_size = 0; + total_size += _extensions_.ByteSize(); + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { unsigned int count = this->uninterpreted_option_size(); @@ -11198,13 +10627,6 @@ size_t OneofOptions::ByteSizeLong() const { } } - total_size += _extensions_.ByteSize(); - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -11214,7 +10636,7 @@ size_t OneofOptions::ByteSizeLong() const { void OneofOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const OneofOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const OneofOptions>( &from); @@ -11223,27 +10645,16 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void OneofOptions::MergeFrom(const OneofOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofOptions) - 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_); + GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } + _internal_metadata_.MergeFrom(from._internal_metadata_); + uninterpreted_option_.MergeFrom(from.uninterpreted_option_); } void OneofOptions::CopyFrom(const ::google::protobuf::Message& from) { @@ -11257,16 +10668,15 @@ void OneofOptions::CopyFrom(const OneofOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool OneofOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -11284,10 +10694,7 @@ void OneofOptions::InternalSwap(OneofOptions* other) { ::google::protobuf::Metadata OneofOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = OneofOptions_descriptor_; - metadata.reflection = OneofOptions_reflection_; - return metadata; + return file_level_metadata[14]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -11323,9 +10730,6 @@ OneofOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const OneofOptions* OneofOptions::internal_default_instance() { - return &OneofOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -11338,19 +10742,23 @@ const int EnumOptions::kUninterpretedOptionFieldNumber; EnumOptions::EnumOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumOptions) } - -void EnumOptions::InitAsDefaultInstance() { -} - EnumOptions::EnumOptions(const EnumOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + ::memcpy(&allow_alias_, &from.allow_alias_, + reinterpret_cast<char*>(&deprecated_) - + reinterpret_cast<char*>(&allow_alias_) + sizeof(deprecated_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumOptions) } @@ -11375,7 +10783,7 @@ void EnumOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* EnumOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return EnumOptions_descriptor_; + return file_level_metadata[15].descriptor; } const EnumOptions& EnumOptions::default_instance() { @@ -11383,8 +10791,6 @@ const EnumOptions& EnumOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> EnumOptions_default_instance_; - EnumOptions* EnumOptions::New(::google::protobuf::Arena* arena) const { EnumOptions* n = new EnumOptions; if (arena != NULL) { @@ -11396,32 +10802,13 @@ EnumOptions* EnumOptions::New(::google::protobuf::Arena* arena) const { void EnumOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumOptions) _extensions_.Clear(); -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(EnumOptions, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<EnumOptions*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(allow_alias_, deprecated_); - -#undef ZR_HELPER_ -#undef ZR_ - uninterpreted_option_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 3u) { + ::memset(&allow_alias_, 0, reinterpret_cast<char*>(&deprecated_) - + reinterpret_cast<char*>(&allow_alias_) + sizeof(deprecated_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool EnumOptions::MergePartialFromCodedStream( @@ -11430,13 +10817,13 @@ bool EnumOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.EnumOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool allow_alias = 2; case 2: { - if (tag == 16) { + if (tag == 16u) { set_has_allow_alias(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11444,14 +10831,12 @@ bool EnumOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_deprecated; break; } // optional bool deprecated = 3 [default = false]; case 3: { - if (tag == 24) { - parse_deprecated: + if (tag == 24u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11459,24 +10844,19 @@ bool EnumOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -11574,17 +10954,12 @@ size_t EnumOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumOptions) size_t total_size = 0; - if (_has_bits_[0 / 32] & 3u) { - // optional bool allow_alias = 2; - if (has_allow_alias()) { - total_size += 1 + 1; - } - - // optional bool deprecated = 3 [default = false]; - if (has_deprecated()) { - total_size += 1 + 1; - } + total_size += _extensions_.ByteSize(); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { @@ -11597,12 +10972,17 @@ size_t EnumOptions::ByteSizeLong() const { } } - total_size += _extensions_.ByteSize(); + if (_has_bits_[0 / 32] & 3u) { + // optional bool allow_alias = 2; + if (has_allow_alias()) { + total_size += 1 + 1; + } + + // optional bool deprecated = 3 [default = false]; + if (has_deprecated()) { + total_size += 1 + 1; + } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -11613,7 +10993,7 @@ size_t EnumOptions::ByteSizeLong() const { void EnumOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const EnumOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumOptions>( &from); @@ -11622,23 +11002,17 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void EnumOptions::MergeFrom(const EnumOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumOptions) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void EnumOptions::UnsafeMergeFrom(const EnumOptions& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _extensions_.MergeFrom(from._extensions_); + _internal_metadata_.MergeFrom(from._internal_metadata_); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 3u) { if (from.has_allow_alias()) { set_allow_alias(from.allow_alias()); } @@ -11646,11 +11020,6 @@ void EnumOptions::UnsafeMergeFrom(const EnumOptions& from) { set_deprecated(from.deprecated()); } } - _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void EnumOptions::CopyFrom(const ::google::protobuf::Message& from) { @@ -11664,16 +11033,15 @@ void EnumOptions::CopyFrom(const EnumOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool EnumOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -11682,9 +11050,9 @@ void EnumOptions::Swap(EnumOptions* other) { InternalSwap(other); } void EnumOptions::InternalSwap(EnumOptions* other) { + uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(allow_alias_, other->allow_alias_); std::swap(deprecated_, other->deprecated_); - uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -11693,10 +11061,7 @@ void EnumOptions::InternalSwap(EnumOptions* other) { ::google::protobuf::Metadata EnumOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumOptions_descriptor_; - metadata.reflection = EnumOptions_reflection_; - return metadata; + return file_level_metadata[15]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -11780,9 +11145,6 @@ EnumOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const EnumOptions* EnumOptions::internal_default_instance() { - return &EnumOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -11794,19 +11156,21 @@ const int EnumValueOptions::kUninterpretedOptionFieldNumber; EnumValueOptions::EnumValueOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValueOptions) } - -void EnumValueOptions::InitAsDefaultInstance() { -} - EnumValueOptions::EnumValueOptions(const EnumValueOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + deprecated_ = from.deprecated_; // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueOptions) } @@ -11830,7 +11194,7 @@ void EnumValueOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* EnumValueOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return EnumValueOptions_descriptor_; + return file_level_metadata[16].descriptor; } const EnumValueOptions& EnumValueOptions::default_instance() { @@ -11838,8 +11202,6 @@ const EnumValueOptions& EnumValueOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> EnumValueOptions_default_instance_; - EnumValueOptions* EnumValueOptions::New(::google::protobuf::Arena* arena) const { EnumValueOptions* n = new EnumValueOptions; if (arena != NULL) { @@ -11851,12 +11213,10 @@ EnumValueOptions* EnumValueOptions::New(::google::protobuf::Arena* arena) const void EnumValueOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueOptions) _extensions_.Clear(); - deprecated_ = false; uninterpreted_option_.Clear(); + deprecated_ = false; _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool EnumValueOptions::MergePartialFromCodedStream( @@ -11865,13 +11225,13 @@ bool EnumValueOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.EnumValueOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool deprecated = 1 [default = false]; case 1: { - if (tag == 8) { + if (tag == 8u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11879,24 +11239,19 @@ bool EnumValueOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -11984,11 +11339,13 @@ size_t EnumValueOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueOptions) size_t total_size = 0; - // optional bool deprecated = 1 [default = false]; - if (has_deprecated()) { - total_size += 1 + 1; - } + total_size += _extensions_.ByteSize(); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { unsigned int count = this->uninterpreted_option_size(); @@ -12000,13 +11357,11 @@ size_t EnumValueOptions::ByteSizeLong() const { } } - total_size += _extensions_.ByteSize(); - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + // optional bool deprecated = 1 [default = false]; + if (has_deprecated()) { + total_size += 1 + 1; } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -12016,7 +11371,7 @@ size_t EnumValueOptions::ByteSizeLong() const { void EnumValueOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const EnumValueOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumValueOptions>( &from); @@ -12025,31 +11380,18 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void EnumValueOptions::MergeFrom(const EnumValueOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueOptions) - 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()) { - set_deprecated(from.deprecated()); - } - } + GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); + uninterpreted_option_.MergeFrom(from.uninterpreted_option_); + if (from.has_deprecated()) { + set_deprecated(from.deprecated()); } } @@ -12064,16 +11406,15 @@ void EnumValueOptions::CopyFrom(const EnumValueOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool EnumValueOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -12082,8 +11423,8 @@ void EnumValueOptions::Swap(EnumValueOptions* other) { InternalSwap(other); } void EnumValueOptions::InternalSwap(EnumValueOptions* other) { - std::swap(deprecated_, other->deprecated_); uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); + std::swap(deprecated_, other->deprecated_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -12092,10 +11433,7 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* other) { ::google::protobuf::Metadata EnumValueOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumValueOptions_descriptor_; - metadata.reflection = EnumValueOptions_reflection_; - return metadata; + return file_level_metadata[16]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -12155,9 +11493,6 @@ EnumValueOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const EnumValueOptions* EnumValueOptions::internal_default_instance() { - return &EnumValueOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -12169,19 +11504,21 @@ const int ServiceOptions::kUninterpretedOptionFieldNumber; ServiceOptions::ServiceOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ServiceOptions) } - -void ServiceOptions::InitAsDefaultInstance() { -} - ServiceOptions::ServiceOptions(const ServiceOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + deprecated_ = from.deprecated_; // @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceOptions) } @@ -12205,7 +11542,7 @@ void ServiceOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* ServiceOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return ServiceOptions_descriptor_; + return file_level_metadata[17].descriptor; } const ServiceOptions& ServiceOptions::default_instance() { @@ -12213,8 +11550,6 @@ const ServiceOptions& ServiceOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> ServiceOptions_default_instance_; - ServiceOptions* ServiceOptions::New(::google::protobuf::Arena* arena) const { ServiceOptions* n = new ServiceOptions; if (arena != NULL) { @@ -12226,12 +11561,10 @@ ServiceOptions* ServiceOptions::New(::google::protobuf::Arena* arena) const { void ServiceOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceOptions) _extensions_.Clear(); - deprecated_ = false; uninterpreted_option_.Clear(); + deprecated_ = false; _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool ServiceOptions::MergePartialFromCodedStream( @@ -12240,13 +11573,13 @@ bool ServiceOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.ServiceOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool deprecated = 33 [default = false]; case 33: { - if (tag == 264) { + if (tag == 264u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -12254,24 +11587,19 @@ bool ServiceOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -12359,11 +11687,13 @@ size_t ServiceOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceOptions) size_t total_size = 0; - // optional bool deprecated = 33 [default = false]; - if (has_deprecated()) { - total_size += 2 + 1; - } + total_size += _extensions_.ByteSize(); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { unsigned int count = this->uninterpreted_option_size(); @@ -12375,13 +11705,11 @@ size_t ServiceOptions::ByteSizeLong() const { } } - total_size += _extensions_.ByteSize(); - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + // optional bool deprecated = 33 [default = false]; + if (has_deprecated()) { + total_size += 2 + 1; } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -12391,7 +11719,7 @@ size_t ServiceOptions::ByteSizeLong() const { void ServiceOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const ServiceOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const ServiceOptions>( &from); @@ -12400,31 +11728,18 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void ServiceOptions::MergeFrom(const ServiceOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceOptions) - 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()) { - set_deprecated(from.deprecated()); - } - } + GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); + uninterpreted_option_.MergeFrom(from.uninterpreted_option_); + if (from.has_deprecated()) { + set_deprecated(from.deprecated()); } } @@ -12439,16 +11754,15 @@ void ServiceOptions::CopyFrom(const ServiceOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool ServiceOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -12457,8 +11771,8 @@ void ServiceOptions::Swap(ServiceOptions* other) { InternalSwap(other); } void ServiceOptions::InternalSwap(ServiceOptions* other) { - std::swap(deprecated_, other->deprecated_); uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); + std::swap(deprecated_, other->deprecated_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -12467,10 +11781,7 @@ void ServiceOptions::InternalSwap(ServiceOptions* other) { ::google::protobuf::Metadata ServiceOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = ServiceOptions_descriptor_; - metadata.reflection = ServiceOptions_reflection_; - return metadata; + return file_level_metadata[17]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -12530,39 +11841,42 @@ ServiceOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const ServiceOptions* ServiceOptions::internal_default_instance() { - return &ServiceOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int MethodOptions::kDeprecatedFieldNumber; +const int MethodOptions::kIdempotencyLevelFieldNumber; const int MethodOptions::kUninterpretedOptionFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 MethodOptions::MethodOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MethodOptions) } - -void MethodOptions::InitAsDefaultInstance() { -} - MethodOptions::MethodOptions(const MethodOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + ::memcpy(&deprecated_, &from.deprecated_, + reinterpret_cast<char*>(&idempotency_level_) - + reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodOptions) } void MethodOptions::SharedCtor() { _cached_size_ = 0; - deprecated_ = false; + ::memset(&deprecated_, 0, reinterpret_cast<char*>(&idempotency_level_) - + reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_)); } MethodOptions::~MethodOptions() { @@ -12580,7 +11894,7 @@ void MethodOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* MethodOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return MethodOptions_descriptor_; + return file_level_metadata[18].descriptor; } const MethodOptions& MethodOptions::default_instance() { @@ -12588,8 +11902,6 @@ const MethodOptions& MethodOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> MethodOptions_default_instance_; - MethodOptions* MethodOptions::New(::google::protobuf::Arena* arena) const { MethodOptions* n = new MethodOptions; if (arena != NULL) { @@ -12601,12 +11913,13 @@ MethodOptions* MethodOptions::New(::google::protobuf::Arena* arena) const { void MethodOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MethodOptions) _extensions_.Clear(); - deprecated_ = false; uninterpreted_option_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 3u) { + ::memset(&deprecated_, 0, reinterpret_cast<char*>(&idempotency_level_) - + reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool MethodOptions::MergePartialFromCodedStream( @@ -12615,13 +11928,13 @@ bool MethodOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.MethodOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool deprecated = 33 [default = false]; case 33: { - if (tag == 264) { + if (tag == 264u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -12629,24 +11942,37 @@ bool MethodOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; + break; + } + + // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + case 34: { + if (tag == 272u) { + int value; + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( + input, &value))); + if (::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(value)) { + set_idempotency_level(static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(value)); + } else { + mutable_unknown_fields()->AddVarint(34, value); + } + } else { + goto handle_unusual; + } break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -12685,6 +12011,12 @@ void MethodOptions::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(33, this->deprecated(), output); } + // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + if (has_idempotency_level()) { + ::google::protobuf::internal::WireFormatLite::WriteEnum( + 34, this->idempotency_level(), output); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( @@ -12711,6 +12043,12 @@ void MethodOptions::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(33, this->deprecated(), target); } + // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + if (has_idempotency_level()) { + target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( + 34, this->idempotency_level(), target); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: @@ -12734,11 +12072,13 @@ size_t MethodOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodOptions) size_t total_size = 0; - // optional bool deprecated = 33 [default = false]; - if (has_deprecated()) { - total_size += 2 + 1; - } + total_size += _extensions_.ByteSize(); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { unsigned int count = this->uninterpreted_option_size(); @@ -12750,12 +12090,18 @@ size_t MethodOptions::ByteSizeLong() const { } } - total_size += _extensions_.ByteSize(); + if (_has_bits_[0 / 32] & 3u) { + // optional bool deprecated = 33 [default = false]; + if (has_deprecated()) { + total_size += 2 + 1; + } + + // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + if (has_idempotency_level()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->idempotency_level()); + } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -12766,7 +12112,7 @@ size_t MethodOptions::ByteSizeLong() const { void MethodOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const MethodOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const MethodOptions>( &from); @@ -12775,31 +12121,23 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void MethodOptions::MergeFrom(const MethodOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodOptions) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void MethodOptions::UnsafeMergeFrom(const MethodOptions& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _extensions_.MergeFrom(from._extensions_); + _internal_metadata_.MergeFrom(from._internal_metadata_); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 3u) { if (from.has_deprecated()) { set_deprecated(from.deprecated()); } - } - _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + if (from.has_idempotency_level()) { + set_idempotency_level(from.idempotency_level()); + } } } @@ -12814,16 +12152,15 @@ void MethodOptions::CopyFrom(const MethodOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool MethodOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -12832,8 +12169,9 @@ void MethodOptions::Swap(MethodOptions* other) { InternalSwap(other); } void MethodOptions::InternalSwap(MethodOptions* other) { - std::swap(deprecated_, other->deprecated_); uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); + std::swap(deprecated_, other->deprecated_); + std::swap(idempotency_level_, other->idempotency_level_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -12842,10 +12180,7 @@ void MethodOptions::InternalSwap(MethodOptions* other) { ::google::protobuf::Metadata MethodOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = MethodOptions_descriptor_; - metadata.reflection = MethodOptions_reflection_; - return metadata; + return file_level_metadata[18]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -12875,6 +12210,31 @@ void MethodOptions::set_deprecated(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.deprecated) } +// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; +bool MethodOptions::has_idempotency_level() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void MethodOptions::set_has_idempotency_level() { + _has_bits_[0] |= 0x00000002u; +} +void MethodOptions::clear_has_idempotency_level() { + _has_bits_[0] &= ~0x00000002u; +} +void MethodOptions::clear_idempotency_level() { + idempotency_level_ = 0; + clear_has_idempotency_level(); +} +::google::protobuf::MethodOptions_IdempotencyLevel MethodOptions::idempotency_level() const { + // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.idempotency_level) + return static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(idempotency_level_); +} +void MethodOptions::set_idempotency_level(::google::protobuf::MethodOptions_IdempotencyLevel value) { + assert(::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(value)); + set_has_idempotency_level(); + idempotency_level_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.idempotency_level) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int MethodOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); @@ -12905,9 +12265,6 @@ MethodOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const MethodOptions* MethodOptions::internal_default_instance() { - return &MethodOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -12919,19 +12276,23 @@ 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(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption.NamePart) } - -void UninterpretedOption_NamePart::InitAsDefaultInstance() { -} - UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_part_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name_part()) { + name_part_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_part_); + } + is_extension_ = from.is_extension_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart) } @@ -12957,7 +12318,7 @@ void UninterpretedOption_NamePart::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* UninterpretedOption_NamePart::descriptor() { protobuf_AssignDescriptorsOnce(); - return UninterpretedOption_NamePart_descriptor_; + return file_level_metadata[19].descriptor; } const UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instance() { @@ -12965,8 +12326,6 @@ const UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instan return *internal_default_instance(); } -::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; if (arena != NULL) { @@ -12977,16 +12336,13 @@ UninterpretedOption_NamePart* UninterpretedOption_NamePart::New(::google::protob void UninterpretedOption_NamePart::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption.NamePart) - if (_has_bits_[0 / 32] & 3u) { - if (has_name_part()) { - name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - } - is_extension_ = false; + if (has_name_part()) { + GOOGLE_DCHECK(!name_part_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_part_.UnsafeRawStringPointer())->clear(); } + is_extension_ = false; _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool UninterpretedOption_NamePart::MergePartialFromCodedStream( @@ -12995,13 +12351,13 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.UninterpretedOption.NamePart) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // required string name_part = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name_part())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13011,14 +12367,12 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_is_extension; break; } // required bool is_extension = 2; case 2: { - if (tag == 16) { - parse_is_extension: + if (tag == 16u) { set_has_is_extension(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -13026,7 +12380,6 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -13127,6 +12480,11 @@ size_t UninterpretedOption_NamePart::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption.NamePart) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. // required string name_part = 1; total_size += 1 + @@ -13139,11 +12497,6 @@ size_t UninterpretedOption_NamePart::ByteSizeLong() const { } else { total_size += RequiredFieldsByteSizeFallback(); } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -13153,7 +12506,7 @@ size_t UninterpretedOption_NamePart::ByteSizeLong() const { 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)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const UninterpretedOption_NamePart* source = ::google::protobuf::internal::DynamicCastToGenerated<const UninterpretedOption_NamePart>( &from); @@ -13162,22 +12515,15 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart) - 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))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 3u) { if (from.has_name_part()) { set_has_name_part(); name_part_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_part_); @@ -13186,10 +12532,6 @@ void UninterpretedOption_NamePart::UnsafeMergeFrom(const UninterpretedOption_Nam set_is_extension(from.is_extension()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void UninterpretedOption_NamePart::CopyFrom(const ::google::protobuf::Message& from) { @@ -13203,12 +12545,11 @@ void UninterpretedOption_NamePart::CopyFrom(const UninterpretedOption_NamePart& // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption.NamePart) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool UninterpretedOption_NamePart::IsInitialized() const { if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false; - return true; } @@ -13226,14 +12567,93 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot ::google::protobuf::Metadata UninterpretedOption_NamePart::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = UninterpretedOption_NamePart_descriptor_; - metadata.reflection = UninterpretedOption_NamePart_reflection_; - return metadata; + return file_level_metadata[19]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// UninterpretedOption_NamePart + +// required string name_part = 1; +bool UninterpretedOption_NamePart::has_name_part() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void UninterpretedOption_NamePart::set_has_name_part() { + _has_bits_[0] |= 0x00000001u; +} +void UninterpretedOption_NamePart::clear_has_name_part() { + _has_bits_[0] &= ~0x00000001u; +} +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 { + // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part) + return name_part_.GetNoArena(); +} +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) { + 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) { + 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() { + 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() { + // @@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) { + if (name_part != NULL) { + set_has_name_part(); + } else { + clear_has_name_part(); + } + name_part_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_part); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part) +} + +// required bool is_extension = 2; +bool UninterpretedOption_NamePart::has_is_extension() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void UninterpretedOption_NamePart::set_has_is_extension() { + _has_bits_[0] |= 0x00000002u; +} +void UninterpretedOption_NamePart::clear_has_is_extension() { + _has_bits_[0] &= ~0x00000002u; +} +void UninterpretedOption_NamePart::clear_is_extension() { + is_extension_ = false; + clear_has_is_extension(); +} +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) { + set_has_is_extension(); + is_extension_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension) } +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS -// ------------------------------------------------------------------- +// =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int UninterpretedOption::kNameFieldNumber; @@ -13247,19 +12667,34 @@ const int UninterpretedOption::kAggregateValueFieldNumber; UninterpretedOption::UninterpretedOption() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption) } - -void UninterpretedOption::InitAsDefaultInstance() { -} - UninterpretedOption::UninterpretedOption(const UninterpretedOption& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + name_(from.name_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + identifier_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_identifier_value()) { + identifier_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.identifier_value_); + } + string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_string_value()) { + string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_); + } + aggregate_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_aggregate_value()) { + aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_); + } + ::memcpy(&positive_int_value_, &from.positive_int_value_, + reinterpret_cast<char*>(&double_value_) - + reinterpret_cast<char*>(&positive_int_value_) + sizeof(double_value_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption) } @@ -13290,7 +12725,7 @@ void UninterpretedOption::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* UninterpretedOption::descriptor() { protobuf_AssignDescriptorsOnce(); - return UninterpretedOption_descriptor_; + return file_level_metadata[20].descriptor; } const UninterpretedOption& UninterpretedOption::default_instance() { @@ -13298,8 +12733,6 @@ const UninterpretedOption& UninterpretedOption::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> UninterpretedOption_default_instance_; - UninterpretedOption* UninterpretedOption::New(::google::protobuf::Arena* arena) const { UninterpretedOption* n = new UninterpretedOption; if (arena != NULL) { @@ -13310,43 +12743,27 @@ UninterpretedOption* UninterpretedOption::New(::google::protobuf::Arena* arena) void UninterpretedOption::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(UninterpretedOption, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<UninterpretedOption*>(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] & 126u) { - ZR_(positive_int_value_, double_value_); + name_.Clear(); + if (_has_bits_[0 / 32] & 7u) { if (has_identifier_value()) { - identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!identifier_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*identifier_value_.UnsafeRawStringPointer())->clear(); } if (has_string_value()) { - string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!string_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*string_value_.UnsafeRawStringPointer())->clear(); } if (has_aggregate_value()) { - aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!aggregate_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*aggregate_value_.UnsafeRawStringPointer())->clear(); } } - -#undef ZR_HELPER_ -#undef ZR_ - - name_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 56u) { + ::memset(&positive_int_value_, 0, reinterpret_cast<char*>(&double_value_) - + reinterpret_cast<char*>(&positive_int_value_) + sizeof(double_value_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool UninterpretedOption::MergePartialFromCodedStream( @@ -13355,30 +12772,26 @@ bool UninterpretedOption::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.UninterpretedOption) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; case 2: { - if (tag == 18) { + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_name: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_name())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_name; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(26)) goto parse_identifier_value; break; } // optional string identifier_value = 3; case 3: { - if (tag == 26) { - parse_identifier_value: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_identifier_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13388,14 +12801,12 @@ bool UninterpretedOption::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(32)) goto parse_positive_int_value; break; } // optional uint64 positive_int_value = 4; case 4: { - if (tag == 32) { - parse_positive_int_value: + if (tag == 32u) { set_has_positive_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( @@ -13403,14 +12814,12 @@ bool UninterpretedOption::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(40)) goto parse_negative_int_value; break; } // optional int64 negative_int_value = 5; case 5: { - if (tag == 40) { - parse_negative_int_value: + if (tag == 40u) { set_has_negative_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -13418,14 +12827,12 @@ bool UninterpretedOption::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(49)) goto parse_double_value; break; } // optional double double_value = 6; case 6: { - if (tag == 49) { - parse_double_value: + if (tag == 49u) { set_has_double_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -13433,27 +12840,23 @@ bool UninterpretedOption::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(58)) goto parse_string_value; break; } // optional bytes string_value = 7; case 7: { - if (tag == 58) { - parse_string_value: + if (tag == 58u) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_string_value())); } else { goto handle_unusual; } - if (input->ExpectTag(66)) goto parse_aggregate_value; break; } // optional string aggregate_value = 8; case 8: { - if (tag == 66) { - parse_aggregate_value: + if (tag == 66u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_aggregate_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13463,7 +12866,6 @@ bool UninterpretedOption::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -13613,7 +13015,23 @@ size_t UninterpretedOption::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption) size_t total_size = 0; - if (_has_bits_[1 / 32] & 126u) { + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; + { + 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 (_has_bits_[0 / 32] & 63u) { // optional string identifier_value = 3; if (has_identifier_value()) { total_size += 1 + @@ -13621,6 +13039,20 @@ size_t UninterpretedOption::ByteSizeLong() const { this->identifier_value()); } + // optional bytes string_value = 7; + if (has_string_value()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::BytesSize( + this->string_value()); + } + + // optional string aggregate_value = 8; + if (has_aggregate_value()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->aggregate_value()); + } + // optional uint64 positive_int_value = 4; if (has_positive_int_value()) { total_size += 1 + @@ -13640,36 +13072,6 @@ size_t UninterpretedOption::ByteSizeLong() const { total_size += 1 + 8; } - // optional bytes string_value = 7; - if (has_string_value()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::BytesSize( - this->string_value()); - } - - // optional string aggregate_value = 8; - if (has_aggregate_value()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->aggregate_value()); - } - - } - // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - { - 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()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -13680,7 +13082,7 @@ size_t UninterpretedOption::ByteSizeLong() const { void UninterpretedOption::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UninterpretedOption) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const UninterpretedOption* source = ::google::protobuf::internal::DynamicCastToGenerated<const UninterpretedOption>( &from); @@ -13689,27 +13091,28 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void UninterpretedOption::MergeFrom(const UninterpretedOption& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void UninterpretedOption::UnsafeMergeFrom(const UninterpretedOption& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); name_.MergeFrom(from.name_); - if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) { + if (from._has_bits_[0 / 32] & 63u) { if (from.has_identifier_value()) { set_has_identifier_value(); identifier_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.identifier_value_); } + if (from.has_string_value()) { + set_has_string_value(); + string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_); + } + if (from.has_aggregate_value()) { + set_has_aggregate_value(); + aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_); + } if (from.has_positive_int_value()) { set_positive_int_value(from.positive_int_value()); } @@ -13719,18 +13122,6 @@ void UninterpretedOption::UnsafeMergeFrom(const UninterpretedOption& from) { if (from.has_double_value()) { set_double_value(from.double_value()); } - if (from.has_string_value()) { - set_has_string_value(); - string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_); - } - if (from.has_aggregate_value()) { - set_has_aggregate_value(); - aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_); - } - } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); } } @@ -13745,11 +13136,10 @@ void UninterpretedOption::CopyFrom(const UninterpretedOption& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool UninterpretedOption::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->name())) return false; return true; } @@ -13761,11 +13151,11 @@ void UninterpretedOption::Swap(UninterpretedOption* other) { void UninterpretedOption::InternalSwap(UninterpretedOption* other) { name_.UnsafeArenaSwap(&other->name_); identifier_value_.Swap(&other->identifier_value_); + string_value_.Swap(&other->string_value_); + aggregate_value_.Swap(&other->aggregate_value_); std::swap(positive_int_value_, other->positive_int_value_); std::swap(negative_int_value_, other->negative_int_value_); std::swap(double_value_, other->double_value_); - string_value_.Swap(&other->string_value_); - aggregate_value_.Swap(&other->aggregate_value_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -13773,98 +13163,10 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) { ::google::protobuf::Metadata UninterpretedOption::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = UninterpretedOption_descriptor_; - metadata.reflection = UninterpretedOption_reflection_; - return metadata; + return file_level_metadata[20]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS -// UninterpretedOption_NamePart - -// required string name_part = 1; -bool UninterpretedOption_NamePart::has_name_part() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void UninterpretedOption_NamePart::set_has_name_part() { - _has_bits_[0] |= 0x00000001u; -} -void UninterpretedOption_NamePart::clear_has_name_part() { - _has_bits_[0] &= ~0x00000001u; -} -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 { - // @@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) { - 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) { - 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) { - 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() { - 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() { - // @@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) { - if (name_part != NULL) { - set_has_name_part(); - } else { - clear_has_name_part(); - } - name_part_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_part); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part) -} - -// required bool is_extension = 2; -bool UninterpretedOption_NamePart::has_is_extension() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void UninterpretedOption_NamePart::set_has_is_extension() { - _has_bits_[0] |= 0x00000002u; -} -void UninterpretedOption_NamePart::clear_has_is_extension() { - _has_bits_[0] &= ~0x00000002u; -} -void UninterpretedOption_NamePart::clear_is_extension() { - is_extension_ = false; - clear_has_is_extension(); -} -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) { - set_has_is_extension(); - is_extension_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension) -} - -inline const UninterpretedOption_NamePart* UninterpretedOption_NamePart::internal_default_instance() { - return &UninterpretedOption_NamePart_default_instance_.get(); -} -// ------------------------------------------------------------------- - // UninterpretedOption // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; @@ -13899,13 +13201,13 @@ UninterpretedOption::name() const { // optional string identifier_value = 3; bool UninterpretedOption::has_identifier_value() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } void UninterpretedOption::set_has_identifier_value() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000001u; } void UninterpretedOption::clear_has_identifier_value() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000001u; } void UninterpretedOption::clear_identifier_value() { identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -13913,7 +13215,7 @@ void UninterpretedOption::clear_identifier_value() { } 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()); + return identifier_value_.GetNoArena(); } void UninterpretedOption::set_identifier_value(const ::std::string& value) { set_has_identifier_value(); @@ -13953,13 +13255,13 @@ void UninterpretedOption::set_allocated_identifier_value(::std::string* identifi // optional uint64 positive_int_value = 4; bool UninterpretedOption::has_positive_int_value() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } void UninterpretedOption::set_has_positive_int_value() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000008u; } void UninterpretedOption::clear_has_positive_int_value() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000008u; } void UninterpretedOption::clear_positive_int_value() { positive_int_value_ = GOOGLE_ULONGLONG(0); @@ -13977,13 +13279,13 @@ void UninterpretedOption::set_positive_int_value(::google::protobuf::uint64 valu // optional int64 negative_int_value = 5; bool UninterpretedOption::has_negative_int_value() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } void UninterpretedOption::set_has_negative_int_value() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000010u; } void UninterpretedOption::clear_has_negative_int_value() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000010u; } void UninterpretedOption::clear_negative_int_value() { negative_int_value_ = GOOGLE_LONGLONG(0); @@ -14001,13 +13303,13 @@ void UninterpretedOption::set_negative_int_value(::google::protobuf::int64 value // optional double double_value = 6; bool UninterpretedOption::has_double_value() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } void UninterpretedOption::set_has_double_value() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000020u; } void UninterpretedOption::clear_has_double_value() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000020u; } void UninterpretedOption::clear_double_value() { double_value_ = 0; @@ -14025,13 +13327,13 @@ void UninterpretedOption::set_double_value(double value) { // optional bytes string_value = 7; bool UninterpretedOption::has_string_value() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void UninterpretedOption::set_has_string_value() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000002u; } void UninterpretedOption::clear_has_string_value() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000002u; } void UninterpretedOption::clear_string_value() { string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -14039,7 +13341,7 @@ void UninterpretedOption::clear_string_value() { } 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()); + return string_value_.GetNoArena(); } void UninterpretedOption::set_string_value(const ::std::string& value) { set_has_string_value(); @@ -14079,13 +13381,13 @@ void UninterpretedOption::set_allocated_string_value(::std::string* string_value // optional string aggregate_value = 8; bool UninterpretedOption::has_aggregate_value() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } void UninterpretedOption::set_has_aggregate_value() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000004u; } void UninterpretedOption::clear_has_aggregate_value() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000004u; } void UninterpretedOption::clear_aggregate_value() { aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -14093,7 +13395,7 @@ void UninterpretedOption::clear_aggregate_value() { } 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()); + return aggregate_value_.GetNoArena(); } void UninterpretedOption::set_aggregate_value(const ::std::string& value) { set_has_aggregate_value(); @@ -14131,9 +13433,6 @@ void UninterpretedOption::set_allocated_aggregate_value(::std::string* aggregate // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value) } -inline const UninterpretedOption* UninterpretedOption::internal_default_instance() { - return &UninterpretedOption_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -14148,19 +13447,29 @@ 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(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo.Location) } - -void SourceCodeInfo_Location::InitAsDefaultInstance() { -} - SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + path_(from.path_), + span_(from.span_), + leading_detached_comments_(from.leading_detached_comments_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + leading_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_leading_comments()) { + leading_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.leading_comments_); + } + trailing_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_trailing_comments()) { + trailing_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.trailing_comments_); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location) } @@ -14187,7 +13496,7 @@ void SourceCodeInfo_Location::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* SourceCodeInfo_Location::descriptor() { protobuf_AssignDescriptorsOnce(); - return SourceCodeInfo_Location_descriptor_; + return file_level_metadata[21].descriptor; } const SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() { @@ -14195,8 +13504,6 @@ const SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() { return *internal_default_instance(); } -::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; if (arena != NULL) { @@ -14207,21 +13514,21 @@ SourceCodeInfo_Location* SourceCodeInfo_Location::New(::google::protobuf::Arena* void SourceCodeInfo_Location::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo.Location) - if (_has_bits_[0 / 32] & 12u) { + path_.Clear(); + span_.Clear(); + leading_detached_comments_.Clear(); + if (_has_bits_[0 / 32] & 3u) { if (has_leading_comments()) { - leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!leading_comments_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*leading_comments_.UnsafeRawStringPointer())->clear(); } if (has_trailing_comments()) { - trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!trailing_comments_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*trailing_comments_.UnsafeRawStringPointer())->clear(); } } - path_.Clear(); - span_.Clear(); - leading_detached_comments_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool SourceCodeInfo_Location::MergePartialFromCodedStream( @@ -14230,49 +13537,45 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo.Location) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated int32 path = 1 [packed = true]; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_path()))); - } else if (tag == 8) { + } else if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 10, input, this->mutable_path()))); + 1, 10u, input, this->mutable_path()))); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_span; break; } // repeated int32 span = 2 [packed = true]; case 2: { - if (tag == 18) { - parse_span: + if (tag == 18u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_span()))); - } else if (tag == 16) { + } else if (tag == 16u) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 18, input, this->mutable_span()))); + 1, 18u, input, this->mutable_span()))); } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_leading_comments; break; } // optional string leading_comments = 3; case 3: { - if (tag == 26) { - parse_leading_comments: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_leading_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -14282,14 +13585,12 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_trailing_comments; break; } // optional string trailing_comments = 4; case 4: { - if (tag == 34) { - parse_trailing_comments: + if (tag == 34u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_trailing_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -14299,14 +13600,12 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_leading_detached_comments; break; } // repeated string leading_detached_comments = 6; case 6: { - if (tag == 50) { - parse_leading_detached_comments: + if (tag == 50u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_leading_detached_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -14317,8 +13616,6 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_leading_detached_comments; - if (input->ExpectAtEnd()) goto success; break; } @@ -14480,21 +13777,10 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo.Location) size_t total_size = 0; - if (_has_bits_[2 / 32] & 12u) { - // optional string leading_comments = 3; - if (has_leading_comments()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->leading_comments()); - } - - // optional string trailing_comments = 4; - if (has_trailing_comments()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->trailing_comments()); - } - + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } // repeated int32 path = 1 [packed = true]; { @@ -14542,10 +13828,21 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { this->leading_detached_comments(i)); } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + if (_has_bits_[0 / 32] & 3u) { + // optional string leading_comments = 3; + if (has_leading_comments()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->leading_comments()); + } + + // optional string trailing_comments = 4; + if (has_trailing_comments()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->trailing_comments()); + } + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -14556,7 +13853,7 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { 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)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const SourceCodeInfo_Location* source = ::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo_Location>( &from); @@ -14565,25 +13862,18 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -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))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + path_.MergeFrom(from.path_); + span_.MergeFrom(from.span_); + leading_detached_comments_.MergeFrom(from.leading_detached_comments_); + if (from._has_bits_[0 / 32] & 3u) { if (from.has_leading_comments()) { set_has_leading_comments(); leading_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.leading_comments_); @@ -14593,10 +13883,6 @@ void SourceCodeInfo_Location::UnsafeMergeFrom(const SourceCodeInfo_Location& fro trailing_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.trailing_comments_); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void SourceCodeInfo_Location::CopyFrom(const ::google::protobuf::Message& from) { @@ -14610,11 +13896,10 @@ 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(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool SourceCodeInfo_Location::IsInitialized() const { - return true; } @@ -14625,9 +13910,9 @@ void SourceCodeInfo_Location::Swap(SourceCodeInfo_Location* other) { void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) { path_.UnsafeArenaSwap(&other->path_); span_.UnsafeArenaSwap(&other->span_); + leading_detached_comments_.UnsafeArenaSwap(&other->leading_detached_comments_); leading_comments_.Swap(&other->leading_comments_); trailing_comments_.Swap(&other->trailing_comments_); - leading_detached_comments_.UnsafeArenaSwap(&other->leading_detached_comments_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -14635,262 +13920,7 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) { ::google::protobuf::Metadata SourceCodeInfo_Location::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = SourceCodeInfo_Location_descriptor_; - metadata.reflection = SourceCodeInfo_Location_reflection_; - return metadata; -} - - -// ------------------------------------------------------------------- - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int SourceCodeInfo::kLocationFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - -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) -} - -void SourceCodeInfo::InitAsDefaultInstance() { -} - -SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from) - : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); - // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo) -} - -void SourceCodeInfo::SharedCtor() { - _cached_size_ = 0; -} - -SourceCodeInfo::~SourceCodeInfo() { - // @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo) - SharedDtor(); -} - -void SourceCodeInfo::SharedDtor() { -} - -void SourceCodeInfo::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* SourceCodeInfo::descriptor() { - protobuf_AssignDescriptorsOnce(); - return SourceCodeInfo_descriptor_; -} - -const SourceCodeInfo& SourceCodeInfo::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); - return *internal_default_instance(); -} - -::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> SourceCodeInfo_default_instance_; - -SourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const { - SourceCodeInfo* n = new SourceCodeInfo; - if (arena != NULL) { - arena->Own(n); - } - return n; -} - -void SourceCodeInfo::Clear() { -// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo) - location_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } -} - -bool SourceCodeInfo::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure - ::google::protobuf::uint32 tag; - // @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo) - for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); - tag = p.first; - if (!p.second) goto handle_unusual; - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - case 1: { - if (tag == 10) { - DO_(input->IncrementRecursionDepth()); - parse_loop_location: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( - input, add_location())); - } else { - goto handle_unusual; - } - if (input->ExpectTag(10)) goto parse_loop_location; - input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; - break; - } - - default: { - handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - goto success; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } -success: - // @@protoc_insertion_point(parse_success:google.protobuf.SourceCodeInfo) - return true; -failure: - // @@protoc_insertion_point(parse_failure:google.protobuf.SourceCodeInfo) - return false; -#undef DO_ -} - -void SourceCodeInfo::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // @@protoc_insertion_point(serialize_start:google.protobuf.SourceCodeInfo) - // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - for (unsigned int i = 0, n = this->location_size(); i < n; i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->location(i), output); - } - - if (_internal_metadata_.have_unknown_fields()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } - // @@protoc_insertion_point(serialize_end:google.protobuf.SourceCodeInfo) -} - -::google::protobuf::uint8* SourceCodeInfo::InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused - // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo) - // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - for (unsigned int i = 0, n = this->location_size(); i < n; i++) { - target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 1, this->location(i), false, target); - } - - if (_internal_metadata_.have_unknown_fields()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo) - return target; -} - -size_t SourceCodeInfo::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo) - size_t total_size = 0; - - // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - { - 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()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _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)) MergeFromFail(__LINE__); - const SourceCodeInfo* source = - ::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo>( - &from); - if (source == NULL) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.SourceCodeInfo) - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo) - UnsafeMergeFrom(*source); - } -} - -void SourceCodeInfo::MergeFrom(const SourceCodeInfo& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo) - 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()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } -} - -void SourceCodeInfo::CopyFrom(const ::google::protobuf::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.SourceCodeInfo) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void SourceCodeInfo::CopyFrom(const SourceCodeInfo& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo) - if (&from == this) return; - Clear(); - UnsafeMergeFrom(from); -} - -bool SourceCodeInfo::IsInitialized() const { - - return true; -} - -void SourceCodeInfo::Swap(SourceCodeInfo* other) { - if (other == this) return; - InternalSwap(other); -} -void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) { - location_.UnsafeArenaSwap(&other->location_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); -} - -::google::protobuf::Metadata SourceCodeInfo::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = SourceCodeInfo_descriptor_; - metadata.reflection = SourceCodeInfo_reflection_; - return metadata; + return file_level_metadata[21]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -14958,13 +13988,13 @@ SourceCodeInfo_Location::mutable_span() { // optional string leading_comments = 3; bool SourceCodeInfo_Location::has_leading_comments() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } void SourceCodeInfo_Location::set_has_leading_comments() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000001u; } void SourceCodeInfo_Location::clear_has_leading_comments() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000001u; } void SourceCodeInfo_Location::clear_leading_comments() { leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -14972,7 +14002,7 @@ void SourceCodeInfo_Location::clear_leading_comments() { } 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()); + return leading_comments_.GetNoArena(); } void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) { set_has_leading_comments(); @@ -15012,13 +14042,13 @@ void SourceCodeInfo_Location::set_allocated_leading_comments(::std::string* lead // optional string trailing_comments = 4; bool SourceCodeInfo_Location::has_trailing_comments() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void SourceCodeInfo_Location::set_has_trailing_comments() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000002u; } void SourceCodeInfo_Location::clear_has_trailing_comments() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000002u; } void SourceCodeInfo_Location::clear_trailing_comments() { trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -15026,7 +14056,7 @@ void SourceCodeInfo_Location::clear_trailing_comments() { } 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()); + return trailing_comments_.GetNoArena(); } void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) { set_has_trailing_comments(); @@ -15119,11 +14149,238 @@ SourceCodeInfo_Location::mutable_leading_detached_comments() { return &leading_detached_comments_; } -inline const SourceCodeInfo_Location* SourceCodeInfo_Location::internal_default_instance() { - return &SourceCodeInfo_Location_default_instance_.get(); +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int SourceCodeInfo::kLocationFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +SourceCodeInfo::SourceCodeInfo() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } + SharedCtor(); + // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo) +} +SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + location_(from.location_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo) +} + +void SourceCodeInfo::SharedCtor() { + _cached_size_ = 0; +} + +SourceCodeInfo::~SourceCodeInfo() { + // @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo) + SharedDtor(); +} + +void SourceCodeInfo::SharedDtor() { +} + +void SourceCodeInfo::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* SourceCodeInfo::descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_metadata[22].descriptor; +} + +const SourceCodeInfo& SourceCodeInfo::default_instance() { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); +} + +SourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const { + SourceCodeInfo* n = new SourceCodeInfo; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void SourceCodeInfo::Clear() { +// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo) + location_.Clear(); + _has_bits_.Clear(); + _internal_metadata_.Clear(); +} + +bool SourceCodeInfo::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // repeated .google.protobuf.SourceCodeInfo.Location location = 1; + case 1: { + if (tag == 10u) { + DO_(input->IncrementRecursionDepth()); + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( + input, add_location())); + } else { + goto handle_unusual; + } + input->UnsafeDecrementRecursionDepth(); + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:google.protobuf.SourceCodeInfo) + return true; +failure: + // @@protoc_insertion_point(parse_failure:google.protobuf.SourceCodeInfo) + return false; +#undef DO_ +} + +void SourceCodeInfo::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:google.protobuf.SourceCodeInfo) + // repeated .google.protobuf.SourceCodeInfo.Location location = 1; + for (unsigned int i = 0, n = this->location_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 1, this->location(i), output); + } + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:google.protobuf.SourceCodeInfo) +} + +::google::protobuf::uint8* SourceCodeInfo::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo) + // repeated .google.protobuf.SourceCodeInfo.Location location = 1; + for (unsigned int i = 0, n = this->location_size(); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 1, this->location(i), false, target); + } + + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo) + return target; +} + +size_t SourceCodeInfo::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo) + size_t total_size = 0; + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.SourceCodeInfo.Location location = 1; + { + 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)); + } + } + + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _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) + GOOGLE_DCHECK_NE(&from, this); + const SourceCodeInfo* source = + ::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo>( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.SourceCodeInfo) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo) + MergeFrom(*source); + } +} + +void SourceCodeInfo::MergeFrom(const SourceCodeInfo& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + location_.MergeFrom(from.location_); } -// ------------------------------------------------------------------- +void SourceCodeInfo::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.SourceCodeInfo) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void SourceCodeInfo::CopyFrom(const SourceCodeInfo& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool SourceCodeInfo::IsInitialized() const { + return true; +} + +void SourceCodeInfo::Swap(SourceCodeInfo* other) { + if (other == this) return; + InternalSwap(other); +} +void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) { + location_.UnsafeArenaSwap(&other->location_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata SourceCodeInfo::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + return file_level_metadata[22]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS // SourceCodeInfo // repeated .google.protobuf.SourceCodeInfo.Location location = 1; @@ -15156,9 +14413,6 @@ SourceCodeInfo::location() const { return location_; } -inline const SourceCodeInfo* SourceCodeInfo::internal_default_instance() { - return &SourceCodeInfo_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -15172,19 +14426,26 @@ 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(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo.Annotation) } - -void GeneratedCodeInfo_Annotation::InitAsDefaultInstance() { -} - GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + path_(from.path_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + source_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_source_file()) { + source_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_file_); + } + ::memcpy(&begin_, &from.begin_, + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&begin_) + sizeof(end_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo.Annotation) } @@ -15211,7 +14472,7 @@ void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* GeneratedCodeInfo_Annotation::descriptor() { protobuf_AssignDescriptorsOnce(); - return GeneratedCodeInfo_Annotation_descriptor_; + return file_level_metadata[23].descriptor; } const GeneratedCodeInfo_Annotation& GeneratedCodeInfo_Annotation::default_instance() { @@ -15219,8 +14480,6 @@ const GeneratedCodeInfo_Annotation& GeneratedCodeInfo_Annotation::default_instan return *internal_default_instance(); } -::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; if (arena != NULL) { @@ -15231,37 +14490,17 @@ GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::New(::google::protob void GeneratedCodeInfo_Annotation::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo.Annotation) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(GeneratedCodeInfo_Annotation, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<GeneratedCodeInfo_Annotation*>(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] & 14u) { - ZR_(begin_, end_); - if (has_source_file()) { - source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - } - } - -#undef ZR_HELPER_ -#undef ZR_ - path_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (has_source_file()) { + GOOGLE_DCHECK(!source_file_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*source_file_.UnsafeRawStringPointer())->clear(); + } + if (_has_bits_[0 / 32] & 6u) { + ::memset(&begin_, 0, reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&begin_) + sizeof(end_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( @@ -15270,31 +14509,29 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.GeneratedCodeInfo.Annotation) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated int32 path = 1 [packed = true]; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_path()))); - } else if (tag == 8) { + } else if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 10, input, this->mutable_path()))); + 1, 10u, input, this->mutable_path()))); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_source_file; break; } // optional string source_file = 2; case 2: { - if (tag == 18) { - parse_source_file: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_source_file())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -15304,14 +14541,12 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_begin; break; } // optional int32 begin = 3; case 3: { - if (tag == 24) { - parse_begin: + if (tag == 24u) { set_has_begin(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -15319,14 +14554,12 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(32)) goto parse_end; break; } // optional int32 end = 4; case 4: { - if (tag == 32) { - parse_end: + if (tag == 32u) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -15334,7 +14567,6 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -15451,7 +14683,31 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo.Annotation) size_t total_size = 0; - if (_has_bits_[1 / 32] & 14u) { + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated int32 path = 1 [packed = true]; + { + 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)); + } + if (data_size > 0) { + 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_ = cached_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + total_size += data_size; + } + + if (_has_bits_[0 / 32] & 7u) { // optional string source_file = 2; if (has_source_file()) { total_size += 1 + @@ -15474,30 +14730,6 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const { } } - // repeated int32 path = 1 [packed = true]; - { - 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)); - } - if (data_size > 0) { - 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_ = cached_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - total_size += data_size; - } - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -15507,7 +14739,7 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const { 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)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const GeneratedCodeInfo_Annotation* source = ::google::protobuf::internal::DynamicCastToGenerated<const GeneratedCodeInfo_Annotation>( &from); @@ -15516,23 +14748,16 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void GeneratedCodeInfo_Annotation::MergeFrom(const GeneratedCodeInfo_Annotation& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -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))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + path_.MergeFrom(from.path_); + if (from._has_bits_[0 / 32] & 7u) { if (from.has_source_file()) { set_has_source_file(); source_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_file_); @@ -15544,10 +14769,6 @@ void GeneratedCodeInfo_Annotation::UnsafeMergeFrom(const GeneratedCodeInfo_Annot set_end(from.end()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void GeneratedCodeInfo_Annotation::CopyFrom(const ::google::protobuf::Message& from) { @@ -15561,11 +14782,10 @@ void GeneratedCodeInfo_Annotation::CopyFrom(const GeneratedCodeInfo_Annotation& // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo.Annotation) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool GeneratedCodeInfo_Annotation::IsInitialized() const { - return true; } @@ -15585,14 +14805,147 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot ::google::protobuf::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = GeneratedCodeInfo_Annotation_descriptor_; - metadata.reflection = GeneratedCodeInfo_Annotation_reflection_; - return metadata; + return file_level_metadata[23]; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// GeneratedCodeInfo_Annotation -// ------------------------------------------------------------------- +// repeated int32 path = 1 [packed = true]; +int GeneratedCodeInfo_Annotation::path_size() const { + return path_.size(); +} +void GeneratedCodeInfo_Annotation::clear_path() { + path_.Clear(); +} +::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) { + path_.Set(index, value); + // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path) +} +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 >& +GeneratedCodeInfo_Annotation::path() const { + // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.Annotation.path) + return path_; +} +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +GeneratedCodeInfo_Annotation::mutable_path() { + // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.Annotation.path) + return &path_; +} + +// optional string source_file = 2; +bool GeneratedCodeInfo_Annotation::has_source_file() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void GeneratedCodeInfo_Annotation::set_has_source_file() { + _has_bits_[0] |= 0x00000001u; +} +void GeneratedCodeInfo_Annotation::clear_has_source_file() { + _has_bits_[0] &= ~0x00000001u; +} +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 { + // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file) + return source_file_.GetNoArena(); +} +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) { + 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) { + 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() { + 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() { + // @@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) { + if (source_file != NULL) { + set_has_source_file(); + } else { + clear_has_source_file(); + } + source_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_file); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file) +} + +// optional int32 begin = 3; +bool GeneratedCodeInfo_Annotation::has_begin() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void GeneratedCodeInfo_Annotation::set_has_begin() { + _has_bits_[0] |= 0x00000002u; +} +void GeneratedCodeInfo_Annotation::clear_has_begin() { + _has_bits_[0] &= ~0x00000002u; +} +void GeneratedCodeInfo_Annotation::clear_begin() { + begin_ = 0; + clear_has_begin(); +} +::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) { + set_has_begin(); + begin_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.begin) +} + +// optional int32 end = 4; +bool GeneratedCodeInfo_Annotation::has_end() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void GeneratedCodeInfo_Annotation::set_has_end() { + _has_bits_[0] |= 0x00000004u; +} +void GeneratedCodeInfo_Annotation::clear_has_end() { + _has_bits_[0] &= ~0x00000004u; +} +void GeneratedCodeInfo_Annotation::clear_end() { + end_ = 0; + clear_has_end(); +} +::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) { + set_has_end(); + end_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end) +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int GeneratedCodeInfo::kAnnotationFieldNumber; @@ -15600,19 +14953,19 @@ const int GeneratedCodeInfo::kAnnotationFieldNumber; GeneratedCodeInfo::GeneratedCodeInfo() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo) } - -void GeneratedCodeInfo::InitAsDefaultInstance() { -} - GeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + annotation_(from.annotation_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo) } @@ -15635,7 +14988,7 @@ void GeneratedCodeInfo::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* GeneratedCodeInfo::descriptor() { protobuf_AssignDescriptorsOnce(); - return GeneratedCodeInfo_descriptor_; + return file_level_metadata[24].descriptor; } const GeneratedCodeInfo& GeneratedCodeInfo::default_instance() { @@ -15643,8 +14996,6 @@ const GeneratedCodeInfo& GeneratedCodeInfo::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> GeneratedCodeInfo_default_instance_; - GeneratedCodeInfo* GeneratedCodeInfo::New(::google::protobuf::Arena* arena) const { GeneratedCodeInfo* n = new GeneratedCodeInfo; if (arena != NULL) { @@ -15657,9 +15008,7 @@ void GeneratedCodeInfo::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo) annotation_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool GeneratedCodeInfo::MergePartialFromCodedStream( @@ -15668,23 +15017,20 @@ bool GeneratedCodeInfo::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.GeneratedCodeInfo) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(input->IncrementRecursionDepth()); - parse_loop_annotation: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_annotation())); } else { goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_loop_annotation; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -15749,6 +15095,11 @@ size_t GeneratedCodeInfo::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; { unsigned int count = this->annotation_size(); @@ -15760,11 +15111,6 @@ size_t GeneratedCodeInfo::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -15774,7 +15120,7 @@ size_t GeneratedCodeInfo::ByteSizeLong() const { void GeneratedCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.GeneratedCodeInfo) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const GeneratedCodeInfo* source = ::google::protobuf::internal::DynamicCastToGenerated<const GeneratedCodeInfo>( &from); @@ -15783,26 +15129,15 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void GeneratedCodeInfo::MergeFrom(const GeneratedCodeInfo& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void GeneratedCodeInfo::UnsafeMergeFrom(const GeneratedCodeInfo& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); annotation_.MergeFrom(from.annotation_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void GeneratedCodeInfo::CopyFrom(const ::google::protobuf::Message& from) { @@ -15816,11 +15151,10 @@ void GeneratedCodeInfo::CopyFrom(const GeneratedCodeInfo& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool GeneratedCodeInfo::IsInitialized() const { - return true; } @@ -15837,152 +15171,10 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) { ::google::protobuf::Metadata GeneratedCodeInfo::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = GeneratedCodeInfo_descriptor_; - metadata.reflection = GeneratedCodeInfo_reflection_; - return metadata; + return file_level_metadata[24]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS -// GeneratedCodeInfo_Annotation - -// repeated int32 path = 1 [packed = true]; -int GeneratedCodeInfo_Annotation::path_size() const { - return path_.size(); -} -void GeneratedCodeInfo_Annotation::clear_path() { - path_.Clear(); -} -::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) { - path_.Set(index, value); - // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path) -} -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 >& -GeneratedCodeInfo_Annotation::path() const { - // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.Annotation.path) - return path_; -} -::google::protobuf::RepeatedField< ::google::protobuf::int32 >* -GeneratedCodeInfo_Annotation::mutable_path() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.Annotation.path) - return &path_; -} - -// optional string source_file = 2; -bool GeneratedCodeInfo_Annotation::has_source_file() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void GeneratedCodeInfo_Annotation::set_has_source_file() { - _has_bits_[0] |= 0x00000002u; -} -void GeneratedCodeInfo_Annotation::clear_has_source_file() { - _has_bits_[0] &= ~0x00000002u; -} -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 { - // @@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) { - 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) { - 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) { - 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() { - 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() { - // @@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) { - if (source_file != NULL) { - set_has_source_file(); - } else { - clear_has_source_file(); - } - source_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_file); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file) -} - -// optional int32 begin = 3; -bool GeneratedCodeInfo_Annotation::has_begin() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void GeneratedCodeInfo_Annotation::set_has_begin() { - _has_bits_[0] |= 0x00000004u; -} -void GeneratedCodeInfo_Annotation::clear_has_begin() { - _has_bits_[0] &= ~0x00000004u; -} -void GeneratedCodeInfo_Annotation::clear_begin() { - begin_ = 0; - clear_has_begin(); -} -::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) { - set_has_begin(); - begin_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.begin) -} - -// optional int32 end = 4; -bool GeneratedCodeInfo_Annotation::has_end() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -void GeneratedCodeInfo_Annotation::set_has_end() { - _has_bits_[0] |= 0x00000008u; -} -void GeneratedCodeInfo_Annotation::clear_has_end() { - _has_bits_[0] &= ~0x00000008u; -} -void GeneratedCodeInfo_Annotation::clear_end() { - end_ = 0; - clear_has_end(); -} -::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) { - set_has_end(); - end_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end) -} - -inline const GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::internal_default_instance() { - return &GeneratedCodeInfo_Annotation_default_instance_.get(); -} -// ------------------------------------------------------------------- - // GeneratedCodeInfo // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; @@ -16015,9 +15207,6 @@ GeneratedCodeInfo::annotation() const { return annotation_; } -inline const GeneratedCodeInfo* GeneratedCodeInfo::internal_default_instance() { - return &GeneratedCodeInfo_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 257dd0f7..7c3de2d2 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -24,46 +24,97 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/generated_enum_reflection.h> #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) - namespace google { 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(); - class DescriptorProto; +class DescriptorProtoDefaultTypeInternal; +extern DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; class DescriptorProto_ExtensionRange; +class DescriptorProto_ExtensionRangeDefaultTypeInternal; +extern DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; class DescriptorProto_ReservedRange; +class DescriptorProto_ReservedRangeDefaultTypeInternal; +extern DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; class EnumDescriptorProto; +class EnumDescriptorProtoDefaultTypeInternal; +extern EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; class EnumOptions; +class EnumOptionsDefaultTypeInternal; +extern EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; class EnumValueDescriptorProto; +class EnumValueDescriptorProtoDefaultTypeInternal; +extern EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; class EnumValueOptions; +class EnumValueOptionsDefaultTypeInternal; +extern EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; class FieldDescriptorProto; +class FieldDescriptorProtoDefaultTypeInternal; +extern FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; class FieldOptions; +class FieldOptionsDefaultTypeInternal; +extern FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; class FileDescriptorProto; +class FileDescriptorProtoDefaultTypeInternal; +extern FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; class FileDescriptorSet; +class FileDescriptorSetDefaultTypeInternal; +extern FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; class FileOptions; +class FileOptionsDefaultTypeInternal; +extern FileOptionsDefaultTypeInternal _FileOptions_default_instance_; class GeneratedCodeInfo; +class GeneratedCodeInfoDefaultTypeInternal; +extern GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; class GeneratedCodeInfo_Annotation; +class GeneratedCodeInfo_AnnotationDefaultTypeInternal; +extern GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; class MessageOptions; +class MessageOptionsDefaultTypeInternal; +extern MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; class MethodDescriptorProto; +class MethodDescriptorProtoDefaultTypeInternal; +extern MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; class MethodOptions; +class MethodOptionsDefaultTypeInternal; +extern MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; class OneofDescriptorProto; +class OneofDescriptorProtoDefaultTypeInternal; +extern OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; class OneofOptions; +class OneofOptionsDefaultTypeInternal; +extern OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; class ServiceDescriptorProto; +class ServiceDescriptorProtoDefaultTypeInternal; +extern ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; class ServiceOptions; +class ServiceOptionsDefaultTypeInternal; +extern ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; class SourceCodeInfo; +class SourceCodeInfoDefaultTypeInternal; +extern SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; class SourceCodeInfo_Location; +class SourceCodeInfo_LocationDefaultTypeInternal; +extern SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; class UninterpretedOption; +class UninterpretedOptionDefaultTypeInternal; +extern UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; class UninterpretedOption_NamePart; +class UninterpretedOption_NamePartDefaultTypeInternal; +extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; +} // namespace protobuf +} // namespace google + +namespace google { +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(); enum FieldDescriptorProto_Type { FieldDescriptorProto_Type_TYPE_DOUBLE = 1, @@ -180,6 +231,26 @@ inline bool FieldOptions_JSType_Parse( return ::google::protobuf::internal::ParseNamedEnum<FieldOptions_JSType>( FieldOptions_JSType_descriptor(), name, value); } +enum MethodOptions_IdempotencyLevel { + MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN = 0, + MethodOptions_IdempotencyLevel_NO_SIDE_EFFECTS = 1, + MethodOptions_IdempotencyLevel_IDEMPOTENT = 2 +}; +LIBPROTOBUF_EXPORT bool MethodOptions_IdempotencyLevel_IsValid(int value); +const MethodOptions_IdempotencyLevel MethodOptions_IdempotencyLevel_IdempotencyLevel_MIN = MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN; +const MethodOptions_IdempotencyLevel MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX = MethodOptions_IdempotencyLevel_IDEMPOTENT; +const int MethodOptions_IdempotencyLevel_IdempotencyLevel_ARRAYSIZE = MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX + 1; + +LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor(); +inline const ::std::string& MethodOptions_IdempotencyLevel_Name(MethodOptions_IdempotencyLevel value) { + return ::google::protobuf::internal::NameOfEnum( + MethodOptions_IdempotencyLevel_descriptor(), value); +} +inline bool MethodOptions_IdempotencyLevel_Parse( + const ::std::string& name, MethodOptions_IdempotencyLevel* value) { + return ::google::protobuf::internal::ParseNamedEnum<MethodOptions_IdempotencyLevel>( + MethodOptions_IdempotencyLevel_descriptor(), name, value); +} // =================================================================== class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorSet) */ { @@ -205,49 +276,52 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message static const ::google::protobuf::Descriptor* descriptor(); static const FileDescriptorSet& default_instance(); - static const FileDescriptorSet* internal_default_instance(); + static inline const FileDescriptorSet* internal_default_instance() { + return reinterpret_cast<const FileDescriptorSet*>( + &_FileDescriptorSet_default_instance_); + } void Swap(FileDescriptorSet* other); // implements Message ---------------------------------------------- - inline FileDescriptorSet* New() const { return New(NULL); } + inline FileDescriptorSet* New() const PROTOBUF_FINAL { return New(NULL); } - FileDescriptorSet* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FileDescriptorSet* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FileDescriptorSet& from); void MergeFrom(const FileDescriptorSet& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FileDescriptorSet* other); - void UnsafeMergeFrom(const FileDescriptorSet& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -274,13 +348,10 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > file_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> FileDescriptorSet_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorProto) */ { @@ -306,49 +377,52 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const FileDescriptorProto& default_instance(); - static const FileDescriptorProto* internal_default_instance(); + static inline const FileDescriptorProto* internal_default_instance() { + return reinterpret_cast<const FileDescriptorProto*>( + &_FileDescriptorProto_default_instance_); + } void Swap(FileDescriptorProto* other); // implements Message ---------------------------------------------- - inline FileDescriptorProto* New() const { return New(NULL); } + inline FileDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - FileDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FileDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FileDescriptorProto& from); void MergeFrom(const FileDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FileDescriptorProto* other); - void UnsafeMergeFrom(const FileDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -498,16 +572,16 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag // @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_package(); - inline void clear_has_package(); - inline void set_has_options(); - inline void clear_has_options(); - inline void set_has_source_code_info(); - inline void clear_has_source_code_info(); - inline void set_has_syntax(); - inline void clear_has_syntax(); + void set_has_name(); + void clear_has_name(); + void set_has_package(); + void clear_has_package(); + void set_has_options(); + void clear_has_options(); + void set_has_source_code_info(); + void clear_has_source_code_info(); + void set_has_syntax(); + void clear_has_syntax(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -526,13 +600,10 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag ::google::protobuf::SourceCodeInfo* source_code_info_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> FileDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ExtensionRange) */ { @@ -558,49 +629,52 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto_ExtensionRange& default_instance(); - static const DescriptorProto_ExtensionRange* internal_default_instance(); + static inline const DescriptorProto_ExtensionRange* internal_default_instance() { + return reinterpret_cast<const DescriptorProto_ExtensionRange*>( + &_DescriptorProto_ExtensionRange_default_instance_); + } void Swap(DescriptorProto_ExtensionRange* other); // implements Message ---------------------------------------------- - inline DescriptorProto_ExtensionRange* New() const { return New(NULL); } + inline DescriptorProto_ExtensionRange* New() const PROTOBUF_FINAL { return New(NULL); } - DescriptorProto_ExtensionRange* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + DescriptorProto_ExtensionRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const DescriptorProto_ExtensionRange& from); void MergeFrom(const DescriptorProto_ExtensionRange& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(DescriptorProto_ExtensionRange* other); - void UnsafeMergeFrom(const DescriptorProto_ExtensionRange& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -622,10 +696,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ExtensionRange) private: - inline void set_has_start(); - inline void clear_has_start(); - inline void set_has_end(); - inline void clear_has_end(); + void set_has_start(); + void clear_has_start(); + void set_has_end(); + void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -634,13 +708,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto ::google::protobuf::int32 end_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> DescriptorProto_ExtensionRange_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ReservedRange) */ { @@ -666,49 +737,52 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto_ReservedRange& default_instance(); - static const DescriptorProto_ReservedRange* internal_default_instance(); + static inline const DescriptorProto_ReservedRange* internal_default_instance() { + return reinterpret_cast<const DescriptorProto_ReservedRange*>( + &_DescriptorProto_ReservedRange_default_instance_); + } void Swap(DescriptorProto_ReservedRange* other); // implements Message ---------------------------------------------- - inline DescriptorProto_ReservedRange* New() const { return New(NULL); } + inline DescriptorProto_ReservedRange* New() const PROTOBUF_FINAL { return New(NULL); } - DescriptorProto_ReservedRange* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + DescriptorProto_ReservedRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const DescriptorProto_ReservedRange& from); void MergeFrom(const DescriptorProto_ReservedRange& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(DescriptorProto_ReservedRange* other); - void UnsafeMergeFrom(const DescriptorProto_ReservedRange& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -730,10 +804,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ReservedRange) private: - inline void set_has_start(); - inline void clear_has_start(); - inline void set_has_end(); - inline void clear_has_end(); + void set_has_start(); + void clear_has_start(); + void set_has_end(); + void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -742,13 +816,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob ::google::protobuf::int32 end_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> DescriptorProto_ReservedRange_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto) */ { @@ -774,49 +845,52 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto& default_instance(); - static const DescriptorProto* internal_default_instance(); + static inline const DescriptorProto* internal_default_instance() { + return reinterpret_cast<const DescriptorProto*>( + &_DescriptorProto_default_instance_); + } void Swap(DescriptorProto* other); // implements Message ---------------------------------------------- - inline DescriptorProto* New() const { return New(NULL); } + inline DescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - DescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + DescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const DescriptorProto& from); void MergeFrom(const DescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(DescriptorProto* other); - void UnsafeMergeFrom(const DescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -948,10 +1022,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_options(); - inline void clear_has_options(); + void set_has_name(); + void clear_has_name(); + void set_has_options(); + void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -968,13 +1042,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* ::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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> DescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldDescriptorProto) */ { @@ -1000,49 +1071,52 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa static const ::google::protobuf::Descriptor* descriptor(); static const FieldDescriptorProto& default_instance(); - static const FieldDescriptorProto* internal_default_instance(); + static inline const FieldDescriptorProto* internal_default_instance() { + return reinterpret_cast<const FieldDescriptorProto*>( + &_FieldDescriptorProto_default_instance_); + } void Swap(FieldDescriptorProto* other); // implements Message ---------------------------------------------- - inline FieldDescriptorProto* New() const { return New(NULL); } + inline FieldDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - FieldDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FieldDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FieldDescriptorProto& from); void MergeFrom(const FieldDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FieldDescriptorProto* other); - void UnsafeMergeFrom(const FieldDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -1233,26 +1307,26 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa // @@protoc_insertion_point(class_scope:google.protobuf.FieldDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_number(); - inline void clear_has_number(); - inline void set_has_label(); - inline void clear_has_label(); - inline void set_has_type(); - inline void clear_has_type(); - inline void set_has_type_name(); - inline void clear_has_type_name(); - inline void set_has_extendee(); - inline void clear_has_extendee(); - inline void set_has_default_value(); - inline void clear_has_default_value(); - inline void set_has_oneof_index(); - inline void clear_has_oneof_index(); - inline void set_has_json_name(); - inline void clear_has_json_name(); - inline void set_has_options(); - inline void clear_has_options(); + void set_has_name(); + void clear_has_name(); + void set_has_number(); + void clear_has_number(); + void set_has_label(); + void clear_has_label(); + void set_has_type(); + void clear_has_type(); + void set_has_type_name(); + void clear_has_type_name(); + void set_has_extendee(); + void clear_has_extendee(); + void set_has_default_value(); + void clear_has_default_value(); + void set_has_oneof_index(); + void clear_has_oneof_index(); + void set_has_json_name(); + void clear_has_json_name(); + void set_has_options(); + void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -1269,13 +1343,10 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> FieldDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofDescriptorProto) */ { @@ -1301,49 +1372,52 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa static const ::google::protobuf::Descriptor* descriptor(); static const OneofDescriptorProto& default_instance(); - static const OneofDescriptorProto* internal_default_instance(); + static inline const OneofDescriptorProto* internal_default_instance() { + return reinterpret_cast<const OneofDescriptorProto*>( + &_OneofDescriptorProto_default_instance_); + } void Swap(OneofDescriptorProto* other); // implements Message ---------------------------------------------- - inline OneofDescriptorProto* New() const { return New(NULL); } + inline OneofDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - OneofDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + OneofDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const OneofDescriptorProto& from); void MergeFrom(const OneofDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(OneofDescriptorProto* other); - void UnsafeMergeFrom(const OneofDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -1372,10 +1446,10 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa // @@protoc_insertion_point(class_scope:google.protobuf.OneofDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_options(); - inline void clear_has_options(); + void set_has_name(); + void clear_has_name(); + void set_has_options(); + void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -1384,13 +1458,10 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa ::google::protobuf::OneofOptions* 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> OneofDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto) */ { @@ -1416,49 +1487,52 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const EnumDescriptorProto& default_instance(); - static const EnumDescriptorProto* internal_default_instance(); + static inline const EnumDescriptorProto* internal_default_instance() { + return reinterpret_cast<const EnumDescriptorProto*>( + &_EnumDescriptorProto_default_instance_); + } void Swap(EnumDescriptorProto* other); // implements Message ---------------------------------------------- - inline EnumDescriptorProto* New() const { return New(NULL); } + inline EnumDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - EnumDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + EnumDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumDescriptorProto& from); void MergeFrom(const EnumDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumDescriptorProto* other); - void UnsafeMergeFrom(const EnumDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -1499,10 +1573,10 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag // @@protoc_insertion_point(class_scope:google.protobuf.EnumDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_options(); - inline void clear_has_options(); + void set_has_name(); + void clear_has_name(); + void set_has_options(); + void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -1512,13 +1586,10 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag ::google::protobuf::EnumOptions* 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> EnumDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueDescriptorProto) */ { @@ -1544,49 +1615,52 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M static const ::google::protobuf::Descriptor* descriptor(); static const EnumValueDescriptorProto& default_instance(); - static const EnumValueDescriptorProto* internal_default_instance(); + static inline const EnumValueDescriptorProto* internal_default_instance() { + return reinterpret_cast<const EnumValueDescriptorProto*>( + &_EnumValueDescriptorProto_default_instance_); + } void Swap(EnumValueDescriptorProto* other); // implements Message ---------------------------------------------- - inline EnumValueDescriptorProto* New() const { return New(NULL); } + inline EnumValueDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - EnumValueDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + EnumValueDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumValueDescriptorProto& from); void MergeFrom(const EnumValueDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumValueDescriptorProto* other); - void UnsafeMergeFrom(const EnumValueDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -1622,12 +1696,12 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M // @@protoc_insertion_point(class_scope:google.protobuf.EnumValueDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_number(); - inline void clear_has_number(); - inline void set_has_options(); - inline void clear_has_options(); + void set_has_name(); + void clear_has_name(); + void set_has_number(); + void clear_has_number(); + void set_has_options(); + void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -1637,13 +1711,10 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M ::google::protobuf::int32 number_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> EnumValueDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceDescriptorProto) */ { @@ -1669,49 +1740,52 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes static const ::google::protobuf::Descriptor* descriptor(); static const ServiceDescriptorProto& default_instance(); - static const ServiceDescriptorProto* internal_default_instance(); + static inline const ServiceDescriptorProto* internal_default_instance() { + return reinterpret_cast<const ServiceDescriptorProto*>( + &_ServiceDescriptorProto_default_instance_); + } void Swap(ServiceDescriptorProto* other); // implements Message ---------------------------------------------- - inline ServiceDescriptorProto* New() const { return New(NULL); } + inline ServiceDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - ServiceDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + ServiceDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const ServiceDescriptorProto& from); void MergeFrom(const ServiceDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(ServiceDescriptorProto* other); - void UnsafeMergeFrom(const ServiceDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -1752,10 +1826,10 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes // @@protoc_insertion_point(class_scope:google.protobuf.ServiceDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_options(); - inline void clear_has_options(); + void set_has_name(); + void clear_has_name(); + void set_has_options(); + void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -1765,13 +1839,10 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes ::google::protobuf::ServiceOptions* 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> ServiceDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodDescriptorProto) */ { @@ -1797,49 +1868,52 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess static const ::google::protobuf::Descriptor* descriptor(); static const MethodDescriptorProto& default_instance(); - static const MethodDescriptorProto* internal_default_instance(); + static inline const MethodDescriptorProto* internal_default_instance() { + return reinterpret_cast<const MethodDescriptorProto*>( + &_MethodDescriptorProto_default_instance_); + } void Swap(MethodDescriptorProto* other); // implements Message ---------------------------------------------- - inline MethodDescriptorProto* New() const { return New(NULL); } + inline MethodDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - MethodDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + MethodDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const MethodDescriptorProto& from); void MergeFrom(const MethodDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(MethodDescriptorProto* other); - void UnsafeMergeFrom(const MethodDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -1906,18 +1980,18 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess // @@protoc_insertion_point(class_scope:google.protobuf.MethodDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_input_type(); - inline void clear_has_input_type(); - inline void set_has_output_type(); - inline void clear_has_output_type(); - inline void set_has_options(); - inline void clear_has_options(); - inline void set_has_client_streaming(); - inline void clear_has_client_streaming(); - inline void set_has_server_streaming(); - inline void clear_has_server_streaming(); + void set_has_name(); + void clear_has_name(); + void set_has_input_type(); + void clear_has_input_type(); + void set_has_output_type(); + void clear_has_output_type(); + void set_has_options(); + void clear_has_options(); + void set_has_client_streaming(); + void clear_has_client_streaming(); + void set_has_server_streaming(); + void clear_has_server_streaming(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -1930,13 +2004,10 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess bool server_streaming_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> MethodDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileOptions) */ { @@ -1962,49 +2033,52 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const FileOptions& default_instance(); - static const FileOptions* internal_default_instance(); + static inline const FileOptions* internal_default_instance() { + return reinterpret_cast<const FileOptions*>( + &_FileOptions_default_instance_); + } void Swap(FileOptions* other); // implements Message ---------------------------------------------- - inline FileOptions* New() const { return New(NULL); } + inline FileOptions* New() const PROTOBUF_FINAL { return New(NULL); } - FileOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FileOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FileOptions& from); void MergeFrom(const FileOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FileOptions* other); - void UnsafeMergeFrom(const FileOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -2176,34 +2250,34 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FileOptions) // @@protoc_insertion_point(class_scope:google.protobuf.FileOptions) private: - inline void set_has_java_package(); - inline void clear_has_java_package(); - inline void set_has_java_outer_classname(); - 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(); - inline void clear_has_optimize_for(); - inline void set_has_go_package(); - inline void clear_has_go_package(); - inline void set_has_cc_generic_services(); - inline void clear_has_cc_generic_services(); - inline void set_has_java_generic_services(); - inline void clear_has_java_generic_services(); - inline void set_has_py_generic_services(); - inline void clear_has_py_generic_services(); - inline void set_has_deprecated(); - inline void clear_has_deprecated(); - inline void set_has_cc_enable_arenas(); - inline void clear_has_cc_enable_arenas(); - inline void set_has_objc_class_prefix(); - inline void clear_has_objc_class_prefix(); - inline void set_has_csharp_namespace(); - inline void clear_has_csharp_namespace(); + void set_has_java_package(); + void clear_has_java_package(); + void set_has_java_outer_classname(); + void clear_has_java_outer_classname(); + void set_has_java_multiple_files(); + void clear_has_java_multiple_files(); + void set_has_java_generate_equals_and_hash(); + void clear_has_java_generate_equals_and_hash(); + void set_has_java_string_check_utf8(); + void clear_has_java_string_check_utf8(); + void set_has_optimize_for(); + void clear_has_optimize_for(); + void set_has_go_package(); + void clear_has_go_package(); + void set_has_cc_generic_services(); + void clear_has_cc_generic_services(); + void set_has_java_generic_services(); + void clear_has_java_generic_services(); + void set_has_py_generic_services(); + void clear_has_py_generic_services(); + void set_has_deprecated(); + void clear_has_deprecated(); + void set_has_cc_enable_arenas(); + void clear_has_cc_enable_arenas(); + void set_has_objc_class_prefix(); + void clear_has_objc_class_prefix(); + void set_has_csharp_namespace(); + void clear_has_csharp_namespace(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2227,13 +2301,10 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FileOptions> FileOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MessageOptions) */ { @@ -2259,49 +2330,52 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const MessageOptions& default_instance(); - static const MessageOptions* internal_default_instance(); + static inline const MessageOptions* internal_default_instance() { + return reinterpret_cast<const MessageOptions*>( + &_MessageOptions_default_instance_); + } void Swap(MessageOptions* other); // implements Message ---------------------------------------------- - inline MessageOptions* New() const { return New(NULL); } + inline MessageOptions* New() const PROTOBUF_FINAL { return New(NULL); } - MessageOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + MessageOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const MessageOptions& from); void MergeFrom(const MessageOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(MessageOptions* other); - void UnsafeMergeFrom(const MessageOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -2350,14 +2424,14 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MessageOptions) // @@protoc_insertion_point(class_scope:google.protobuf.MessageOptions) private: - inline void set_has_message_set_wire_format(); - inline void clear_has_message_set_wire_format(); - inline void set_has_no_standard_descriptor_accessor(); - inline void clear_has_no_standard_descriptor_accessor(); - inline void set_has_deprecated(); - inline void clear_has_deprecated(); - inline void set_has_map_entry(); - inline void clear_has_map_entry(); + void set_has_message_set_wire_format(); + void clear_has_message_set_wire_format(); + void set_has_no_standard_descriptor_accessor(); + void clear_has_no_standard_descriptor_accessor(); + void set_has_deprecated(); + void clear_has_deprecated(); + void set_has_map_entry(); + void clear_has_map_entry(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2371,13 +2445,10 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* bool map_entry_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> MessageOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldOptions) */ { @@ -2403,49 +2474,52 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ static const ::google::protobuf::Descriptor* descriptor(); static const FieldOptions& default_instance(); - static const FieldOptions* internal_default_instance(); + static inline const FieldOptions* internal_default_instance() { + return reinterpret_cast<const FieldOptions*>( + &_FieldOptions_default_instance_); + } void Swap(FieldOptions* other); // implements Message ---------------------------------------------- - inline FieldOptions* New() const { return New(NULL); } + inline FieldOptions* New() const PROTOBUF_FINAL { return New(NULL); } - FieldOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FieldOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FieldOptions& from); void MergeFrom(const FieldOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FieldOptions* other); - void UnsafeMergeFrom(const FieldOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -2564,18 +2638,18 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FieldOptions) // @@protoc_insertion_point(class_scope:google.protobuf.FieldOptions) private: - inline void set_has_ctype(); - inline void clear_has_ctype(); - inline void set_has_packed(); - inline void clear_has_packed(); - inline void set_has_jstype(); - inline void clear_has_jstype(); - inline void set_has_lazy(); - inline void clear_has_lazy(); - inline void set_has_deprecated(); - inline void clear_has_deprecated(); - inline void set_has_weak(); - inline void clear_has_weak(); + void set_has_ctype(); + void clear_has_ctype(); + void set_has_packed(); + void clear_has_packed(); + void set_has_jstype(); + void clear_has_jstype(); + void set_has_lazy(); + void clear_has_lazy(); + void set_has_deprecated(); + void clear_has_deprecated(); + void set_has_weak(); + void clear_has_weak(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2591,13 +2665,10 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ bool weak_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> FieldOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofOptions) */ { @@ -2623,49 +2694,52 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ static const ::google::protobuf::Descriptor* descriptor(); static const OneofOptions& default_instance(); - static const OneofOptions* internal_default_instance(); + static inline const OneofOptions* internal_default_instance() { + return reinterpret_cast<const OneofOptions*>( + &_OneofOptions_default_instance_); + } void Swap(OneofOptions* other); // implements Message ---------------------------------------------- - inline OneofOptions* New() const { return New(NULL); } + inline OneofOptions* New() const PROTOBUF_FINAL { return New(NULL); } - OneofOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + OneofOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const OneofOptions& from); void MergeFrom(const OneofOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(OneofOptions* other); - void UnsafeMergeFrom(const OneofOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -2695,13 +2769,10 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> OneofOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumOptions) */ { @@ -2727,49 +2798,52 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const EnumOptions& default_instance(); - static const EnumOptions* internal_default_instance(); + static inline const EnumOptions* internal_default_instance() { + return reinterpret_cast<const EnumOptions*>( + &_EnumOptions_default_instance_); + } void Swap(EnumOptions* other); // implements Message ---------------------------------------------- - inline EnumOptions* New() const { return New(NULL); } + inline EnumOptions* New() const PROTOBUF_FINAL { return New(NULL); } - EnumOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + EnumOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumOptions& from); void MergeFrom(const EnumOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumOptions* other); - void UnsafeMergeFrom(const EnumOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -2804,10 +2878,10 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumOptions) // @@protoc_insertion_point(class_scope:google.protobuf.EnumOptions) private: - inline void set_has_allow_alias(); - inline void clear_has_allow_alias(); - inline void set_has_deprecated(); - inline void clear_has_deprecated(); + void set_has_allow_alias(); + void clear_has_allow_alias(); + void set_has_deprecated(); + void clear_has_deprecated(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2819,13 +2893,10 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p bool deprecated_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> EnumOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueOptions) */ { @@ -2851,49 +2922,52 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / static const ::google::protobuf::Descriptor* descriptor(); static const EnumValueOptions& default_instance(); - static const EnumValueOptions* internal_default_instance(); + static inline const EnumValueOptions* internal_default_instance() { + return reinterpret_cast<const EnumValueOptions*>( + &_EnumValueOptions_default_instance_); + } void Swap(EnumValueOptions* other); // implements Message ---------------------------------------------- - inline EnumValueOptions* New() const { return New(NULL); } + inline EnumValueOptions* New() const PROTOBUF_FINAL { return New(NULL); } - EnumValueOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + EnumValueOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumValueOptions& from); void MergeFrom(const EnumValueOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumValueOptions* other); - void UnsafeMergeFrom(const EnumValueOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -2921,8 +2995,8 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumValueOptions) // @@protoc_insertion_point(class_scope:google.protobuf.EnumValueOptions) private: - inline void set_has_deprecated(); - inline void clear_has_deprecated(); + void set_has_deprecated(); + void clear_has_deprecated(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2933,13 +3007,10 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / bool deprecated_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> EnumValueOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceOptions) */ { @@ -2965,49 +3036,52 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const ServiceOptions& default_instance(); - static const ServiceOptions* internal_default_instance(); + static inline const ServiceOptions* internal_default_instance() { + return reinterpret_cast<const ServiceOptions*>( + &_ServiceOptions_default_instance_); + } void Swap(ServiceOptions* other); // implements Message ---------------------------------------------- - inline ServiceOptions* New() const { return New(NULL); } + inline ServiceOptions* New() const PROTOBUF_FINAL { return New(NULL); } - ServiceOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + ServiceOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const ServiceOptions& from); void MergeFrom(const ServiceOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(ServiceOptions* other); - void UnsafeMergeFrom(const ServiceOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3035,8 +3109,8 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(ServiceOptions) // @@protoc_insertion_point(class_scope:google.protobuf.ServiceOptions) private: - inline void set_has_deprecated(); - inline void clear_has_deprecated(); + void set_has_deprecated(); + void clear_has_deprecated(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -3047,13 +3121,10 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* bool deprecated_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> ServiceOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodOptions) */ { @@ -3079,52 +3150,83 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ static const ::google::protobuf::Descriptor* descriptor(); static const MethodOptions& default_instance(); - static const MethodOptions* internal_default_instance(); + static inline const MethodOptions* internal_default_instance() { + return reinterpret_cast<const MethodOptions*>( + &_MethodOptions_default_instance_); + } void Swap(MethodOptions* other); // implements Message ---------------------------------------------- - inline MethodOptions* New() const { return New(NULL); } + inline MethodOptions* New() const PROTOBUF_FINAL { return New(NULL); } - MethodOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + MethodOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const MethodOptions& from); void MergeFrom(const MethodOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(MethodOptions* other); - void UnsafeMergeFrom(const MethodOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- + typedef MethodOptions_IdempotencyLevel IdempotencyLevel; + static const IdempotencyLevel IDEMPOTENCY_UNKNOWN = + MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN; + static const IdempotencyLevel NO_SIDE_EFFECTS = + MethodOptions_IdempotencyLevel_NO_SIDE_EFFECTS; + static const IdempotencyLevel IDEMPOTENT = + MethodOptions_IdempotencyLevel_IDEMPOTENT; + static inline bool IdempotencyLevel_IsValid(int value) { + return MethodOptions_IdempotencyLevel_IsValid(value); + } + static const IdempotencyLevel IdempotencyLevel_MIN = + MethodOptions_IdempotencyLevel_IdempotencyLevel_MIN; + static const IdempotencyLevel IdempotencyLevel_MAX = + MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX; + static const int IdempotencyLevel_ARRAYSIZE = + MethodOptions_IdempotencyLevel_IdempotencyLevel_ARRAYSIZE; + static inline const ::google::protobuf::EnumDescriptor* + IdempotencyLevel_descriptor() { + return MethodOptions_IdempotencyLevel_descriptor(); + } + static inline const ::std::string& IdempotencyLevel_Name(IdempotencyLevel value) { + return MethodOptions_IdempotencyLevel_Name(value); + } + static inline bool IdempotencyLevel_Parse(const ::std::string& name, + IdempotencyLevel* value) { + return MethodOptions_IdempotencyLevel_Parse(name, value); + } + // accessors ------------------------------------------------------- // optional bool deprecated = 33 [default = false]; @@ -3134,6 +3236,13 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ bool deprecated() const; void set_deprecated(bool value); + // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + bool has_idempotency_level() const; + void clear_idempotency_level(); + static const int kIdempotencyLevelFieldNumber = 34; + ::google::protobuf::MethodOptions_IdempotencyLevel idempotency_level() const; + void set_idempotency_level(::google::protobuf::MethodOptions_IdempotencyLevel value); + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); @@ -3149,8 +3258,10 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MethodOptions) // @@protoc_insertion_point(class_scope:google.protobuf.MethodOptions) private: - inline void set_has_deprecated(); - inline void clear_has_deprecated(); + void set_has_deprecated(); + void clear_has_deprecated(); + void set_has_idempotency_level(); + void clear_has_idempotency_level(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -3159,15 +3270,13 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; + int idempotency_level_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> MethodOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption.NamePart) */ { @@ -3193,49 +3302,52 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu static const ::google::protobuf::Descriptor* descriptor(); static const UninterpretedOption_NamePart& default_instance(); - static const UninterpretedOption_NamePart* internal_default_instance(); + static inline const UninterpretedOption_NamePart* internal_default_instance() { + return reinterpret_cast<const UninterpretedOption_NamePart*>( + &_UninterpretedOption_NamePart_default_instance_); + } void Swap(UninterpretedOption_NamePart* other); // implements Message ---------------------------------------------- - inline UninterpretedOption_NamePart* New() const { return New(NULL); } + inline UninterpretedOption_NamePart* New() const PROTOBUF_FINAL { return New(NULL); } - UninterpretedOption_NamePart* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + UninterpretedOption_NamePart* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const UninterpretedOption_NamePart& from); void MergeFrom(const UninterpretedOption_NamePart& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(UninterpretedOption_NamePart* other); - void UnsafeMergeFrom(const UninterpretedOption_NamePart& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3262,10 +3374,10 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu // @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption.NamePart) private: - inline void set_has_name_part(); - inline void clear_has_name_part(); - inline void set_has_is_extension(); - inline void clear_has_is_extension(); + void set_has_name_part(); + void clear_has_name_part(); + void set_has_is_extension(); + void clear_has_is_extension(); // helper for ByteSizeLong() size_t RequiredFieldsByteSizeFallback() const; @@ -3277,13 +3389,10 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu bool is_extension_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> UninterpretedOption_NamePart_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption) */ { @@ -3309,49 +3418,52 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const UninterpretedOption& default_instance(); - static const UninterpretedOption* internal_default_instance(); + static inline const UninterpretedOption* internal_default_instance() { + return reinterpret_cast<const UninterpretedOption*>( + &_UninterpretedOption_default_instance_); + } void Swap(UninterpretedOption* other); // implements Message ---------------------------------------------- - inline UninterpretedOption* New() const { return New(NULL); } + inline UninterpretedOption* New() const PROTOBUF_FINAL { return New(NULL); } - UninterpretedOption* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + UninterpretedOption* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const UninterpretedOption& from); void MergeFrom(const UninterpretedOption& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(UninterpretedOption* other); - void UnsafeMergeFrom(const UninterpretedOption& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3430,18 +3542,18 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag // @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption) private: - inline void set_has_identifier_value(); - inline void clear_has_identifier_value(); - inline void set_has_positive_int_value(); - inline void clear_has_positive_int_value(); - inline void set_has_negative_int_value(); - inline void clear_has_negative_int_value(); - inline void set_has_double_value(); - inline void clear_has_double_value(); - inline void set_has_string_value(); - inline void clear_has_string_value(); - inline void set_has_aggregate_value(); - inline void clear_has_aggregate_value(); + void set_has_identifier_value(); + void clear_has_identifier_value(); + void set_has_positive_int_value(); + void clear_has_positive_int_value(); + void set_has_negative_int_value(); + void clear_has_negative_int_value(); + void set_has_double_value(); + void clear_has_double_value(); + void set_has_string_value(); + void clear_has_string_value(); + void set_has_aggregate_value(); + void clear_has_aggregate_value(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -3455,13 +3567,10 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag double double_value_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> UninterpretedOption_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo.Location) */ { @@ -3487,49 +3596,52 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me static const ::google::protobuf::Descriptor* descriptor(); static const SourceCodeInfo_Location& default_instance(); - static const SourceCodeInfo_Location* internal_default_instance(); + static inline const SourceCodeInfo_Location* internal_default_instance() { + return reinterpret_cast<const SourceCodeInfo_Location*>( + &_SourceCodeInfo_Location_default_instance_); + } void Swap(SourceCodeInfo_Location* other); // implements Message ---------------------------------------------- - inline SourceCodeInfo_Location* New() const { return New(NULL); } + inline SourceCodeInfo_Location* New() const PROTOBUF_FINAL { return New(NULL); } - SourceCodeInfo_Location* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + SourceCodeInfo_Location* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const SourceCodeInfo_Location& from); void MergeFrom(const SourceCodeInfo_Location& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(SourceCodeInfo_Location* other); - void UnsafeMergeFrom(const SourceCodeInfo_Location& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3601,10 +3713,10 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me // @@protoc_insertion_point(class_scope:google.protobuf.SourceCodeInfo.Location) private: - inline void set_has_leading_comments(); - inline void clear_has_leading_comments(); - inline void set_has_trailing_comments(); - inline void clear_has_trailing_comments(); + void set_has_leading_comments(); + void clear_has_leading_comments(); + void set_has_trailing_comments(); + void clear_has_trailing_comments(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -3618,13 +3730,10 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me ::google::protobuf::internal::ArenaStringPtr trailing_comments_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> SourceCodeInfo_Location_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo) */ { @@ -3650,49 +3759,52 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const SourceCodeInfo& default_instance(); - static const SourceCodeInfo* internal_default_instance(); + static inline const SourceCodeInfo* internal_default_instance() { + return reinterpret_cast<const SourceCodeInfo*>( + &_SourceCodeInfo_default_instance_); + } void Swap(SourceCodeInfo* other); // implements Message ---------------------------------------------- - inline SourceCodeInfo* New() const { return New(NULL); } + inline SourceCodeInfo* New() const PROTOBUF_FINAL { return New(NULL); } - SourceCodeInfo* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + SourceCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const SourceCodeInfo& from); void MergeFrom(const SourceCodeInfo& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(SourceCodeInfo* other); - void UnsafeMergeFrom(const SourceCodeInfo& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3721,13 +3833,10 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location > location_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> SourceCodeInfo_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo.Annotation) */ { @@ -3753,49 +3862,52 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu static const ::google::protobuf::Descriptor* descriptor(); static const GeneratedCodeInfo_Annotation& default_instance(); - static const GeneratedCodeInfo_Annotation* internal_default_instance(); + static inline const GeneratedCodeInfo_Annotation* internal_default_instance() { + return reinterpret_cast<const GeneratedCodeInfo_Annotation*>( + &_GeneratedCodeInfo_Annotation_default_instance_); + } void Swap(GeneratedCodeInfo_Annotation* other); // implements Message ---------------------------------------------- - inline GeneratedCodeInfo_Annotation* New() const { return New(NULL); } + inline GeneratedCodeInfo_Annotation* New() const PROTOBUF_FINAL { return New(NULL); } - GeneratedCodeInfo_Annotation* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + GeneratedCodeInfo_Annotation* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const GeneratedCodeInfo_Annotation& from); void MergeFrom(const GeneratedCodeInfo_Annotation& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(GeneratedCodeInfo_Annotation* other); - void UnsafeMergeFrom(const GeneratedCodeInfo_Annotation& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3841,12 +3953,12 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu // @@protoc_insertion_point(class_scope:google.protobuf.GeneratedCodeInfo.Annotation) private: - inline void set_has_source_file(); - inline void clear_has_source_file(); - inline void set_has_begin(); - inline void clear_has_begin(); - inline void set_has_end(); - inline void clear_has_end(); + void set_has_source_file(); + void clear_has_source_file(); + void set_has_begin(); + void clear_has_begin(); + void set_has_end(); + void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -3858,13 +3970,10 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu ::google::protobuf::int32 end_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> GeneratedCodeInfo_Annotation_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo) */ { @@ -3890,49 +3999,52 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message static const ::google::protobuf::Descriptor* descriptor(); static const GeneratedCodeInfo& default_instance(); - static const GeneratedCodeInfo* internal_default_instance(); + static inline const GeneratedCodeInfo* internal_default_instance() { + return reinterpret_cast<const GeneratedCodeInfo*>( + &_GeneratedCodeInfo_default_instance_); + } void Swap(GeneratedCodeInfo* other); // implements Message ---------------------------------------------- - inline GeneratedCodeInfo* New() const { return New(NULL); } + inline GeneratedCodeInfo* New() const PROTOBUF_FINAL { return New(NULL); } - GeneratedCodeInfo* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + GeneratedCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const GeneratedCodeInfo& from); void MergeFrom(const GeneratedCodeInfo& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(GeneratedCodeInfo* other); - void UnsafeMergeFrom(const GeneratedCodeInfo& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3961,13 +4073,10 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation > annotation_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> GeneratedCodeInfo_default_instance_; - // =================================================================== @@ -4006,9 +4115,6 @@ FileDescriptorSet::file() const { return file_; } -inline const FileDescriptorSet* FileDescriptorSet::internal_default_instance() { - return &FileDescriptorSet_default_instance_.get(); -} // ------------------------------------------------------------------- // FileDescriptorProto @@ -4029,7 +4135,7 @@ inline void FileDescriptorProto::clear_name() { } inline const ::std::string& FileDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void FileDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -4083,7 +4189,7 @@ inline void FileDescriptorProto::clear_package() { } inline const ::std::string& FileDescriptorProto::package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package) - return package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return package_.GetNoArena(); } inline void FileDescriptorProto::set_package(const ::std::string& value) { set_has_package(); @@ -4358,13 +4464,13 @@ FileDescriptorProto::extension() const { // optional .google.protobuf.FileOptions options = 8; inline bool FileDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } inline void FileDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000008u; } inline void FileDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000008u; } inline void FileDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear(); @@ -4403,13 +4509,13 @@ inline void FileDescriptorProto::set_allocated_options(::google::protobuf::FileO // optional .google.protobuf.SourceCodeInfo source_code_info = 9; inline bool FileDescriptorProto::has_source_code_info() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } inline void FileDescriptorProto::set_has_source_code_info() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00000010u; } inline void FileDescriptorProto::clear_has_source_code_info() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00000010u; } inline void FileDescriptorProto::clear_source_code_info() { if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear(); @@ -4448,13 +4554,13 @@ inline void FileDescriptorProto::set_allocated_source_code_info(::google::protob // optional string syntax = 12; inline bool FileDescriptorProto::has_syntax() const { - return (_has_bits_[0] & 0x00000800u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void FileDescriptorProto::set_has_syntax() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00000004u; } inline void FileDescriptorProto::clear_has_syntax() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00000004u; } inline void FileDescriptorProto::clear_syntax() { syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -4462,7 +4568,7 @@ inline void FileDescriptorProto::clear_syntax() { } inline const ::std::string& FileDescriptorProto::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax) - return syntax_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return syntax_.GetNoArena(); } inline void FileDescriptorProto::set_syntax(const ::std::string& value) { set_has_syntax(); @@ -4500,9 +4606,6 @@ inline void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax) } -inline const FileDescriptorProto* FileDescriptorProto::internal_default_instance() { - return &FileDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // DescriptorProto_ExtensionRange @@ -4555,9 +4658,6 @@ inline void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 va // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end) } -inline const DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::internal_default_instance() { - return &DescriptorProto_ExtensionRange_default_instance_.get(); -} // ------------------------------------------------------------------- // DescriptorProto_ReservedRange @@ -4610,9 +4710,6 @@ inline void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 val // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end) } -inline const DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::internal_default_instance() { - return &DescriptorProto_ReservedRange_default_instance_.get(); -} // ------------------------------------------------------------------- // DescriptorProto @@ -4633,7 +4730,7 @@ inline void DescriptorProto::clear_name() { } inline const ::std::string& DescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void DescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -4853,13 +4950,13 @@ DescriptorProto::oneof_decl() const { // optional .google.protobuf.MessageOptions options = 7; inline bool DescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000080u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void DescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000002u; } inline void DescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000002u; } inline void DescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear(); @@ -4981,9 +5078,6 @@ DescriptorProto::mutable_reserved_name() { return &reserved_name_; } -inline const DescriptorProto* DescriptorProto::internal_default_instance() { - return &DescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // FieldDescriptorProto @@ -5004,7 +5098,7 @@ inline void FieldDescriptorProto::clear_name() { } inline const ::std::string& FieldDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void FieldDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5044,13 +5138,13 @@ inline void FieldDescriptorProto::set_allocated_name(::std::string* name) { // optional int32 number = 3; inline bool FieldDescriptorProto::has_number() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } inline void FieldDescriptorProto::set_has_number() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000040u; } inline void FieldDescriptorProto::clear_has_number() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000040u; } inline void FieldDescriptorProto::clear_number() { number_ = 0; @@ -5068,13 +5162,13 @@ inline void FieldDescriptorProto::set_number(::google::protobuf::int32 value) { // optional .google.protobuf.FieldDescriptorProto.Label label = 4; inline bool FieldDescriptorProto::has_label() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000100u) != 0; } inline void FieldDescriptorProto::set_has_label() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000100u; } inline void FieldDescriptorProto::clear_has_label() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000100u; } inline void FieldDescriptorProto::clear_label() { label_ = 1; @@ -5093,13 +5187,13 @@ inline void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorP // optional .google.protobuf.FieldDescriptorProto.Type type = 5; inline bool FieldDescriptorProto::has_type() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000200u) != 0; } inline void FieldDescriptorProto::set_has_type() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000200u; } inline void FieldDescriptorProto::clear_has_type() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000200u; } inline void FieldDescriptorProto::clear_type() { type_ = 1; @@ -5118,13 +5212,13 @@ inline void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorPr // optional string type_name = 6; inline bool FieldDescriptorProto::has_type_name() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void FieldDescriptorProto::set_has_type_name() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000002u; } inline void FieldDescriptorProto::clear_has_type_name() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000002u; } inline void FieldDescriptorProto::clear_type_name() { type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5132,7 +5226,7 @@ inline void FieldDescriptorProto::clear_type_name() { } inline 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()); + return type_name_.GetNoArena(); } inline void FieldDescriptorProto::set_type_name(const ::std::string& value) { set_has_type_name(); @@ -5172,13 +5266,13 @@ inline void FieldDescriptorProto::set_allocated_type_name(::std::string* type_na // optional string extendee = 2; inline bool FieldDescriptorProto::has_extendee() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void FieldDescriptorProto::set_has_extendee() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000004u; } inline void FieldDescriptorProto::clear_has_extendee() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000004u; } inline void FieldDescriptorProto::clear_extendee() { extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5186,7 +5280,7 @@ inline void FieldDescriptorProto::clear_extendee() { } inline const ::std::string& FieldDescriptorProto::extendee() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee) - return extendee_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return extendee_.GetNoArena(); } inline void FieldDescriptorProto::set_extendee(const ::std::string& value) { set_has_extendee(); @@ -5226,13 +5320,13 @@ inline void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee // optional string default_value = 7; inline bool FieldDescriptorProto::has_default_value() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } inline void FieldDescriptorProto::set_has_default_value() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000008u; } inline void FieldDescriptorProto::clear_has_default_value() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000008u; } inline void FieldDescriptorProto::clear_default_value() { default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5240,7 +5334,7 @@ inline void FieldDescriptorProto::clear_default_value() { } inline 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()); + return default_value_.GetNoArena(); } inline void FieldDescriptorProto::set_default_value(const ::std::string& value) { set_has_default_value(); @@ -5304,13 +5398,13 @@ inline void FieldDescriptorProto::set_oneof_index(::google::protobuf::int32 valu // optional string json_name = 10; inline bool FieldDescriptorProto::has_json_name() const { - return (_has_bits_[0] & 0x00000100u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } inline void FieldDescriptorProto::set_has_json_name() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000010u; } inline void FieldDescriptorProto::clear_has_json_name() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000010u; } inline void FieldDescriptorProto::clear_json_name() { json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5318,7 +5412,7 @@ inline void FieldDescriptorProto::clear_json_name() { } inline 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()); + return json_name_.GetNoArena(); } inline void FieldDescriptorProto::set_json_name(const ::std::string& value) { set_has_json_name(); @@ -5358,13 +5452,13 @@ inline void FieldDescriptorProto::set_allocated_json_name(::std::string* json_na // optional .google.protobuf.FieldOptions options = 8; inline bool FieldDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } inline void FieldDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000020u; } inline void FieldDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000020u; } inline void FieldDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear(); @@ -5401,9 +5495,6 @@ inline void FieldDescriptorProto::set_allocated_options(::google::protobuf::Fiel // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.options) } -inline const FieldDescriptorProto* FieldDescriptorProto::internal_default_instance() { - return &FieldDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // OneofDescriptorProto @@ -5424,7 +5515,7 @@ inline void OneofDescriptorProto::clear_name() { } inline const ::std::string& OneofDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void OneofDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5507,9 +5598,6 @@ inline void OneofDescriptorProto::set_allocated_options(::google::protobuf::Oneo // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.options) } -inline const OneofDescriptorProto* OneofDescriptorProto::internal_default_instance() { - return &OneofDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // EnumDescriptorProto @@ -5530,7 +5618,7 @@ inline void EnumDescriptorProto::clear_name() { } inline const ::std::string& EnumDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void EnumDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5600,13 +5688,13 @@ EnumDescriptorProto::value() const { // optional .google.protobuf.EnumOptions options = 3; inline bool EnumDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void EnumDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } inline void EnumDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } inline void EnumDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear(); @@ -5643,9 +5731,6 @@ inline void EnumDescriptorProto::set_allocated_options(::google::protobuf::EnumO // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.options) } -inline const EnumDescriptorProto* EnumDescriptorProto::internal_default_instance() { - return &EnumDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // EnumValueDescriptorProto @@ -5666,7 +5751,7 @@ inline void EnumValueDescriptorProto::clear_name() { } inline const ::std::string& EnumValueDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void EnumValueDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5706,13 +5791,13 @@ inline void EnumValueDescriptorProto::set_allocated_name(::std::string* name) { // optional int32 number = 2; inline bool EnumValueDescriptorProto::has_number() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void EnumValueDescriptorProto::set_has_number() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000004u; } inline void EnumValueDescriptorProto::clear_has_number() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000004u; } inline void EnumValueDescriptorProto::clear_number() { number_ = 0; @@ -5730,13 +5815,13 @@ inline void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value // optional .google.protobuf.EnumValueOptions options = 3; inline bool EnumValueDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void EnumValueDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } inline void EnumValueDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } inline void EnumValueDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear(); @@ -5773,9 +5858,6 @@ inline void EnumValueDescriptorProto::set_allocated_options(::google::protobuf:: // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.options) } -inline const EnumValueDescriptorProto* EnumValueDescriptorProto::internal_default_instance() { - return &EnumValueDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // ServiceDescriptorProto @@ -5796,7 +5878,7 @@ inline void ServiceDescriptorProto::clear_name() { } inline const ::std::string& ServiceDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void ServiceDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5866,13 +5948,13 @@ ServiceDescriptorProto::method() const { // optional .google.protobuf.ServiceOptions options = 3; inline bool ServiceDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void ServiceDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } inline void ServiceDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } inline void ServiceDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear(); @@ -5909,9 +5991,6 @@ inline void ServiceDescriptorProto::set_allocated_options(::google::protobuf::Se // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.options) } -inline const ServiceDescriptorProto* ServiceDescriptorProto::internal_default_instance() { - return &ServiceDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // MethodDescriptorProto @@ -5932,7 +6011,7 @@ inline void MethodDescriptorProto::clear_name() { } inline const ::std::string& MethodDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void MethodDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5986,7 +6065,7 @@ inline void MethodDescriptorProto::clear_input_type() { } inline 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()); + return input_type_.GetNoArena(); } inline void MethodDescriptorProto::set_input_type(const ::std::string& value) { set_has_input_type(); @@ -6040,7 +6119,7 @@ inline void MethodDescriptorProto::clear_output_type() { } inline 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()); + return output_type_.GetNoArena(); } inline void MethodDescriptorProto::set_output_type(const ::std::string& value) { set_has_output_type(); @@ -6171,9 +6250,6 @@ inline void MethodDescriptorProto::set_server_streaming(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.server_streaming) } -inline const MethodDescriptorProto* MethodDescriptorProto::internal_default_instance() { - return &MethodDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // FileOptions @@ -6194,7 +6270,7 @@ inline void FileOptions::clear_java_package() { } inline 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()); + return java_package_.GetNoArena(); } inline void FileOptions::set_java_package(const ::std::string& value) { set_has_java_package(); @@ -6248,7 +6324,7 @@ inline void FileOptions::clear_java_outer_classname() { } inline 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()); + return java_outer_classname_.GetNoArena(); } inline void FileOptions::set_java_outer_classname(const ::std::string& value) { set_has_java_outer_classname(); @@ -6288,13 +6364,13 @@ inline void FileOptions::set_allocated_java_outer_classname(::std::string* java_ // optional bool java_multiple_files = 10 [default = false]; inline bool FileOptions::has_java_multiple_files() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } inline void FileOptions::set_has_java_multiple_files() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000020u; } inline void FileOptions::clear_has_java_multiple_files() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000020u; } inline void FileOptions::clear_java_multiple_files() { java_multiple_files_ = false; @@ -6312,13 +6388,13 @@ inline void FileOptions::set_java_multiple_files(bool value) { // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; inline bool FileOptions::has_java_generate_equals_and_hash() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } inline void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000040u; } inline void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000040u; } inline void FileOptions::clear_java_generate_equals_and_hash() { java_generate_equals_and_hash_ = false; @@ -6336,13 +6412,13 @@ inline void FileOptions::set_java_generate_equals_and_hash(bool value) { // 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] & 0x00000080u) != 0; } inline void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000080u; } inline void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000080u; } inline void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; @@ -6360,13 +6436,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] & 0x00002000u) != 0; } inline void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00002000u; } inline void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00002000u; } inline void FileOptions::clear_optimize_for() { optimize_for_ = 1; @@ -6385,13 +6461,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] & 0x00000004u) != 0; } inline void FileOptions::set_has_go_package() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000004u; } inline void FileOptions::clear_has_go_package() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000004u; } inline void FileOptions::clear_go_package() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -6399,7 +6475,7 @@ inline void FileOptions::clear_go_package() { } inline 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()); + return go_package_.GetNoArena(); } inline void FileOptions::set_go_package(const ::std::string& value) { set_has_go_package(); @@ -6439,13 +6515,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] & 0x00000100u) != 0; } inline void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000100u; } inline void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000100u; } inline void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; @@ -6463,13 +6539,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] & 0x00000200u) != 0; } inline void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000200u; } inline void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000200u; } inline void FileOptions::clear_java_generic_services() { java_generic_services_ = false; @@ -6487,13 +6563,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] & 0x00000400u) != 0; } inline void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000400u; } inline void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000400u; } inline void FileOptions::clear_py_generic_services() { py_generic_services_ = false; @@ -6511,13 +6587,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] & 0x00000800u) != 0; } inline void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00000800u; } inline void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00000800u; } inline void FileOptions::clear_deprecated() { deprecated_ = false; @@ -6535,13 +6611,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] & 0x00001000u) != 0; } inline void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00001000u; } inline void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00001000u; } inline void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; @@ -6559,13 +6635,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] & 0x00000008u) != 0; } inline void FileOptions::set_has_objc_class_prefix() { - _has_bits_[0] |= 0x00001000u; + _has_bits_[0] |= 0x00000008u; } inline void FileOptions::clear_has_objc_class_prefix() { - _has_bits_[0] &= ~0x00001000u; + _has_bits_[0] &= ~0x00000008u; } inline void FileOptions::clear_objc_class_prefix() { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -6573,7 +6649,7 @@ inline void FileOptions::clear_objc_class_prefix() { } inline 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()); + return objc_class_prefix_.GetNoArena(); } inline void FileOptions::set_objc_class_prefix(const ::std::string& value) { set_has_objc_class_prefix(); @@ -6613,13 +6689,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] & 0x00000010u) != 0; } inline void FileOptions::set_has_csharp_namespace() { - _has_bits_[0] |= 0x00002000u; + _has_bits_[0] |= 0x00000010u; } inline void FileOptions::clear_has_csharp_namespace() { - _has_bits_[0] &= ~0x00002000u; + _has_bits_[0] &= ~0x00000010u; } inline void FileOptions::clear_csharp_namespace() { csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -6627,7 +6703,7 @@ inline void FileOptions::clear_csharp_namespace() { } inline 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()); + return csharp_namespace_.GetNoArena(); } inline void FileOptions::set_csharp_namespace(const ::std::string& value) { set_has_csharp_namespace(); @@ -6695,9 +6771,6 @@ FileOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const FileOptions* FileOptions::internal_default_instance() { - return &FileOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // MessageOptions @@ -6828,9 +6901,6 @@ MessageOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const MessageOptions* MessageOptions::internal_default_instance() { - return &MessageOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // FieldOptions @@ -6862,13 +6932,13 @@ inline void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value // optional bool packed = 2; inline bool FieldOptions::has_packed() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void FieldOptions::set_has_packed() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000004u; } inline void FieldOptions::clear_has_packed() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000004u; } inline void FieldOptions::clear_packed() { packed_ = false; @@ -6886,13 +6956,13 @@ inline void FieldOptions::set_packed(bool value) { // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; inline bool FieldOptions::has_jstype() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void FieldOptions::set_has_jstype() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } inline void FieldOptions::clear_has_jstype() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } inline void FieldOptions::clear_jstype() { jstype_ = 0; @@ -7011,9 +7081,6 @@ FieldOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const FieldOptions* FieldOptions::internal_default_instance() { - return &FieldOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // OneofOptions @@ -7048,9 +7115,6 @@ OneofOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const OneofOptions* OneofOptions::internal_default_instance() { - return &OneofOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // EnumOptions @@ -7133,9 +7197,6 @@ EnumOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const EnumOptions* EnumOptions::internal_default_instance() { - return &EnumOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // EnumValueOptions @@ -7194,9 +7255,6 @@ EnumValueOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const EnumValueOptions* EnumValueOptions::internal_default_instance() { - return &EnumValueOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // ServiceOptions @@ -7255,9 +7313,6 @@ ServiceOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const ServiceOptions* ServiceOptions::internal_default_instance() { - return &ServiceOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // MethodOptions @@ -7286,6 +7341,31 @@ inline void MethodOptions::set_deprecated(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.deprecated) } +// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; +inline bool MethodOptions::has_idempotency_level() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void MethodOptions::set_has_idempotency_level() { + _has_bits_[0] |= 0x00000002u; +} +inline void MethodOptions::clear_has_idempotency_level() { + _has_bits_[0] &= ~0x00000002u; +} +inline void MethodOptions::clear_idempotency_level() { + idempotency_level_ = 0; + clear_has_idempotency_level(); +} +inline ::google::protobuf::MethodOptions_IdempotencyLevel MethodOptions::idempotency_level() const { + // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.idempotency_level) + return static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(idempotency_level_); +} +inline void MethodOptions::set_idempotency_level(::google::protobuf::MethodOptions_IdempotencyLevel value) { + assert(::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(value)); + set_has_idempotency_level(); + idempotency_level_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.idempotency_level) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int MethodOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); @@ -7316,9 +7396,6 @@ MethodOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const MethodOptions* MethodOptions::internal_default_instance() { - return &MethodOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // UninterpretedOption_NamePart @@ -7339,7 +7416,7 @@ inline void UninterpretedOption_NamePart::clear_name_part() { } inline 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()); + return name_part_.GetNoArena(); } inline void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) { set_has_name_part(); @@ -7401,9 +7478,6 @@ inline void UninterpretedOption_NamePart::set_is_extension(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension) } -inline const UninterpretedOption_NamePart* UninterpretedOption_NamePart::internal_default_instance() { - return &UninterpretedOption_NamePart_default_instance_.get(); -} // ------------------------------------------------------------------- // UninterpretedOption @@ -7440,13 +7514,13 @@ UninterpretedOption::name() const { // optional string identifier_value = 3; inline bool UninterpretedOption::has_identifier_value() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } inline void UninterpretedOption::set_has_identifier_value() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000001u; } inline void UninterpretedOption::clear_has_identifier_value() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000001u; } inline void UninterpretedOption::clear_identifier_value() { identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7454,7 +7528,7 @@ inline void UninterpretedOption::clear_identifier_value() { } inline 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()); + return identifier_value_.GetNoArena(); } inline void UninterpretedOption::set_identifier_value(const ::std::string& value) { set_has_identifier_value(); @@ -7494,13 +7568,13 @@ inline void UninterpretedOption::set_allocated_identifier_value(::std::string* i // optional uint64 positive_int_value = 4; inline bool UninterpretedOption::has_positive_int_value() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } inline void UninterpretedOption::set_has_positive_int_value() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000008u; } inline void UninterpretedOption::clear_has_positive_int_value() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000008u; } inline void UninterpretedOption::clear_positive_int_value() { positive_int_value_ = GOOGLE_ULONGLONG(0); @@ -7518,13 +7592,13 @@ inline void UninterpretedOption::set_positive_int_value(::google::protobuf::uint // optional int64 negative_int_value = 5; inline bool UninterpretedOption::has_negative_int_value() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } inline void UninterpretedOption::set_has_negative_int_value() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000010u; } inline void UninterpretedOption::clear_has_negative_int_value() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000010u; } inline void UninterpretedOption::clear_negative_int_value() { negative_int_value_ = GOOGLE_LONGLONG(0); @@ -7542,13 +7616,13 @@ inline void UninterpretedOption::set_negative_int_value(::google::protobuf::int6 // optional double double_value = 6; inline bool UninterpretedOption::has_double_value() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } inline void UninterpretedOption::set_has_double_value() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000020u; } inline void UninterpretedOption::clear_has_double_value() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000020u; } inline void UninterpretedOption::clear_double_value() { double_value_ = 0; @@ -7566,13 +7640,13 @@ inline void UninterpretedOption::set_double_value(double value) { // optional bytes string_value = 7; inline bool UninterpretedOption::has_string_value() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void UninterpretedOption::set_has_string_value() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000002u; } inline void UninterpretedOption::clear_has_string_value() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000002u; } inline void UninterpretedOption::clear_string_value() { string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7580,7 +7654,7 @@ inline void UninterpretedOption::clear_string_value() { } inline 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()); + return string_value_.GetNoArena(); } inline void UninterpretedOption::set_string_value(const ::std::string& value) { set_has_string_value(); @@ -7620,13 +7694,13 @@ inline void UninterpretedOption::set_allocated_string_value(::std::string* strin // optional string aggregate_value = 8; inline bool UninterpretedOption::has_aggregate_value() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void UninterpretedOption::set_has_aggregate_value() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000004u; } inline void UninterpretedOption::clear_has_aggregate_value() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000004u; } inline void UninterpretedOption::clear_aggregate_value() { aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7634,7 +7708,7 @@ inline void UninterpretedOption::clear_aggregate_value() { } inline 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()); + return aggregate_value_.GetNoArena(); } inline void UninterpretedOption::set_aggregate_value(const ::std::string& value) { set_has_aggregate_value(); @@ -7672,9 +7746,6 @@ inline void UninterpretedOption::set_allocated_aggregate_value(::std::string* ag // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value) } -inline const UninterpretedOption* UninterpretedOption::internal_default_instance() { - return &UninterpretedOption_default_instance_.get(); -} // ------------------------------------------------------------------- // SourceCodeInfo_Location @@ -7741,13 +7812,13 @@ SourceCodeInfo_Location::mutable_span() { // optional string leading_comments = 3; inline bool SourceCodeInfo_Location::has_leading_comments() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } inline void SourceCodeInfo_Location::set_has_leading_comments() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000001u; } inline void SourceCodeInfo_Location::clear_has_leading_comments() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000001u; } inline void SourceCodeInfo_Location::clear_leading_comments() { leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7755,7 +7826,7 @@ inline void SourceCodeInfo_Location::clear_leading_comments() { } inline 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()); + return leading_comments_.GetNoArena(); } inline void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) { set_has_leading_comments(); @@ -7795,13 +7866,13 @@ inline void SourceCodeInfo_Location::set_allocated_leading_comments(::std::strin // optional string trailing_comments = 4; inline bool SourceCodeInfo_Location::has_trailing_comments() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void SourceCodeInfo_Location::set_has_trailing_comments() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000002u; } inline void SourceCodeInfo_Location::clear_has_trailing_comments() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000002u; } inline void SourceCodeInfo_Location::clear_trailing_comments() { trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7809,7 +7880,7 @@ inline void SourceCodeInfo_Location::clear_trailing_comments() { } inline 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()); + return trailing_comments_.GetNoArena(); } inline void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) { set_has_trailing_comments(); @@ -7902,9 +7973,6 @@ SourceCodeInfo_Location::mutable_leading_detached_comments() { return &leading_detached_comments_; } -inline const SourceCodeInfo_Location* SourceCodeInfo_Location::internal_default_instance() { - return &SourceCodeInfo_Location_default_instance_.get(); -} // ------------------------------------------------------------------- // SourceCodeInfo @@ -7939,9 +8007,6 @@ SourceCodeInfo::location() const { return location_; } -inline const SourceCodeInfo* SourceCodeInfo::internal_default_instance() { - return &SourceCodeInfo_default_instance_.get(); -} // ------------------------------------------------------------------- // GeneratedCodeInfo_Annotation @@ -7978,13 +8043,13 @@ GeneratedCodeInfo_Annotation::mutable_path() { // optional string source_file = 2; inline bool GeneratedCodeInfo_Annotation::has_source_file() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } inline void GeneratedCodeInfo_Annotation::set_has_source_file() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000001u; } inline void GeneratedCodeInfo_Annotation::clear_has_source_file() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000001u; } inline void GeneratedCodeInfo_Annotation::clear_source_file() { source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7992,7 +8057,7 @@ inline void GeneratedCodeInfo_Annotation::clear_source_file() { } inline 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()); + return source_file_.GetNoArena(); } inline void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) { set_has_source_file(); @@ -8032,13 +8097,13 @@ inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::strin // optional int32 begin = 3; inline bool GeneratedCodeInfo_Annotation::has_begin() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void GeneratedCodeInfo_Annotation::set_has_begin() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } inline void GeneratedCodeInfo_Annotation::clear_has_begin() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } inline void GeneratedCodeInfo_Annotation::clear_begin() { begin_ = 0; @@ -8056,13 +8121,13 @@ inline void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 va // optional int32 end = 4; inline bool GeneratedCodeInfo_Annotation::has_end() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void GeneratedCodeInfo_Annotation::set_has_end() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000004u; } inline void GeneratedCodeInfo_Annotation::clear_has_end() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000004u; } inline void GeneratedCodeInfo_Annotation::clear_end() { end_ = 0; @@ -8078,9 +8143,6 @@ inline void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 valu // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end) } -inline const GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::internal_default_instance() { - return &GeneratedCodeInfo_Annotation_default_instance_.get(); -} // ------------------------------------------------------------------- // GeneratedCodeInfo @@ -8115,9 +8177,6 @@ GeneratedCodeInfo::annotation() const { return annotation_; } -inline const GeneratedCodeInfo* GeneratedCodeInfo::internal_default_instance() { - return &GeneratedCodeInfo_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- @@ -8170,6 +8229,7 @@ inline const GeneratedCodeInfo* GeneratedCodeInfo::internal_default_instance() { // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google @@ -8202,6 +8262,11 @@ template <> inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::FieldOptions_JSType>() { return ::google::protobuf::FieldOptions_JSType_descriptor(); } +template <> struct is_proto_enum< ::google::protobuf::MethodOptions_IdempotencyLevel> : ::google::protobuf::internal::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::MethodOptions_IdempotencyLevel>() { + return ::google::protobuf::MethodOptions_IdempotencyLevel_descriptor(); +} } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index 558ae23e..d9b9064b 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -157,7 +157,6 @@ message FieldDescriptorProto { LABEL_OPTIONAL = 1; LABEL_REQUIRED = 2; LABEL_REPEATED = 3; - // TODO(sanjay): Should we add LABEL_MAP? }; optional string name = 1; @@ -431,13 +430,14 @@ message MessageOptions { // parser. optional bool map_entry = 7; + reserved 8; // javalite_serializable + + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; // Clients can define custom options in extensions of this message. See above. extensions 1000 to max; - - reserved 8; // javalite_serializable } message FieldOptions { @@ -551,6 +551,7 @@ message EnumOptions { // is a formalization for deprecating enums. optional bool deprecated = 3 [default=false]; + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; @@ -605,6 +606,17 @@ message MethodOptions { // this is a formalization for deprecating methods. optional bool deprecated = 33 [default=false]; + // Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + // or neither? HTTP based RPC implementation may choose GET verb for safe + // methods, and PUT verb for idempotent methods instead of the default POST. + enum IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0; + NO_SIDE_EFFECTS = 1; // implies idempotent + IDEMPOTENT = 2; // idempotent, but may have side effects + } + optional IdempotencyLevel idempotency_level = + 34 [default=IDEMPOTENCY_UNKNOWN]; + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc index 2117c020..57ae960f 100644 --- a/src/google/protobuf/descriptor_database.cc +++ b/src/google/protobuf/descriptor_database.cc @@ -97,11 +97,12 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol( // Try to look up the symbol to make sure a super-symbol doesn't already // exist. - typename map<string, Value>::iterator iter = FindLastLessOrEqual(name); + typename std::map<string, Value>::iterator iter = FindLastLessOrEqual(name); if (iter == by_symbol_.end()) { // Apparently the map is currently empty. Just insert and be done with it. - by_symbol_.insert(typename map<string, Value>::value_type(name, value)); + by_symbol_.insert( + typename std::map<string, Value>::value_type(name, value)); return true; } @@ -128,7 +129,8 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol( // Insert the new symbol using the iterator as a hint, the new entry will // appear immediately before the one the iterator is pointing at. - by_symbol_.insert(iter, typename map<string, Value>::value_type(name, value)); + by_symbol_.insert(iter, + typename std::map<string, Value>::value_type(name, value)); return true; } @@ -179,7 +181,7 @@ Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindFile( template <typename Value> Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindSymbol( const string& name) { - typename map<string, Value>::iterator iter = FindLastLessOrEqual(name); + typename std::map<string, Value>::iterator iter = FindLastLessOrEqual(name); return (iter != by_symbol_.end() && IsSubSymbol(iter->first, name)) ? iter->second : Value(); @@ -196,8 +198,8 @@ Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindExtension( template <typename Value> bool SimpleDescriptorDatabase::DescriptorIndex<Value>::FindAllExtensionNumbers( const string& containing_type, - vector<int>* output) { - typename map<pair<string, int>, Value>::const_iterator it = + std::vector<int>* output) { + typename std::map<pair<string, int>, Value>::const_iterator it = by_extension_.lower_bound(std::make_pair(containing_type, 0)); bool success = false; @@ -217,7 +219,8 @@ SimpleDescriptorDatabase::DescriptorIndex<Value>::FindLastLessOrEqual( // Find the last key in the map which sorts less than or equal to the // symbol name. Since upper_bound() returns the *first* key that sorts // *greater* than the input, we want the element immediately before that. - typename map<string, Value>::iterator iter = by_symbol_.upper_bound(name); + typename std::map<string, Value>::iterator iter = + by_symbol_.upper_bound(name); if (iter != by_symbol_.begin()) --iter; return iter; } @@ -284,7 +287,7 @@ bool SimpleDescriptorDatabase::FindFileContainingExtension( bool SimpleDescriptorDatabase::FindAllExtensionNumbers( const string& extendee_type, - vector<int>* output) { + std::vector<int>* output) { return index_.FindAllExtensionNumbers(extendee_type, output); } @@ -340,7 +343,7 @@ bool EncodedDescriptorDatabase::FindFileContainingSymbol( bool EncodedDescriptorDatabase::FindNameOfFileContainingSymbol( const string& symbol_name, string* output) { - pair<const void*, int> encoded_file = index_.FindSymbol(symbol_name); + std::pair<const void*, int> encoded_file = index_.FindSymbol(symbol_name); if (encoded_file.first == NULL) return false; // Optimization: The name should be the first field in the encoded message. @@ -352,7 +355,7 @@ bool EncodedDescriptorDatabase::FindNameOfFileContainingSymbol( FileDescriptorProto::kNameFieldNumber, internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - if (input.ReadTag() == kNameTag) { + if (input.ReadTagNoLastTag() == kNameTag) { // Success! return internal::WireFormatLite::ReadString(&input, output); } else { @@ -376,12 +379,12 @@ bool EncodedDescriptorDatabase::FindFileContainingExtension( bool EncodedDescriptorDatabase::FindAllExtensionNumbers( const string& extendee_type, - vector<int>* output) { + std::vector<int>* output) { return index_.FindAllExtensionNumbers(extendee_type, output); } bool EncodedDescriptorDatabase::MaybeParse( - pair<const void*, int> encoded_file, + std::pair<const void*, int> encoded_file, FileDescriptorProto* output) { if (encoded_file.first == NULL) return false; return output->ParseFromArray(encoded_file.first, encoded_file.second); @@ -431,11 +434,11 @@ bool DescriptorPoolDatabase::FindFileContainingExtension( bool DescriptorPoolDatabase::FindAllExtensionNumbers( const string& extendee_type, - vector<int>* output) { + std::vector<int>* output) { const Descriptor* extendee = pool_.FindMessageTypeByName(extendee_type); if (extendee == NULL) return false; - vector<const FieldDescriptor*> extensions; + std::vector<const FieldDescriptor*> extensions; pool_.FindAllExtensions(extendee, &extensions); for (int i = 0; i < extensions.size(); ++i) { @@ -454,7 +457,7 @@ MergedDescriptorDatabase::MergedDescriptorDatabase( sources_.push_back(source2); } MergedDescriptorDatabase::MergedDescriptorDatabase( - const vector<DescriptorDatabase*>& sources) + const std::vector<DescriptorDatabase*>& sources) : sources_(sources) {} MergedDescriptorDatabase::~MergedDescriptorDatabase() {} @@ -517,23 +520,23 @@ bool MergedDescriptorDatabase::FindFileContainingExtension( bool MergedDescriptorDatabase::FindAllExtensionNumbers( const string& extendee_type, - vector<int>* output) { - set<int> merged_results; - vector<int> results; + std::vector<int>* output) { + std::set<int> merged_results; + std::vector<int> results; bool success = false; for (int i = 0; i < sources_.size(); i++) { if (sources_[i]->FindAllExtensionNumbers(extendee_type, &results)) { - std::copy( - results.begin(), results.end(), - insert_iterator<set<int> >(merged_results, merged_results.begin())); + std::copy(results.begin(), results.end(), + std::insert_iterator<std::set<int> >(merged_results, + merged_results.begin())); success = true; } results.clear(); } std::copy(merged_results.begin(), merged_results.end(), - insert_iterator<vector<int> >(*output, output->end())); + std::insert_iterator<std::vector<int> >(*output, output->end())); return success; } diff --git a/src/google/protobuf/descriptor_database.h b/src/google/protobuf/descriptor_database.h index 86002d56..be97a6d8 100644 --- a/src/google/protobuf/descriptor_database.h +++ b/src/google/protobuf/descriptor_database.h @@ -97,7 +97,7 @@ class LIBPROTOBUF_EXPORT DescriptorDatabase { // This method has a default implementation that always returns // false. virtual bool FindAllExtensionNumbers(const string& /* extendee_type */, - vector<int>* /* output */) { + std::vector<int>* /* output */) { return false; } @@ -150,7 +150,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase { int field_number, FileDescriptorProto* output); bool FindAllExtensionNumbers(const string& extendee_type, - vector<int>* output); + std::vector<int>* output); private: // So that it can use DescriptorIndex. @@ -175,12 +175,12 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase { Value FindSymbol(const string& name); Value FindExtension(const string& containing_type, int field_number); bool FindAllExtensionNumbers(const string& containing_type, - vector<int>* output); + std::vector<int>* output); private: - map<string, Value> by_name_; - map<string, Value> by_symbol_; - map<pair<string, int>, Value> by_extension_; + std::map<string, Value> by_name_; + std::map<string, Value> by_symbol_; + std::map<std::pair<string, int>, Value> by_extension_; // Invariant: The by_symbol_ map does not contain any symbols which are // prefixes of other symbols in the map. For example, "foo.bar" is a @@ -235,7 +235,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase { // Find the last entry in the by_symbol_ map whose key is less than or // equal to the given name. - typename map<string, Value>::iterator FindLastLessOrEqual( + typename std::map<string, Value>::iterator FindLastLessOrEqual( const string& name); // True if either the arguments are equal or super_symbol identifies a @@ -250,7 +250,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase { DescriptorIndex<const FileDescriptorProto*> index_; - vector<const FileDescriptorProto*> files_to_delete_; + std::vector<const FileDescriptorProto*> files_to_delete_; // If file is non-NULL, copy it into *output and return true, otherwise // return false. @@ -295,15 +295,16 @@ class LIBPROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase { int field_number, FileDescriptorProto* output); bool FindAllExtensionNumbers(const string& extendee_type, - vector<int>* output); + std::vector<int>* output); private: - SimpleDescriptorDatabase::DescriptorIndex<pair<const void*, int> > index_; - vector<void*> files_to_delete_; + SimpleDescriptorDatabase::DescriptorIndex<std::pair<const void*, int> > + index_; + std::vector<void*> files_to_delete_; // If encoded_file.first is non-NULL, parse the data into *output and return // true, otherwise return false. - bool MaybeParse(pair<const void*, int> encoded_file, + bool MaybeParse(std::pair<const void*, int> encoded_file, FileDescriptorProto* output); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EncodedDescriptorDatabase); @@ -324,7 +325,7 @@ class LIBPROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase { int field_number, FileDescriptorProto* output); bool FindAllExtensionNumbers(const string& extendee_type, - vector<int>* output); + std::vector<int>* output); private: const DescriptorPool& pool_; @@ -341,7 +342,8 @@ class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase { // Merge more than two databases. The sources remain property of the caller. // The vector may be deleted after the constructor returns but the // DescriptorDatabases need to stick around. - explicit MergedDescriptorDatabase(const vector<DescriptorDatabase*>& sources); + explicit MergedDescriptorDatabase( + const std::vector<DescriptorDatabase*>& sources); ~MergedDescriptorDatabase(); // implements DescriptorDatabase ----------------------------------- @@ -355,11 +357,11 @@ class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase { // Merges the results of calling all databases. Returns true iff any // of the databases returned true. bool FindAllExtensionNumbers(const string& extendee_type, - vector<int>* output); + std::vector<int>* output); private: - vector<DescriptorDatabase*> sources_; + std::vector<DescriptorDatabase*> sources_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase); }; diff --git a/src/google/protobuf/descriptor_database_unittest.cc b/src/google/protobuf/descriptor_database_unittest.cc index 4f568f7d..05d67656 100644 --- a/src/google/protobuf/descriptor_database_unittest.cc +++ b/src/google/protobuf/descriptor_database_unittest.cc @@ -410,7 +410,7 @@ TEST_P(DescriptorDatabaseTest, FindAllExtensionNumbers) { "extension { name:\"waldo\" extendee: \"Bar\" number:56 } "); { - vector<int> numbers; + std::vector<int> numbers; EXPECT_TRUE(database_->FindAllExtensionNumbers("Foo", &numbers)); ASSERT_EQ(2, numbers.size()); std::sort(numbers.begin(), numbers.end()); @@ -419,7 +419,7 @@ TEST_P(DescriptorDatabaseTest, FindAllExtensionNumbers) { } { - vector<int> numbers; + std::vector<int> numbers; EXPECT_TRUE(database_->FindAllExtensionNumbers("corge.Bar", &numbers)); // Note: won't find extension 56 due to the name not being fully qualified. ASSERT_EQ(1, numbers.size()); @@ -428,13 +428,13 @@ TEST_P(DescriptorDatabaseTest, FindAllExtensionNumbers) { { // Can't find extensions for non-existent types. - vector<int> numbers; + std::vector<int> numbers; EXPECT_FALSE(database_->FindAllExtensionNumbers("NoSuchType", &numbers)); } { // Can't find extensions for unqualified types. - vector<int> numbers; + std::vector<int> numbers; EXPECT_FALSE(database_->FindAllExtensionNumbers("Bar", &numbers)); } } @@ -708,7 +708,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindFileContainingExtension) { TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) { { // Message only has extension in database1_ - vector<int> numbers; + std::vector<int> numbers; EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers("Foo", &numbers)); ASSERT_EQ(1, numbers.size()); EXPECT_EQ(3, numbers[0]); @@ -716,7 +716,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) { { // Message only has extension in database2_ - vector<int> numbers; + std::vector<int> numbers; EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers("Bar", &numbers)); ASSERT_EQ(1, numbers.size()); EXPECT_EQ(5, numbers[0]); @@ -724,7 +724,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) { { // Merge results from the two databases. - vector<int> numbers; + std::vector<int> numbers; EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers("Baz", &numbers)); ASSERT_EQ(2, numbers.size()); std::sort(numbers.begin(), numbers.end()); @@ -733,7 +733,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) { } { - vector<int> numbers; + std::vector<int> numbers; EXPECT_TRUE(reverse_merged_.FindAllExtensionNumbers("Baz", &numbers)); ASSERT_EQ(2, numbers.size()); std::sort(numbers.begin(), numbers.end()); @@ -743,7 +743,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) { { // Can't find extensions for a non-existent message. - vector<int> numbers; + std::vector<int> numbers; EXPECT_FALSE(reverse_merged_.FindAllExtensionNumbers("Blah", &numbers)); } } diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index f6b3f1c5..7ec75156 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -41,8 +41,11 @@ #include <vector> #include <google/protobuf/compiler/importer.h> +#include <google/protobuf/compiler/parser.h> #include <google/protobuf/unittest.pb.h> #include <google/protobuf/unittest_custom_options.pb.h> +#include <google/protobuf/unittest_proto3_arena.pb.h> +#include <google/protobuf/io/tokenizer.h> #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/descriptor.h> @@ -55,6 +58,7 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/logging.h> +#include <google/protobuf/stubs/stringprintf.h> #include <google/protobuf/testing/googletest.h> #include <gtest/gtest.h> @@ -488,6 +492,65 @@ TEST_F(FileDescriptorTest, Syntax) { } } +void ExtractDebugString( + const FileDescriptor* file, std::set<string>* visited, + std::vector<std::pair<string, string> >* debug_strings) { + if (!visited->insert(file->name()).second) { + return; + } + for (int i = 0; i < file->dependency_count(); ++i) { + ExtractDebugString(file->dependency(i), visited, debug_strings); + } + debug_strings->push_back(make_pair(file->name(), file->DebugString())); +} + +class SimpleErrorCollector : public google::protobuf::io::ErrorCollector { + public: + // implements ErrorCollector --------------------------------------- + void AddError(int line, int column, const string& message) { + last_error_ = StringPrintf("%d:%d:", line, column) + message; + } + + const string& last_error() { return last_error_; } + + private: + string last_error_; +}; +// Test that the result of FileDescriptor::DebugString() can be used to create +// the original descriptors. +TEST_F(FileDescriptorTest, DebugStringRoundTrip) { + std::set<string> visited; + std::vector<std::pair<string, string> > debug_strings; + ExtractDebugString(protobuf_unittest::TestAllTypes::descriptor()->file(), + &visited, &debug_strings); + ExtractDebugString( + protobuf_unittest::TestMessageWithCustomOptions::descriptor()->file(), + &visited, &debug_strings); + ExtractDebugString(proto3_arena_unittest::TestAllTypes::descriptor()->file(), + &visited, &debug_strings); + ASSERT_GE(debug_strings.size(), 3); + + DescriptorPool pool; + for (int i = 0; i < debug_strings.size(); ++i) { + const string& name = debug_strings[i].first; + const string& content = debug_strings[i].second; + google::protobuf::io::ArrayInputStream input_stream(content.data(), content.size()); + SimpleErrorCollector error_collector; + google::protobuf::io::Tokenizer tokenizer(&input_stream, &error_collector); + google::protobuf::compiler::Parser parser; + parser.RecordErrorsTo(&error_collector); + FileDescriptorProto proto; + ASSERT_TRUE(parser.Parse(&tokenizer, &proto)) + << error_collector.last_error() << "\n" + << content; + ASSERT_EQ("", error_collector.last_error()); + proto.set_name(name); + const FileDescriptor* descriptor = pool.BuildFile(proto); + ASSERT_TRUE(descriptor != NULL) << proto.DebugString(); + EXPECT_EQ(content, descriptor->DebugString()); + } +} + // =================================================================== // Test simple flat messages and fields. @@ -1861,7 +1924,7 @@ TEST_F(ExtensionDescriptorTest, FindExtensionByName) { } TEST_F(ExtensionDescriptorTest, FindAllExtensions) { - vector<const FieldDescriptor*> extensions; + std::vector<const FieldDescriptor*> extensions; pool_.FindAllExtensions(foo_, &extensions); ASSERT_EQ(4, extensions.size()); EXPECT_EQ(10, extensions[0]->number()); @@ -2625,7 +2688,7 @@ TEST_P(AllowUnknownDependenciesTest, CustomOption) { // Verify that no extension options were set, but they were left as // uninterpreted_options. - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; file->options().GetReflection()->ListFields(file->options(), &fields); ASSERT_EQ(2, fields.size()); EXPECT_TRUE(file->options().has_optimize_for()); @@ -3276,6 +3339,85 @@ TEST(CustomOptions, OptionsWithRequiredEnums) { EXPECT_EQ(protobuf_unittest::NewOptionType::NEW_VALUE, new_enum_opt.value()); } +// Test that FileDescriptor::DebugString() formats custom options correctly. +TEST(CustomOptions, DebugString) { + DescriptorPool pool; + + FileDescriptorProto file_proto; + MessageOptions::descriptor()->file()->CopyTo(&file_proto); + ASSERT_TRUE(pool.BuildFile(file_proto) != NULL); + + // Add "foo.proto": + // import "google/protobuf/descriptor.proto"; + // package "protobuf_unittest"; + // option (protobuf_unittest.cc_option1) = 1; + // option (protobuf_unittest.cc_option2) = 2; + // extend google.protobuf.FieldOptions { + // optional int32 cc_option1 = 7736974; + // optional int32 cc_option2 = 7736975; + // } + ASSERT_TRUE(TextFormat::ParseFromString( + "name: \"foo.proto\" " + "package: \"protobuf_unittest\" " + "dependency: \"google/protobuf/descriptor.proto\" " + "options { " + " uninterpreted_option { " + " name { " + " name_part: \"protobuf_unittest.cc_option1\" " + " is_extension: true " + " } " + " positive_int_value: 1 " + " } " + " uninterpreted_option { " + " name { " + " name_part: \"protobuf_unittest.cc_option2\" " + " is_extension: true " + " } " + " positive_int_value: 2 " + " } " + "} " + "extension { " + " name: \"cc_option1\" " + " extendee: \".google.protobuf.FileOptions\" " + // This field number is intentionally chosen to be the same as + // (.fileopt1) defined in unittest_custom_options.proto (linked + // in this test binary). This is to test whether we are messing + // generated pool with custom descriptor pools when dealing with + // custom options. + " number: 7736974 " + " label: LABEL_OPTIONAL " + " type: TYPE_INT32 " + "}" + "extension { " + " name: \"cc_option2\" " + " extendee: \".google.protobuf.FileOptions\" " + " number: 7736975 " + " label: LABEL_OPTIONAL " + " type: TYPE_INT32 " + "}", + &file_proto)); + const FileDescriptor* descriptor = pool.BuildFile(file_proto); + ASSERT_TRUE(descriptor != NULL); + + EXPECT_EQ(2, descriptor->extension_count()); + + ASSERT_EQ( + "syntax = \"proto2\";\n" + "\n" + "import \"google/protobuf/descriptor.proto\";\n" + "package protobuf_unittest;\n" + "\n" + "option (.protobuf_unittest.cc_option1) = 1;\n" + "option (.protobuf_unittest.cc_option2) = 2;\n" + "\n" + "extend .google.protobuf.FileOptions {\n" + " optional int32 cc_option1 = 7736974;\n" + " optional int32 cc_option2 = 7736975;\n" + "}\n" + "\n", + descriptor->DebugString()); +} + // =================================================================== class ValidationErrorTest : public testing::Test { @@ -5169,7 +5311,7 @@ TEST_F(ValidationErrorTest, ErrorsReportedToLogError) { "message_type { name: \"Foo\" } ", &file_proto)); - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; @@ -5598,8 +5740,8 @@ TEST_F(ValidationErrorTest, EnumValuesConflictWhenPrefixesStripped) { "}", "foo.proto: BAR__BAZ: NAME: When enum name is stripped and label is " "PascalCased (BarBaz), this value label conflicts with " - "FOO_ENUM_BAR_BAZ. This " - "will make the proto fail to compile for some languages, such as C#.\n"); + "FOO_ENUM_BAR_BAZ. This will make the proto fail to compile for some " + "languages, such as C#.\n"); BuildFileWithErrors( "syntax: 'proto3'" @@ -5611,8 +5753,8 @@ TEST_F(ValidationErrorTest, EnumValuesConflictWhenPrefixesStripped) { "}", "foo.proto: BAR_BAZ: NAME: When enum name is stripped and label is " "PascalCased (BarBaz), this value label conflicts with " - "FOO_ENUM__BAR_BAZ. This " - "will make the proto fail to compile for some languages, such as C#.\n"); + "FOO_ENUM__BAR_BAZ. This will make the proto fail to compile for some " + "languages, such as C#.\n"); // This isn't an error because the underscore will cause the PascalCase to // differ by case (BarBaz vs. Barbaz). @@ -6159,7 +6301,7 @@ TEST_F(DatabaseBackedPoolTest, FindAllExtensions) { for (int i = 0; i < 2; ++i) { // Repeat the lookup twice, to check that we get consistent // results despite the fallback database lookup mutating the pool. - vector<const FieldDescriptor*> extensions; + std::vector<const FieldDescriptor*> extensions; pool.FindAllExtensions(foo, &extensions); ASSERT_EQ(1, extensions.size()); EXPECT_EQ(5, extensions[0]->number()); @@ -6170,7 +6312,7 @@ TEST_F(DatabaseBackedPoolTest, ErrorWithoutErrorCollector) { ErrorDescriptorDatabase error_database; DescriptorPool pool(&error_database); - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index f7cc647f..12135b80 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -19,85 +19,88 @@ namespace google { namespace protobuf { +class DurationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Duration> {}; +DurationDefaultTypeInternal _Duration_default_instance_; namespace { -const ::google::protobuf::Descriptor* Duration_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Duration_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/duration.proto"); - GOOGLE_CHECK(file != NULL); - Duration_descriptor_ = file->message_type(0); - static const int Duration_offsets_[2] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fduration_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fduration_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, seconds_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, nanos_), }; - Duration_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Duration_descriptor_, - Duration::internal_default_instance(), - Duration_offsets_, - -1, - -1, - -1, - sizeof(Duration), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Duration)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Duration_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/duration.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fduration_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Duration_descriptor_, Duration::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto() { - Duration_default_instance_.Shutdown(); - delete Duration_reflection_; + _Duration_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - Duration_default_instance_.DefaultConstruct(); - Duration_default_instance_.get_mutable()->InitAsDefaultInstance(); + ::google::protobuf::internal::InitProtobufDefaults(); + _Duration_default_instance_.DefaultConstruct(); } -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); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&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(); + static const char descriptor[] = { + "\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\370\001\001\242\002\003GPB\252\002\036Google.Prot" + "obuf.WellKnownTypesb\006proto3" + }; ::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\370\001\001\242\002\003GPB\252\002\036Google.Prot" - "obuf.WellKnownTypesb\006proto3", 227); + descriptor, 227); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/duration.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto); @@ -115,16 +118,6 @@ 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 @@ -134,7 +127,9 @@ const int Duration::kNanosFieldNumber; Duration::Duration() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Duration) } @@ -148,15 +143,14 @@ Duration::Duration(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Duration) } - -void Duration::InitAsDefaultInstance() { -} - Duration::Duration(const Duration& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::memcpy(&seconds_, &from.seconds_, + reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Duration) } @@ -192,7 +186,7 @@ void Duration::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Duration::descriptor() { protobuf_AssignDescriptorsOnce(); - return Duration_descriptor_; + return file_level_metadata[0].descriptor; } const Duration& Duration::default_instance() { @@ -200,35 +194,14 @@ const Duration& Duration::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Duration> Duration_default_instance_; - Duration* Duration::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Duration>(arena); } void Duration::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Duration) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(Duration, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<Duration*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(seconds_, nanos_); - -#undef ZR_HELPER_ -#undef ZR_ - + ::memset(&seconds_, 0, reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); } bool Duration::MergePartialFromCodedStream( @@ -237,13 +210,13 @@ bool Duration::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Duration) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional int64 seconds = 1; + // int64 seconds = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -251,14 +224,12 @@ bool Duration::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_nanos; break; } - // optional int32 nanos = 2; + // int32 nanos = 2; case 2: { - if (tag == 16) { - parse_nanos: + if (tag == 16u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -266,7 +237,6 @@ bool Duration::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -294,12 +264,12 @@ failure: void Duration::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Duration) - // optional int64 seconds = 1; + // int64 seconds = 1; if (this->seconds() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->seconds(), output); } - // optional int32 nanos = 2; + // int32 nanos = 2; if (this->nanos() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->nanos(), output); } @@ -311,12 +281,12 @@ void Duration::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Duration) - // optional int64 seconds = 1; + // int64 seconds = 1; if (this->seconds() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->seconds(), target); } - // optional int32 nanos = 2; + // int32 nanos = 2; if (this->nanos() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->nanos(), target); } @@ -329,14 +299,14 @@ size_t Duration::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Duration) size_t total_size = 0; - // optional int64 seconds = 1; + // int64 seconds = 1; if (this->seconds() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int64Size( this->seconds()); } - // optional int32 nanos = 2; + // int32 nanos = 2; if (this->nanos() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( @@ -352,7 +322,7 @@ size_t Duration::ByteSizeLong() const { void Duration::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Duration) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Duration* source = ::google::protobuf::internal::DynamicCastToGenerated<const Duration>( &from); @@ -361,21 +331,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Duration::MergeFrom(const Duration& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Duration) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Duration::UnsafeMergeFrom(const Duration& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.seconds() != 0) { set_seconds(from.seconds()); } @@ -395,11 +358,10 @@ void Duration::CopyFrom(const Duration& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Duration) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Duration::IsInitialized() const { - return true; } @@ -408,10 +370,13 @@ void Duration::Swap(Duration* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Duration temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Duration* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Duration::UnsafeArenaSwap(Duration* other) { @@ -422,22 +387,18 @@ void Duration::UnsafeArenaSwap(Duration* other) { void Duration::InternalSwap(Duration* other) { std::swap(seconds_, other->seconds_); std::swap(nanos_, other->nanos_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Duration::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Duration_descriptor_; - metadata.reflection = Duration_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Duration -// optional int64 seconds = 1; +// int64 seconds = 1; void Duration::clear_seconds() { seconds_ = GOOGLE_LONGLONG(0); } @@ -451,7 +412,7 @@ void Duration::set_seconds(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds) } -// optional int32 nanos = 2; +// int32 nanos = 2; void Duration::clear_nanos() { nanos_ = 0; } @@ -465,9 +426,6 @@ void Duration::set_nanos(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos) } -inline const Duration* Duration::internal_default_instance() { - return &Duration_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index 3ed1a6d3..24414d28 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -24,10 +24,17 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class Duration; +class DurationDefaultTypeInternal; +extern DurationDefaultTypeInternal _Duration_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -35,10 +42,6 @@ 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(); - -class Duration; // =================================================================== @@ -54,47 +57,52 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Duration& default_instance(); - static const Duration* internal_default_instance(); + static inline const Duration* internal_default_instance() { + return reinterpret_cast<const Duration*>( + &_Duration_default_instance_); + } void UnsafeArenaSwap(Duration* other); void Swap(Duration* other); // implements Message ---------------------------------------------- - inline Duration* New() const { return New(NULL); } + inline Duration* New() const PROTOBUF_FINAL { return New(NULL); } - Duration* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Duration* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Duration& from); void MergeFrom(const Duration& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Duration* other); - void UnsafeMergeFrom(const Duration& from); protected: explicit Duration(::google::protobuf::Arena* arena); private: @@ -109,19 +117,19 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional int64 seconds = 1; + // int64 seconds = 1; void clear_seconds(); static const int kSecondsFieldNumber = 1; ::google::protobuf::int64 seconds() const; void set_seconds(::google::protobuf::int64 value); - // optional int32 nanos = 2; + // int32 nanos = 2; void clear_nanos(); static const int kNanosFieldNumber = 2; ::google::protobuf::int32 nanos() const; @@ -139,13 +147,10 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fduration_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Duration> Duration_default_instance_; - // =================================================================== @@ -154,7 +159,7 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Duration> Duration_de #if !PROTOBUF_INLINE_NOT_IN_HEADERS // Duration -// optional int64 seconds = 1; +// int64 seconds = 1; inline void Duration::clear_seconds() { seconds_ = GOOGLE_LONGLONG(0); } @@ -168,7 +173,7 @@ inline void Duration::set_seconds(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds) } -// optional int32 nanos = 2; +// int32 nanos = 2; inline void Duration::clear_nanos() { nanos_ = 0; } @@ -182,13 +187,11 @@ inline void Duration::set_nanos(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos) } -inline const Duration* Duration::internal_default_instance() { - return &Duration_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc index f51bc9d6..d686e01e 100644 --- a/src/google/protobuf/dynamic_message.cc +++ b/src/google/protobuf/dynamic_message.cc @@ -88,11 +88,11 @@ namespace google { namespace protobuf { -using internal::WireFormat; +using internal::DynamicMapField; using internal::ExtensionSet; using internal::GeneratedMessageReflection; +using internal::InternalMetadataWithArena; using internal::MapField; -using internal::DynamicMapField; using internal::ArenaStringPtr; @@ -221,7 +221,7 @@ class DynamicMessage : public Message { int size; int has_bits_offset; int oneof_case_offset; - int unknown_fields_offset; + int internal_metadata_offset; int extensions_offset; // Not owned by the TypeInfo. @@ -231,7 +231,8 @@ class DynamicMessage : public Message { // Warning: The order in which the following pointers are defined is // important (the prototype must be deleted *before* the offsets). - google::protobuf::scoped_array<int> offsets; + google::protobuf::scoped_array<uint32> offsets; + google::protobuf::scoped_array<uint32> has_bits_indices; google::protobuf::scoped_ptr<const GeneratedMessageReflection> reflection; // Don't use a scoped_ptr to hold the prototype: the destructor for // DynamicMessage needs to know whether it is the prototype, and does so by @@ -327,14 +328,15 @@ void DynamicMessage::SharedCtor() { // Initialize oneof cases. for (int i = 0 ; i < descriptor->oneof_decl_count(); ++i) { - new(OffsetToPointer(type_info_->oneof_case_offset + sizeof(uint32) * i)) + new (OffsetToPointer(type_info_->oneof_case_offset + sizeof(uint32) * i)) uint32(0); } - new(OffsetToPointer(type_info_->unknown_fields_offset)) UnknownFieldSet; + new (OffsetToPointer(type_info_->internal_metadata_offset)) + InternalMetadataWithArena; if (type_info_->extensions_offset != -1) { - new(OffsetToPointer(type_info_->extensions_offset)) ExtensionSet; + new (OffsetToPointer(type_info_->extensions_offset)) ExtensionSet; } for (int i = 0; i < descriptor->field_count(); i++) { @@ -379,10 +381,10 @@ void DynamicMessage::SharedCtor() { if (is_prototype()) { default_value = &field->default_value_string(); } else { - default_value = - &(reinterpret_cast<const ArenaStringPtr*>( - type_info_->prototype->OffsetToPointer( - type_info_->offsets[i]))->Get(NULL)); + default_value = &(reinterpret_cast<const ArenaStringPtr*>( + type_info_->prototype->OffsetToPointer( + type_info_->offsets[i])) + ->Get()); } ArenaStringPtr* asp = new(field_ptr) ArenaStringPtr(); asp->UnsafeSetDefault(default_value); @@ -413,8 +415,9 @@ void DynamicMessage::SharedCtor() { DynamicMessage::~DynamicMessage() { const Descriptor* descriptor = type_info_->type; - reinterpret_cast<UnknownFieldSet*>( - OffsetToPointer(type_info_->unknown_fields_offset))->~UnknownFieldSet(); + reinterpret_cast<InternalMetadataWithArena*>( + OffsetToPointer(type_info_->internal_metadata_offset)) + ->~InternalMetadataWithArena(); if (type_info_->extensions_offset != -1) { reinterpret_cast<ExtensionSet*>( @@ -445,10 +448,10 @@ DynamicMessage::~DynamicMessage() { case FieldOptions::STRING: { const ::std::string* default_value = &(reinterpret_cast<const ArenaStringPtr*>( - reinterpret_cast<uint8*>( - type_info_->default_oneof_instance) - + type_info_->offsets[i]) - ->Get(NULL)); + reinterpret_cast<uint8*>( + type_info_->default_oneof_instance) + + type_info_->offsets[i]) + ->Get()); reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy( default_value, NULL); break; @@ -506,8 +509,9 @@ DynamicMessage::~DynamicMessage() { case FieldOptions::STRING: { const ::std::string* default_value = &(reinterpret_cast<const ArenaStringPtr*>( - type_info_->prototype->OffsetToPointer( - type_info_->offsets[i]))->Get(NULL)); + type_info_->prototype->OffsetToPointer( + type_info_->offsets[i])) + ->Get()); reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy( default_value, NULL); break; @@ -649,7 +653,8 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( // or not that field is set. // Compute size and offsets. - int* offsets = new int[type->field_count() + type->oneof_decl_count()]; + uint32* offsets = + new uint32[type->field_count() + type->oneof_decl_count()]; type_info->offsets.reset(offsets); // Decide all field offsets by packing in order. @@ -667,6 +672,12 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( DivideRoundingUp(type->field_count(), bitsizeof(uint32)); size += has_bits_array_size * sizeof(uint32); size = AlignOffset(size); + + uint32* has_bits_indices = new uint32[type->field_count()]; + for (int i = 0; i < type->field_count(); i++) { + has_bits_indices[i] = i; + } + type_info->has_bits_indices.reset(has_bits_indices); } // The oneof_case, if any. It is an array of uint32s. @@ -687,6 +698,8 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( } // All the fields. + // + // TODO(b/31226269): Optimize the order of fields to minimize padding. for (int i = 0; i < type->field_count(); i++) { // Make sure field is aligned to avoid bus errors. // Oneof fields do not use any space. @@ -705,10 +718,10 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( size += kMaxOneofUnionSize; } - // Add the UnknownFieldSet to the end. + // Add the InternalMetadataWithArena to the end. size = AlignOffset(size); - type_info->unknown_fields_offset = size; - size += sizeof(UnknownFieldSet); + type_info->internal_metadata_offset = size; + size += sizeof(InternalMetadataWithArena); // Align the final size to make sure no clever allocators think that // alignment is not necessary. @@ -728,6 +741,10 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( DynamicMessage* prototype = new(base) DynamicMessage(type_info); // Construct the reflection object. + + void* default_oneof_instance = NULL; + int oneof_case_offset = -1; + if (type->oneof_decl_count() > 0) { // Compute the size of default oneof instance and offsets of default // oneof fields. @@ -746,19 +763,24 @@ 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 */)); - } 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 */)); + default_oneof_instance = type_info->default_oneof_instance; + oneof_case_offset = type_info->oneof_case_offset; } + + internal::ReflectionSchema schema = { + type_info->prototype, + type_info->offsets.get(), + type_info->has_bits_indices.get(), + type_info->has_bits_offset, + type_info->internal_metadata_offset, + type_info->extensions_offset, + default_oneof_instance, + oneof_case_offset, + type_info->size}; + + type_info->reflection.reset(new GeneratedMessageReflection( + type_info->type, schema, type_info->pool, this)); + // Cross link prototypes. prototype->CrossLinkPrototypes(); @@ -767,7 +789,7 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( void DynamicMessageFactory::ConstructDefaultOneofInstance( const Descriptor* type, - const int offsets[], + const uint32 offsets[], void* default_oneof_instance) { for (int i = 0; i < type->oneof_decl_count(); i++) { for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) { @@ -813,7 +835,7 @@ void DynamicMessageFactory::ConstructDefaultOneofInstance( void DynamicMessageFactory::DeleteDefaultOneofInstance( const Descriptor* type, - const int offsets[], + const uint32 offsets[], void* default_oneof_instance) { for (int i = 0; i < type->oneof_decl_count(); i++) { for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) { diff --git a/src/google/protobuf/dynamic_message.h b/src/google/protobuf/dynamic_message.h index f74cd7dd..7ff80f26 100644 --- a/src/google/protobuf/dynamic_message.h +++ b/src/google/protobuf/dynamic_message.h @@ -136,11 +136,11 @@ class LIBPROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory { // Construct default oneof instance for reflection usage if oneof // is defined. static void ConstructDefaultOneofInstance(const Descriptor* type, - const int offsets[], + const uint32 offsets[], void* default_oneof_instance); // Delete default oneof instance. Called by ~DynamicMessageFactory. static void DeleteDefaultOneofInstance(const Descriptor* type, - const int offsets[], + const uint32 offsets[], void* default_oneof_instance); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory); diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index f19bf2a6..19f4aefe 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -19,82 +19,85 @@ namespace google { namespace protobuf { +class EmptyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Empty> {}; +EmptyDefaultTypeInternal _Empty_default_instance_; namespace { -const ::google::protobuf::Descriptor* Empty_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Empty_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/empty.proto"); - GOOGLE_CHECK(file != NULL); - Empty_descriptor_ = file->message_type(0); - static const int Empty_offsets_[1] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fempty_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fempty_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ }; - Empty_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Empty_descriptor_, - Empty::internal_default_instance(), - Empty_offsets_, - -1, - -1, - -1, - sizeof(Empty), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Empty)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Empty_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/empty.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fempty_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Empty_descriptor_, Empty::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto() { - Empty_default_instance_.Shutdown(); - delete Empty_reflection_; + _Empty_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - Empty_default_instance_.DefaultConstruct(); - Empty_default_instance_.get_mutable()->InitAsDefaultInstance(); + ::google::protobuf::internal::InitProtobufDefaults(); + _Empty_default_instance_.DefaultConstruct(); } -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); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&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(); + static const char descriptor[] = { + "\n\033google/protobuf/empty.proto\022\017google.pr" + "otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n" + "EmptyProtoP\001Z\'github.com/golang/protobuf" + "/ptypes/empty\370\001\001\242\002\003GPB\252\002\036Google.Protobuf" + ".WellKnownTypesb\006proto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\033google/protobuf/empty.proto\022\017google.pr" - "otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n" - "EmptyProtoP\001Z\'github.com/golang/protobuf" - "/ptypes/empty\370\001\001\242\002\003GPB\252\002\036Google.Protobuf" - ".WellKnownTypesb\006proto3", 183); + descriptor, 183); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/empty.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto); @@ -112,16 +115,6 @@ 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 @@ -129,7 +122,9 @@ static void MergeFromFail(int line) { Empty::Empty() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Empty) } @@ -143,15 +138,11 @@ Empty::Empty(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Empty) } - -void Empty::InitAsDefaultInstance() { -} - Empty::Empty(const Empty& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.Empty) } @@ -185,7 +176,7 @@ void Empty::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Empty::descriptor() { protobuf_AssignDescriptorsOnce(); - return Empty_descriptor_; + return file_level_metadata[0].descriptor; } const Empty& Empty::default_instance() { @@ -193,8 +184,6 @@ const Empty& Empty::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Empty> Empty_default_instance_; - Empty* Empty::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Empty>(arena); } @@ -209,7 +198,7 @@ bool Empty::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Empty) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; handle_unusual: @@ -256,7 +245,7 @@ size_t Empty::ByteSizeLong() const { void Empty::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Empty) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Empty* source = ::google::protobuf::internal::DynamicCastToGenerated<const Empty>( &from); @@ -265,21 +254,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Empty::MergeFrom(const Empty& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Empty) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Empty::UnsafeMergeFrom(const Empty& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); } void Empty::CopyFrom(const ::google::protobuf::Message& from) { @@ -293,11 +275,10 @@ void Empty::CopyFrom(const Empty& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Empty) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Empty::IsInitialized() const { - return true; } @@ -306,10 +287,13 @@ void Empty::Swap(Empty* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Empty temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Empty* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Empty::UnsafeArenaSwap(Empty* other) { @@ -318,24 +302,17 @@ void Empty::UnsafeArenaSwap(Empty* other) { InternalSwap(other); } void Empty::InternalSwap(Empty* other) { - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Empty::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Empty_descriptor_; - metadata.reflection = Empty_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Empty -inline const Empty* Empty::internal_default_instance() { - return &Empty_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 29309366..e2aca67d 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -24,10 +24,17 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class Empty; +class EmptyDefaultTypeInternal; +extern EmptyDefaultTypeInternal _Empty_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -35,10 +42,6 @@ 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(); - -class Empty; // =================================================================== @@ -54,47 +57,52 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Empty& default_instance(); - static const Empty* internal_default_instance(); + static inline const Empty* internal_default_instance() { + return reinterpret_cast<const Empty*>( + &_Empty_default_instance_); + } void UnsafeArenaSwap(Empty* other); void Swap(Empty* other); // implements Message ---------------------------------------------- - inline Empty* New() const { return New(NULL); } + inline Empty* New() const PROTOBUF_FINAL { return New(NULL); } - Empty* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Empty* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Empty& from); void MergeFrom(const Empty& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Empty* other); - void UnsafeMergeFrom(const Empty& from); protected: explicit Empty(::google::protobuf::Arena* arena); private: @@ -109,7 +117,7 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -125,13 +133,10 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fempty_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Empty> Empty_default_instance_; - // =================================================================== @@ -140,13 +145,11 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Empty> Empty_default_ #if !PROTOBUF_INLINE_NOT_IN_HEADERS // Empty -inline const Empty* Empty::internal_default_instance() { - return &Empty_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc index ad164e3e..955c079b 100644 --- a/src/google/protobuf/extension_set.cc +++ b/src/google/protobuf/extension_set.cc @@ -76,7 +76,7 @@ inline bool is_packable(WireFormatLite::WireType type) { } // Registry stuff. -typedef hash_map<pair<const MessageLite*, int>, +typedef hash_map<std::pair<const MessageLite*, int>, ExtensionInfo> ExtensionRegistry; ExtensionRegistry* registry_ = NULL; GOOGLE_PROTOBUF_DECLARE_ONCE(registry_init_); @@ -1371,7 +1371,7 @@ size_t ExtensionSet::ByteSize() const { bool ExtensionSet::MaybeNewExtension(int number, const FieldDescriptor* descriptor, Extension** result) { - pair<ExtensionMap::iterator, bool> insert_result = + std::pair<ExtensionMap::iterator, bool> insert_result = extensions_.insert(std::make_pair(number, Extension())); *result = &insert_result.first->second; (*result)->descriptor = descriptor; diff --git a/src/google/protobuf/extension_set_heavy.cc b/src/google/protobuf/extension_set_heavy.cc index 1bbc8fef..2c37ade9 100644 --- a/src/google/protobuf/extension_set_heavy.cc +++ b/src/google/protobuf/extension_set_heavy.cc @@ -656,7 +656,7 @@ bool ExtensionSet::ParseMessageSetItem(io::CodedInputStream* input, string message_data; while (true) { - const uint32 tag = input->ReadTag(); + const uint32 tag = input->ReadTagNoLastTag(); if (tag == 0) return false; switch (tag) { diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc index a70a2ff6..d6b823c0 100644 --- a/src/google/protobuf/extension_set_unittest.cc +++ b/src/google/protobuf/extension_set_unittest.cc @@ -331,7 +331,7 @@ TEST(ExtensionSetTest, SwapExtension) { unittest::TestAllExtensions message2; TestUtil::SetAllExtensions(&message1); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; // Swap empty fields. const Reflection* reflection = message1.GetReflection(); @@ -363,7 +363,7 @@ TEST(ExtensionSetTest, SwapExtensionWithEmpty) { TestUtil::SetAllExtensions(&message3); const Reflection* reflection = message3.GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message3, &fields); reflection->SwapFields(&message1, &message2, fields); @@ -380,7 +380,7 @@ TEST(ExtensionSetTest, SwapExtensionBothFull) { TestUtil::SetAllExtensions(&message2); const Reflection* reflection = message1.GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message1, &fields); reflection->SwapFields(&message1, &message2, fields); @@ -490,7 +490,7 @@ TEST(ExtensionSetTest, SwapFieldsOfExtensionBothFullWithArena) { TestUtil::SetAllExtensions(message2); const Reflection* reflection = message1->GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(*message1, &fields); reflection->SwapFields(message1, message2, fields); TestUtil::ExpectAllExtensionsSet(*message1); @@ -504,7 +504,7 @@ TEST(ExtensionSetTest, SwapExtensionWithSelf) { TestUtil::SetAllExtensions(&message1); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; const Reflection* reflection = message1.GetReflection(); reflection->ListFields(message1, &fields); reflection->SwapFields(&message1, &message1, fields); diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index 5d80d297..b7925b88 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -19,84 +19,87 @@ namespace google { namespace protobuf { +class FieldMaskDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> {}; +FieldMaskDefaultTypeInternal _FieldMask_default_instance_; namespace { -const ::google::protobuf::Descriptor* FieldMask_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FieldMask_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/field_mask.proto"); - GOOGLE_CHECK(file != NULL); - FieldMask_descriptor_ = file->message_type(0); - static const int FieldMask_offsets_[1] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ffield_5fmask_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ffield_5fmask_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, paths_), }; - FieldMask_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FieldMask_descriptor_, - FieldMask::internal_default_instance(), - FieldMask_offsets_, - -1, - -1, - -1, - sizeof(FieldMask), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(FieldMask)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_FieldMask_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/field_mask.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2ffield_5fmask_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldMask_descriptor_, FieldMask::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto() { - FieldMask_default_instance_.Shutdown(); - delete FieldMask_reflection_; + _FieldMask_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } 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::internal::InitProtobufDefaults(); + _FieldMask_default_instance_.DefaultConstruct(); } -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); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&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(); + static const char descriptor[] = { + "\n google/protobuf/field_mask.proto\022\017goog" + "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB" + "\211\001\n\023com.google.protobufB\016FieldMaskProtoP" + "\001Z9google.golang.org/genproto/protobuf/f" + "ield_mask;field_mask\242\002\003GPB\252\002\036Google.Prot" + "obuf.WellKnownTypesb\006proto3" + }; ::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" - "N\n\023com.google.protobufB\016FieldMaskProtoP\001" - "\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb" - "\006proto3", 167); + descriptor, 227); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/field_mask.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto); @@ -114,16 +117,6 @@ 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 @@ -132,19 +125,18 @@ const int FieldMask::kPathsFieldNumber; FieldMask::FieldMask() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldMask) } - -void FieldMask::InitAsDefaultInstance() { -} - FieldMask::FieldMask(const FieldMask& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + paths_(from.paths_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldMask) } @@ -167,7 +159,7 @@ void FieldMask::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FieldMask::descriptor() { protobuf_AssignDescriptorsOnce(); - return FieldMask_descriptor_; + return file_level_metadata[0].descriptor; } const FieldMask& FieldMask::default_instance() { @@ -175,8 +167,6 @@ const FieldMask& FieldMask::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FieldMask> FieldMask_default_instance_; - FieldMask* FieldMask::New(::google::protobuf::Arena* arena) const { FieldMask* n = new FieldMask; if (arena != NULL) { @@ -196,14 +186,13 @@ bool FieldMask::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FieldMask) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated string paths = 1; case 1: { - if (tag == 10) { - parse_paths: + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_paths())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -214,8 +203,6 @@ bool FieldMask::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_paths; - if (input->ExpectAtEnd()) goto success; break; } @@ -295,7 +282,7 @@ size_t FieldMask::ByteSizeLong() const { void FieldMask::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldMask) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FieldMask* source = ::google::protobuf::internal::DynamicCastToGenerated<const FieldMask>( &from); @@ -304,22 +291,15 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FieldMask::MergeFrom(const FieldMask& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldMask) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void FieldMask::UnsafeMergeFrom(const FieldMask& from) { - GOOGLE_DCHECK(&from != this); - paths_.UnsafeMergeFrom(from.paths_); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + paths_.MergeFrom(from.paths_); } void FieldMask::CopyFrom(const ::google::protobuf::Message& from) { @@ -333,11 +313,10 @@ void FieldMask::CopyFrom(const FieldMask& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldMask) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FieldMask::IsInitialized() const { - return true; } @@ -347,16 +326,12 @@ void FieldMask::Swap(FieldMask* other) { } void FieldMask::InternalSwap(FieldMask* other) { paths_.UnsafeArenaSwap(&other->paths_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata FieldMask::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FieldMask_descriptor_; - metadata.reflection = FieldMask_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -417,9 +392,6 @@ FieldMask::mutable_paths() { return &paths_; } -inline const FieldMask* FieldMask::internal_default_instance() { - return &FieldMask_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 17cb6bbf..6b4c5f99 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -24,10 +24,17 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class FieldMask; +class FieldMaskDefaultTypeInternal; +extern FieldMaskDefaultTypeInternal _FieldMask_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -35,10 +42,6 @@ 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(); - -class FieldMask; // =================================================================== @@ -57,49 +60,52 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro static const ::google::protobuf::Descriptor* descriptor(); static const FieldMask& default_instance(); - static const FieldMask* internal_default_instance(); + static inline const FieldMask* internal_default_instance() { + return reinterpret_cast<const FieldMask*>( + &_FieldMask_default_instance_); + } void Swap(FieldMask* other); // implements Message ---------------------------------------------- - inline FieldMask* New() const { return New(NULL); } + inline FieldMask* New() const PROTOBUF_FINAL { return New(NULL); } - FieldMask* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FieldMask* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FieldMask& from); void MergeFrom(const FieldMask& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FieldMask* other); - void UnsafeMergeFrom(const FieldMask& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -129,13 +135,10 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ffield_5fmask_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> FieldMask_default_instance_; - // =================================================================== @@ -199,13 +202,11 @@ FieldMask::mutable_paths() { return &paths_; } -inline const FieldMask* FieldMask::internal_default_instance() { - return &FieldMask_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/field_mask.proto b/src/google/protobuf/field_mask.proto index b6d32a79..c68d247c 100644 --- a/src/google/protobuf/field_mask.proto +++ b/src/google/protobuf/field_mask.proto @@ -37,6 +37,7 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "FieldMaskProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; +option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask"; // `FieldMask` represents a set of symbolic field paths, for example: // diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index 6f418433..08742232 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -44,6 +44,7 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/map_field.h> #include <google/protobuf/repeated_field.h> +// #include "google/protobuf/bridge/compatibility_mode_support.h" #define GOOGLE_PROTOBUF_HAS_ONEOF @@ -84,6 +85,22 @@ inline bool SupportsArenas(const Descriptor* descriptor) { namespace { +template <class To> +To* GetPointerAtOffset(Message* message, uint32 offset) { + return reinterpret_cast<To*>(reinterpret_cast<char*>(message) + offset); +} + +template <class To> +const To* GetConstPointerAtOffset(const Message* message, uint32 offset) { + return reinterpret_cast<const To*>(reinterpret_cast<const char*>(message) + + offset); +} + +template <class To> +const To& GetConstRefAtOffset(const Message& message, uint32 offset) { + return *GetConstPointerAtOffset<To>(&message, offset); +} + void ReportReflectionUsageError( const Descriptor* descriptor, const FieldDescriptor* field, const char* method, const char* description) { @@ -173,43 +190,25 @@ 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) - : 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) + const Descriptor* descriptor, const ReflectionSchema& schema, + const DescriptorPool* pool, MessageFactory* factory) : 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) {} + schema_(schema), + descriptor_pool_((pool == NULL) ? DescriptorPool::generated_pool() + : pool), + message_factory_(factory), + // TODO(haberman) remove this when upb is using our table driven. + default_instance_(schema_.default_instance_), + default_oneof_instance_(schema_.default_oneof_instance_), + offsets_(schema_.offsets_), + has_bits_indices_(schema_.has_bit_indices_), + has_bits_offset_(schema_.has_bits_offset_), + oneof_case_offset_(schema_.oneof_case_offset_), + unknown_fields_offset_(-1), + extensions_offset_(schema_.extensions_offset_), + arena_offset_(schema_.metadata_offset_), + object_size_(schema_.object_size_) { +} GeneratedMessageReflection::~GeneratedMessageReflection() {} @@ -236,39 +235,33 @@ const UnknownFieldSet& GetEmptyUnknownFieldSet() { const UnknownFieldSet& GeneratedMessageReflection::GetUnknownFields( const Message& message) const { if (descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) { + // We have to ensure that any mutations made to the return value of + // MutableUnknownFields() are not reflected here. return GetEmptyUnknownFieldSet(); - } - if (unknown_fields_offset_ == kUnknownFieldSetInMetadata) { + } else { return GetInternalMetadataWithArena(message).unknown_fields(); } - const void* ptr = reinterpret_cast<const uint8*>(&message) + - unknown_fields_offset_; - return *reinterpret_cast<const UnknownFieldSet*>(ptr); } UnknownFieldSet* GeneratedMessageReflection::MutableUnknownFields( Message* message) const { - if (unknown_fields_offset_ == kUnknownFieldSetInMetadata) { - return MutableInternalMetadataWithArena(message)-> - mutable_unknown_fields(); - } - void* ptr = reinterpret_cast<uint8*>(message) + unknown_fields_offset_; - return reinterpret_cast<UnknownFieldSet*>(ptr); + return MutableInternalMetadataWithArena(message)->mutable_unknown_fields(); } int GeneratedMessageReflection::SpaceUsed(const Message& message) const { // object_size_ already includes the in-memory representation of each field // in the message, so we only need to account for additional memory used by // the fields. - int total_size = object_size_; + int total_size = schema_.GetObjectSize(); total_size += GetUnknownFields(message).SpaceUsedExcludingSelf(); - if (extensions_offset_ != -1) { + if (schema_.HasExtensionSet()) { total_size += GetExtensionSet(message).SpaceUsedExcludingSelf(); } - for (int i = 0; i < descriptor_->field_count(); i++) { + const int field_count = descriptor_->field_count(); + for (int i = 0; i < field_count; i++) { const FieldDescriptor* field = descriptor_->field(i); if (field->is_repeated()) { @@ -337,9 +330,9 @@ int GeneratedMessageReflection::SpaceUsed(const Message& message) const { // the prototype. Only count the string if it has been changed // from the default value. const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); + &DefaultRaw<ArenaStringPtr>(field).Get(); const string* ptr = - &GetField<ArenaStringPtr>(message, field).Get(default_ptr); + &GetField<ArenaStringPtr>(message, field).Get(); if (ptr != default_ptr) { // string fields are represented by just a pointer, so also @@ -353,7 +346,7 @@ int GeneratedMessageReflection::SpaceUsed(const Message& message) const { } case FieldDescriptor::CPPTYPE_MESSAGE: - if (&message == default_instance_) { + if (schema_.IsDefaultInstance(message)) { // For singular fields, the prototype just stores a pointer to the // external type's prototype, so there is no extra memory usage. } else { @@ -475,9 +468,9 @@ void GeneratedMessageReflection::SwapField( string1->Swap(string2); } else { const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); - const string temp = string1->Get(default_ptr); - string1->Set(default_ptr, string2->Get(default_ptr), arena1); + &DefaultRaw<ArenaStringPtr>(field).Get(); + const string temp = string1->Get(); + string1->Set(default_ptr, string2->Get(), arena1); string2->Set(default_ptr, temp, arena2); } } @@ -638,16 +631,16 @@ void GeneratedMessageReflection::Swap( // Slow copy path. // Use our arena as temp space, if available. Message* temp = message1->New(GetArena(message1)); - temp->MergeFrom(*message1); - message1->CopyFrom(*message2); - message2->CopyFrom(*temp); + temp->MergeFrom(*message2); + message2->CopyFrom(*message1); + Swap(message1, temp); if (GetArena(message1) == NULL) { delete temp; } return; } - if (has_bits_offset_ != -1) { + if (schema_.HasHasbits()) { uint32* has_bits1 = MutableHasBits(message1); uint32* has_bits2 = MutableHasBits(message2); int has_bits_size = (descriptor_->field_count() + 31) / 32; @@ -657,18 +650,20 @@ void GeneratedMessageReflection::Swap( } } - for (int i = 0; i < descriptor_->field_count(); i++) { + const int field_count = descriptor_->field_count(); + for (int i = 0; i < field_count; i++) { const FieldDescriptor* field = descriptor_->field(i); if (!field->containing_oneof()) { SwapField(message1, message2, field); } } - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { + const int oneof_decl_count = descriptor_->oneof_decl_count(); + for (int i = 0; i < oneof_decl_count; i++) { SwapOneofField(message1, message2, descriptor_->oneof_decl(i)); } - if (extensions_offset_ != -1) { + if (schema_.HasExtensionSet()) { MutableExtensionSet(message1)->Swap(MutableExtensionSet(message2)); } @@ -678,7 +673,7 @@ void GeneratedMessageReflection::Swap( void GeneratedMessageReflection::SwapFields( Message* message1, Message* message2, - const vector<const FieldDescriptor*>& fields) const { + const std::vector<const FieldDescriptor*>& fields) const { if (message1 == message2) return; // TODO(kenton): Other Reflection methods should probably check this too. @@ -699,7 +694,8 @@ void GeneratedMessageReflection::SwapFields( std::set<int> swapped_oneof; - for (int i = 0; i < fields.size(); i++) { + const int fields_size = static_cast<int>(fields.size()); + for (int i = 0; i < fields_size; i++) { const FieldDescriptor* field = fields[i]; if (field->is_extension()) { MutableExtensionSet(message1)->SwapExtension( @@ -821,9 +817,9 @@ void GeneratedMessageReflection::ClearField( default: // TODO(kenton): Support other string reps. case FieldOptions::STRING: { const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); - MutableRaw<ArenaStringPtr>(message, field)->Destroy(default_ptr, - GetArena(message)); + &DefaultRaw<ArenaStringPtr>(field).Get(); + MutableRaw<ArenaStringPtr>(message, field)->SetAllocated( + default_ptr, NULL, GetArena(message)); break; } } @@ -831,7 +827,7 @@ void GeneratedMessageReflection::ClearField( } case FieldDescriptor::CPPTYPE_MESSAGE: - if (has_bits_offset_ == -1) { + if (!schema_.HasHasbits()) { // Proto3 does not have has-bits and we need to set a message field // to NULL in order to indicate its un-presence. if (GetArena(message) == NULL) { @@ -1008,28 +1004,35 @@ struct FieldNumberSorter { } }; -inline bool IsIndexInHasBitSet(const uint32* has_bit_set, uint32 index) { - return ((has_bit_set[index / 32] >> (index % 32)) & static_cast<uint32>(1)) - != 0; +inline bool IsIndexInHasBitSet( + const uint32* has_bit_set, uint32 has_bit_index) { + return ((has_bit_set[has_bit_index / 32] >> (has_bit_index % 32)) & + static_cast<uint32>(1)) != 0; } } // namespace void GeneratedMessageReflection::ListFields( const Message& message, - vector<const FieldDescriptor*>* output) const { + std::vector<const FieldDescriptor*>* output) const { output->clear(); // Optimization: The default instance never has any fields set. - if (&message == default_instance_) return; + if (schema_.IsDefaultInstance(message)) 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++) { + // within the field loop. We allow this violation of ReflectionSchema + // encapsulation because this function takes a noticable about of CPU + // fleetwide and properly allowing this optimization through public interfaces + // seems more trouble than it is worth. + const uint32* const has_bits = + schema_.HasHasbits() ? GetHasBits(message) : NULL; + const uint32* const has_bits_indices = schema_.has_bit_indices_; + const uint32* const oneof_case_array = + &GetConstRefAtOffset<uint32>(message, schema_.oneof_case_offset_); + + const int field_count = descriptor_->field_count(); + output->reserve(field_count); + for (int i = 0; i < field_count; i++) { const FieldDescriptor* field = descriptor_->field(i); if (field->is_repeated()) { if (FieldSize(message, field) > 0) { @@ -1044,7 +1047,7 @@ void GeneratedMessageReflection::ListFields( } } else if (has_bits) { // Equivalent to: HasBit(message, field) - if (IsIndexInHasBitSet(has_bits, i)) { + if (IsIndexInHasBitSet(has_bits, has_bits_indices[i])) { output->push_back(field); } } else if (HasBit(message, field)) { // Fall back on proto3-style HasBit. @@ -1053,7 +1056,7 @@ void GeneratedMessageReflection::ListFields( } } - if (extensions_offset_ != -1) { + if (schema_.HasExtensionSet()) { GetExtensionSet(message).AppendToList(descriptor_, descriptor_pool_, output); } @@ -1147,9 +1150,7 @@ string GeneratedMessageReflection::GetString( switch (field->options().ctype()) { default: // TODO(kenton): Support other string reps. case FieldOptions::STRING: { - const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); - return GetField<ArenaStringPtr>(message, field).Get(default_ptr); + return GetField<ArenaStringPtr>(message, field).Get(); } } @@ -1169,9 +1170,7 @@ const string& GeneratedMessageReflection::GetStringReference( switch (field->options().ctype()) { default: // TODO(kenton): Support other string reps. case FieldOptions::STRING: { - const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); - return GetField<ArenaStringPtr>(message, field).Get(default_ptr); + return GetField<ArenaStringPtr>(message, field).Get(); } } @@ -1192,8 +1191,7 @@ void GeneratedMessageReflection::SetString( switch (field->options().ctype()) { default: // TODO(kenton): Support other string reps. case FieldOptions::STRING: { - const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); + const string* default_ptr = &DefaultRaw<ArenaStringPtr>(field).Get(); if (field->containing_oneof() && !HasOneofField(*message, field)) { ClearOneof(message, field->containing_oneof()); MutableField<ArenaStringPtr>(message, field)->UnsafeSetDefault( @@ -1727,11 +1725,10 @@ void* GeneratedMessageReflection::MutableRawRepeatedField( } else { // Trigger transform for MapField if (IsMapFieldInApi(field)) { - return reinterpret_cast<MapFieldBase*>(reinterpret_cast<uint8*>(message) + - offsets_[field->index()]) + return MutableRawNonOneof<MapFieldBase>(message, field) ->MutableRepeatedField(); } - return reinterpret_cast<uint8*>(message) + offsets_[field->index()]; + return MutableRawNonOneof<void>(message, field); } } @@ -1758,11 +1755,9 @@ const void* GeneratedMessageReflection::GetRawRepeatedField( } else { // Trigger transform for MapField if (IsMapFieldInApi(field)) { - return &(reinterpret_cast<const MapFieldBase*>( - reinterpret_cast<const uint8*>(&message) + - offsets_[field->index()])->GetRepeatedField()); + return &(GetRawNonOneof<MapFieldBase>(message, field).GetRepeatedField()); } - return reinterpret_cast<const uint8*>(&message) + offsets_[field->index()]; + return &GetRawNonOneof<char>(message, field); } } @@ -1844,7 +1839,7 @@ int GeneratedMessageReflection::MapSize( const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByName( const string& name) const { - if (extensions_offset_ == -1) return NULL; + if (!schema_.HasExtensionSet()) return NULL; const FieldDescriptor* result = descriptor_pool_->FindExtensionByName(name); if (result != NULL && result->containing_type() == descriptor_) { @@ -1856,7 +1851,8 @@ const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByName( const Descriptor* type = descriptor_pool_->FindMessageTypeByName(name); if (type != NULL) { // Look for a matching extension in the foreign type's scope. - for (int i = 0; i < type->extension_count(); i++) { + const int type_extension_count = type->extension_count(); + for (int i = 0; i < type_extension_count; i++) { const FieldDescriptor* extension = type->extension(i); if (extension->containing_type() == descriptor_ && extension->type() == FieldDescriptor::TYPE_MESSAGE && @@ -1874,7 +1870,7 @@ const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByName( const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByNumber( int number) const { - if (extensions_offset_ == -1) return NULL; + if (!schema_.HasExtensionSet()) return NULL; return descriptor_pool_->FindExtensionByNumber(descriptor_, number); } @@ -1887,202 +1883,176 @@ bool GeneratedMessageReflection::SupportsUnknownEnumValues() const { // These simple template accessors obtain pointers (or references) to // the given field. + +template <class Type> +const Type& GeneratedMessageReflection::GetRawNonOneof( + const Message& message, const FieldDescriptor* field) const { + return GetConstRefAtOffset<Type>(message, + schema_.GetFieldOffsetNonOneof(field)); +} + +template <class Type> +Type* GeneratedMessageReflection::MutableRawNonOneof( + Message* message, const FieldDescriptor* field) const { + return GetPointerAtOffset<Type>(message, + schema_.GetFieldOffsetNonOneof(field)); +} + template <typename Type> -inline const Type& GeneratedMessageReflection::GetRaw( +const Type& GeneratedMessageReflection::GetRaw( const Message& message, const FieldDescriptor* field) const { if (field->containing_oneof() && !HasOneofField(message, field)) { return DefaultRaw<Type>(field); } - int index = field->containing_oneof() ? - descriptor_->field_count() + field->containing_oneof()->index() : - field->index(); - const void* ptr = reinterpret_cast<const uint8*>(&message) + - offsets_[index]; - return *reinterpret_cast<const Type*>(ptr); + return GetConstRefAtOffset<Type>(message, schema_.GetFieldOffset(field)); } template <typename Type> -inline Type* GeneratedMessageReflection::MutableRaw( - Message* message, const FieldDescriptor* field) const { - int index = field->containing_oneof() ? - descriptor_->field_count() + field->containing_oneof()->index() : - field->index(); - void* ptr = reinterpret_cast<uint8*>(message) + offsets_[index]; - return reinterpret_cast<Type*>(ptr); +Type* GeneratedMessageReflection::MutableRaw(Message* message, + const FieldDescriptor* field) const { + return GetPointerAtOffset<Type>(message, schema_.GetFieldOffset(field)); } -template <typename Type> -inline const Type& GeneratedMessageReflection::DefaultRaw( - const FieldDescriptor* field) const { - const void* ptr = field->containing_oneof() ? - reinterpret_cast<const uint8*>(default_oneof_instance_) + - offsets_[field->index()] : - reinterpret_cast<const uint8*>(default_instance_) + - offsets_[field->index()]; - return *reinterpret_cast<const Type*>(ptr); -} inline const uint32* GeneratedMessageReflection::GetHasBits( const Message& message) const { - if (has_bits_offset_ == -1) { // proto3 with no has-bits. - return NULL; - } - const void* ptr = reinterpret_cast<const uint8*>(&message) + has_bits_offset_; - return reinterpret_cast<const uint32*>(ptr); + GOOGLE_DCHECK(schema_.HasHasbits()); + return &GetConstRefAtOffset<uint32>(message, schema_.HasBitsOffset()); } + inline uint32* GeneratedMessageReflection::MutableHasBits( Message* message) const { - if (has_bits_offset_ == -1) { - return NULL; - } - void* ptr = reinterpret_cast<uint8*>(message) + has_bits_offset_; - return reinterpret_cast<uint32*>(ptr); + GOOGLE_DCHECK(schema_.HasHasbits()); + return GetPointerAtOffset<uint32>(message, schema_.HasBitsOffset()); } inline uint32 GeneratedMessageReflection::GetOneofCase( - const Message& message, - const OneofDescriptor* oneof_descriptor) const { - const void* ptr = reinterpret_cast<const uint8*>(&message) - + oneof_case_offset_; - return reinterpret_cast<const uint32*>(ptr)[oneof_descriptor->index()]; + const Message& message, const OneofDescriptor* oneof_descriptor) const { + return GetConstRefAtOffset<uint32>( + message, schema_.GetOneofCaseOffset(oneof_descriptor)); } inline uint32* GeneratedMessageReflection::MutableOneofCase( - Message* message, - const OneofDescriptor* oneof_descriptor) const { - void* ptr = reinterpret_cast<uint8*>(message) + oneof_case_offset_; - return &(reinterpret_cast<uint32*>(ptr)[oneof_descriptor->index()]); + Message* message, const OneofDescriptor* oneof_descriptor) const { + return GetPointerAtOffset<uint32>( + message, schema_.GetOneofCaseOffset(oneof_descriptor)); } inline const ExtensionSet& GeneratedMessageReflection::GetExtensionSet( const Message& message) const { - GOOGLE_DCHECK_NE(extensions_offset_, -1); - const void* ptr = reinterpret_cast<const uint8*>(&message) + - extensions_offset_; - return *reinterpret_cast<const ExtensionSet*>(ptr); + return GetConstRefAtOffset<ExtensionSet>(message, + schema_.GetExtensionSetOffset()); } + inline ExtensionSet* GeneratedMessageReflection::MutableExtensionSet( Message* message) const { - GOOGLE_DCHECK_NE(extensions_offset_, -1); - void* ptr = reinterpret_cast<uint8*>(message) + extensions_offset_; - return reinterpret_cast<ExtensionSet*>(ptr); + return GetPointerAtOffset<ExtensionSet>(message, + schema_.GetExtensionSetOffset()); } inline Arena* GeneratedMessageReflection::GetArena(Message* message) const { - if (arena_offset_ == kNoArenaPointer) { - return NULL; - } - - if (unknown_fields_offset_ == kUnknownFieldSetInMetadata) { - // zero-overhead arena pointer overloading UnknownFields - return GetInternalMetadataWithArena(*message).arena(); - } - - // Baseline case: message class has a dedicated arena pointer. - void* ptr = reinterpret_cast<uint8*>(message) + arena_offset_; - return *reinterpret_cast<Arena**>(ptr); + return GetInternalMetadataWithArena(*message).arena(); } inline const InternalMetadataWithArena& GeneratedMessageReflection::GetInternalMetadataWithArena( const Message& message) const { - const void* ptr = reinterpret_cast<const uint8*>(&message) + arena_offset_; - return *reinterpret_cast<const InternalMetadataWithArena*>(ptr); + return GetConstRefAtOffset<InternalMetadataWithArena>( + message, schema_.GetMetadataOffset()); } inline InternalMetadataWithArena* GeneratedMessageReflection::MutableInternalMetadataWithArena( Message* message) const { - void* ptr = reinterpret_cast<uint8*>(message) + arena_offset_; - return reinterpret_cast<InternalMetadataWithArena*>(ptr); + return GetPointerAtOffset<InternalMetadataWithArena>( + message, schema_.GetMetadataOffset()); } -inline bool -GeneratedMessageReflection::GetIsDefaultInstance( - const Message& message) const { - return &message == default_instance_; +template <typename Type> +inline const Type& GeneratedMessageReflection::DefaultRaw( + const FieldDescriptor* field) const { + return *reinterpret_cast<const Type*>(schema_.GetFieldDefault(field)); } // Simple accessors for manipulating has_bits_. inline bool GeneratedMessageReflection::HasBit( const Message& message, const FieldDescriptor* field) const { - if (has_bits_offset_ == -1) { - // proto3: no has-bits. All fields present except messages, which are - // present only if their message-field pointer is non-NULL. - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - return !GetIsDefaultInstance(message) && - GetRaw<const Message*>(message, field) != NULL; - } else { - // Non-message field (and non-oneof, since that was handled in HasField() - // before calling us), and singular (again, checked in HasField). So, this - // field must be a scalar. - - // Scalar primitive (numeric or string/bytes) fields are present if - // their value is non-zero (numeric) or non-empty (string/bytes). N.B.: - // we must use this definition here, rather than the "scalar fields - // always present" in the proto3 docs, because MergeFrom() semantics - // require presence as "present on wire", and reflection-based merge - // (which uses HasField()) needs to be consistent with this. - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_STRING: - switch (field->options().ctype()) { - default: { - const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); - return GetField<ArenaStringPtr>(message, field).Get( - default_ptr).size() > 0; - } + if (schema_.HasHasbits()) { + return IsIndexInHasBitSet(GetHasBits(message), schema_.HasBitIndex(field)); + } + + // proto3: no has-bits. All fields present except messages, which are + // present only if their message-field pointer is non-NULL. + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + return !schema_.IsDefaultInstance(message) && + GetRaw<const Message*>(message, field) != NULL; + } else { + // Non-message field (and non-oneof, since that was handled in HasField() + // before calling us), and singular (again, checked in HasField). So, this + // field must be a scalar. + + // Scalar primitive (numeric or string/bytes) fields are present if + // their value is non-zero (numeric) or non-empty (string/bytes). N.B.: + // we must use this definition here, rather than the "scalar fields + // always present" in the proto3 docs, because MergeFrom() semantics + // require presence as "present on wire", and reflection-based merge + // (which uses HasField()) needs to be consistent with this. + switch (field->cpp_type()) { + case FieldDescriptor::CPPTYPE_STRING: + switch (field->options().ctype()) { + default: { + return GetField<ArenaStringPtr>(message, field).Get().size() > 0; } - return false; - case FieldDescriptor::CPPTYPE_BOOL: - return GetRaw<bool>(message, field) != false; - case FieldDescriptor::CPPTYPE_INT32: - return GetRaw<int32>(message, field) != 0; - case FieldDescriptor::CPPTYPE_INT64: - return GetRaw<int64>(message, field) != 0; - case FieldDescriptor::CPPTYPE_UINT32: - return GetRaw<uint32>(message, field) != 0; - case FieldDescriptor::CPPTYPE_UINT64: - return GetRaw<uint64>(message, field) != 0; - case FieldDescriptor::CPPTYPE_FLOAT: - return GetRaw<float>(message, field) != 0.0; - case FieldDescriptor::CPPTYPE_DOUBLE: - return GetRaw<double>(message, field) != 0.0; - case FieldDescriptor::CPPTYPE_ENUM: - return GetRaw<int>(message, field) != 0; - case FieldDescriptor::CPPTYPE_MESSAGE: - // handled above; avoid warning - GOOGLE_LOG(FATAL) << "Reached impossible case in HasBit()."; - break; - } + } + return false; + case FieldDescriptor::CPPTYPE_BOOL: + return GetRaw<bool>(message, field) != false; + case FieldDescriptor::CPPTYPE_INT32: + return GetRaw<int32>(message, field) != 0; + case FieldDescriptor::CPPTYPE_INT64: + return GetRaw<int64>(message, field) != 0; + case FieldDescriptor::CPPTYPE_UINT32: + return GetRaw<uint32>(message, field) != 0; + case FieldDescriptor::CPPTYPE_UINT64: + return GetRaw<uint64>(message, field) != 0; + case FieldDescriptor::CPPTYPE_FLOAT: + return GetRaw<float>(message, field) != 0.0; + case FieldDescriptor::CPPTYPE_DOUBLE: + return GetRaw<double>(message, field) != 0.0; + case FieldDescriptor::CPPTYPE_ENUM: + return GetRaw<int>(message, field) != 0; + case FieldDescriptor::CPPTYPE_MESSAGE: + // handled above; avoid warning + break; } + GOOGLE_LOG(FATAL) << "Reached impossible case in HasBit()."; + return false; } - return IsIndexInHasBitSet(GetHasBits(message), field->index()); } inline void GeneratedMessageReflection::SetBit( Message* message, const FieldDescriptor* field) const { - if (has_bits_offset_ == -1) { + if (!schema_.HasHasbits()) { return; } - const uint32 index = static_cast<uint32>(field->index()); + const uint32 index = schema_.HasBitIndex(field); MutableHasBits(message)[index / 32] |= (static_cast<uint32>(1) << (index % 32)); } inline void GeneratedMessageReflection::ClearBit( Message* message, const FieldDescriptor* field) const { - if (has_bits_offset_ == -1) { + if (!schema_.HasHasbits()) { return; } - const uint32 index = static_cast<uint32>(field->index()); + const uint32 index = schema_.HasBitIndex(field); MutableHasBits(message)[index / 32] &= ~(static_cast<uint32>(1) << (index % 32)); } inline void GeneratedMessageReflection::SwapBit( Message* message1, Message* message2, const FieldDescriptor* field) const { - if (has_bits_offset_ == -1) { + if (!schema_.HasHasbits()) { return; } bool temp_has_bit = HasBit(*message1, field); @@ -2135,7 +2105,7 @@ inline void GeneratedMessageReflection::ClearOneof( default: // TODO(kenton): Support other string reps. case FieldOptions::STRING: { const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); + &DefaultRaw<ArenaStringPtr>(field).Get(); MutableField<ArenaStringPtr>(message, field)-> Destroy(default_ptr, GetArena(message)); break; @@ -2247,7 +2217,7 @@ void* GeneratedMessageReflection::RepeatedFieldData( return MutableExtensionSet(message)->MutableRawRepeatedField( field->number(), field->type(), field->is_packed(), field); } else { - return reinterpret_cast<uint8*>(message) + offsets_[field->index()]; + return MutableRawNonOneof<char>(message, field); } } @@ -2259,42 +2229,165 @@ MapFieldBase* GeneratedMessageReflection::MapData( return MutableRaw<MapFieldBase>(message, field); } -GeneratedMessageReflection* -GeneratedMessageReflection::NewGeneratedMessageReflection( - 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, - 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); -} - -GeneratedMessageReflection* -GeneratedMessageReflection::NewGeneratedMessageReflection( - const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, - 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); +namespace { + +// Helper function to transform migration schema into reflection schema. +ReflectionSchema MigrationToReflectionSchema( + const DefaultInstanceData* default_instance_data, const uint32* offsets, + MigrationSchema migration_schema) { + ReflectionSchema result; + result.default_instance_ = default_instance_data->default_instance; + // First 5 offsets are offsets to the special fields. The following offsets + // are the proto fields. + result.offsets_ = offsets + migration_schema.offsets_index + 4; + result.has_bit_indices_ = offsets + migration_schema.has_bit_indices_index; + result.has_bits_offset_ = offsets[migration_schema.offsets_index + 0]; + result.metadata_offset_ = offsets[migration_schema.offsets_index + 1]; + result.extensions_offset_ = offsets[migration_schema.offsets_index + 2]; + result.default_oneof_instance_ = default_instance_data->default_oneof_instance; + result.oneof_case_offset_ = offsets[migration_schema.offsets_index + 3]; + result.object_size_ = migration_schema.object_size; + return result; +} + +ReflectionSchema MigrationToReflectionSchema( + const DefaultInstanceData* default_instance_data, const uint32* offsets, + ReflectionSchema schema) { + return schema; +} + +template<typename Schema> +class AssignDescriptorsHelper { + public: + AssignDescriptorsHelper(MessageFactory* factory, + Metadata* file_level_metadata, + const EnumDescriptor** file_level_enum_descriptors, + const Schema* schemas, + const DefaultInstanceData* default_instance_data, + const uint32* offsets) + : factory_(factory), + file_level_metadata_(file_level_metadata), + file_level_enum_descriptors_(file_level_enum_descriptors), + schemas_(schemas), + default_instance_data_(default_instance_data), + offsets_(offsets) {} + + void AssignMessageDescriptor(const Descriptor* descriptor) { + for (int i = 0; i < descriptor->nested_type_count(); i++) { + AssignMessageDescriptor(descriptor->nested_type(i)); + } + + file_level_metadata_->descriptor = descriptor; + + if (!descriptor->options().map_entry()) { + // Only set reflection for non map types. + file_level_metadata_->reflection = new GeneratedMessageReflection( + descriptor, MigrationToReflectionSchema(default_instance_data_++, + offsets_, *schemas_), + ::google::protobuf::DescriptorPool::generated_pool(), factory_); + for (int i = 0; i < descriptor->enum_type_count(); i++) { + AssignEnumDescriptor(descriptor->enum_type(i)); + } + schemas_++; + } + file_level_metadata_++; + } + + void AssignEnumDescriptor(const EnumDescriptor* descriptor) { + *file_level_enum_descriptors_ = descriptor; + file_level_enum_descriptors_++; + } + + private: + MessageFactory* factory_; + Metadata* file_level_metadata_; + const EnumDescriptor** file_level_enum_descriptors_; + const Schema* schemas_; + const DefaultInstanceData* default_instance_data_; + const uint32* offsets_; +}; + +} // namespace + +void AssignDescriptors( + const string& filename, const MigrationSchema* schemas, + const DefaultInstanceData* default_instance_data, const uint32* offsets, + MessageFactory* factory, + // update the following descriptor arrays. + Metadata* file_level_metadata, + const EnumDescriptor** file_level_enum_descriptors, + const ServiceDescriptor** file_level_service_descriptors) { + const ::google::protobuf::FileDescriptor* file = + ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(filename); + GOOGLE_CHECK(file != NULL); + + if (!factory) factory = MessageFactory::generated_factory(); + + AssignDescriptorsHelper<MigrationSchema> helper(factory, file_level_metadata, + file_level_enum_descriptors, schemas, + default_instance_data, offsets); + + for (int i = 0; i < file->message_type_count(); i++) { + helper.AssignMessageDescriptor(file->message_type(i)); + } + + for (int i = 0; i < file->enum_type_count(); i++) { + helper.AssignEnumDescriptor(file->enum_type(i)); + } + if (file->options().cc_generic_services()) { + for (int i = 0; i < file->service_count(); i++) { + file_level_service_descriptors[i] = file->service(i); + } + } +} + +void AssignDescriptors( + const string& filename, const ReflectionSchema* schemas, + MessageFactory* factory, + // update the following descriptor arrays. + Metadata* file_level_metadata, + const EnumDescriptor** file_level_enum_descriptors, + const ServiceDescriptor** file_level_service_descriptors) { + const ::google::protobuf::FileDescriptor* file = + ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(filename); + GOOGLE_CHECK(file != NULL); + + if (!factory) factory = MessageFactory::generated_factory(); + + AssignDescriptorsHelper<ReflectionSchema> helper(factory, file_level_metadata, + file_level_enum_descriptors, schemas, + NULL, NULL); + + for (int i = 0; i < file->message_type_count(); i++) { + helper.AssignMessageDescriptor(file->message_type(i)); + } + + for (int i = 0; i < file->enum_type_count(); i++) { + helper.AssignEnumDescriptor(file->enum_type(i)); + } + if (file->options().cc_generic_services()) { + for (int i = 0; i < file->service_count(); i++) { + file_level_service_descriptors[i] = file->service(i); + } + } +} + +void RegisterAllTypesInternal(const Metadata* file_level_metadata, int size) { + for (int i = 0; i < size; i++) { + const GeneratedMessageReflection* reflection = + static_cast<const GeneratedMessageReflection*>( + file_level_metadata[i].reflection); + if (reflection) { + // It's not a map type + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + file_level_metadata[i].descriptor, + reflection->schema_.default_instance_); + } + } +} + +void RegisterAllTypes(const Metadata* file_level_metadata, int size) { + RegisterAllTypesInternal(file_level_metadata, size); } } // namespace internal diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index 1413b110..ea97a7c8 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -45,6 +45,7 @@ // TODO(jasonh): Remove this once the compiler change to directly include this // is released to components. #include <google/protobuf/generated_enum_reflection.h> +#include <google/protobuf/generated_message_util.h> #include <google/protobuf/message.h> #include <google/protobuf/metadata.h> #include <google/protobuf/unknown_field_set.h> @@ -73,6 +74,157 @@ class GeneratedMessageReflection; // Defined in other files. class ExtensionSet; // extension_set.h +// This struct describes the internal layout of the message, hence this is +// used to act on the message reflectively. +// default_instance: The default instance of the message. This is only +// used to obtain pointers to default instances of embedded +// messages, which GetMessage() will return if the particular +// sub-message has not been initialized yet. (Thus, all +// embedded message fields *must* have non-NULL pointers +// in the default instance.) +// offsets: An array of ints giving the byte offsets. +// For each oneof field, the offset is relative to the +// default_oneof_instance. These can be computed at compile +// time using the +// PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET() macro. +// For each none oneof field, the offset is related to +// the start of the message object. These can be computed +// at compile time using the +// GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro. +// Besides offsets for all fields, this array also contains +// offsets for oneof unions. The offset of the i-th oneof +// union is offsets[descriptor->field_count() + i]. +// has_bit_indices: Mapping from field indexes to their index in the has +// bit array. +// has_bits_offset: Offset in the message of an array of uint32s of size +// descriptor->field_count()/32, rounded up. This is a +// bitfield where each bit indicates whether or not the +// corresponding field of the message has been initialized. +// The bit for field index i is obtained by the expression: +// has_bits[i / 32] & (1 << (i % 32)) +// unknown_fields_offset: Offset in the message of the UnknownFieldSet for +// the message. +// extensions_offset: Offset in the message of the ExtensionSet for the +// message, or -1 if the message type has no extension +// ranges. +// default_oneof_instance: The default instance of the oneofs. It is a +// struct holding the default value of all oneof fields +// for this message. It is only used to obtain pointers +// to default instances of oneof fields, which Get +// methods will return if the field is not set. +// oneof_case_offset: Offset in the message of an array of uint32s of +// size descriptor->oneof_decl_count(). Each uint32 +// indicates what field is set for each oneof. +// object_size: The size of a message object of this type, as measured +// by sizeof(). +// arena_offset: If a message doesn't have a unknown_field_set that stores +// the arena, it must have a direct pointer to the arena. +struct ReflectionSchema { + public: + // Size of a google::protobuf::Message object of this type. + uint32 GetObjectSize() const { return object_size_; } + + // Offset of a non-oneof field. Getting a field offset is slightly more + // efficient when we know statically that it is not a oneof field. + uint32 GetFieldOffsetNonOneof(const FieldDescriptor* field) const { + GOOGLE_DCHECK(!field->containing_oneof()); + return offsets_[field->index()]; + } + + // Offset of any field. + uint32 GetFieldOffset(const FieldDescriptor* field) const { + if (field->containing_oneof()) { + size_t offset = field->containing_type()->field_count() + + field->containing_oneof()->index(); + return offsets_[offset]; + } else { + return GetFieldOffsetNonOneof(field); + } + } + + uint32 GetOneofCaseOffset(const OneofDescriptor* oneof_descriptor) const { + return oneof_case_offset_ + (oneof_descriptor->index() * sizeof(uint32)); + } + + bool HasHasbits() const { return has_bits_offset_ != -1; } + + // Bit index within the bit array of hasbits. Bit order is low-to-high. + uint32 HasBitIndex(const FieldDescriptor* field) const { + GOOGLE_DCHECK(HasHasbits()); + return has_bit_indices_[field->index()]; + } + + // Byte offset of the hasbits array. + uint32 HasBitsOffset() const { + GOOGLE_DCHECK(HasHasbits()); + return has_bits_offset_; + } + + // The offset of the InternalMetadataWithArenaOffset member. + // For Lite this will actually be an InternalMetadataWithArenaOffsetLite. + // The schema doesn't contain enough information to distinguish between + // these two cases. + uint32 GetMetadataOffset() const { + return metadata_offset_; + } + + // Whether this message has an ExtensionSet. + bool HasExtensionSet() const { return extensions_offset_ != -1; } + + // The offset of the ExtensionSet in this message. + uint32 GetExtensionSetOffset() const { + GOOGLE_DCHECK(HasExtensionSet()); + return extensions_offset_; + } + + bool IsDefaultInstance(const Message& message) const { + return &message == default_instance_; + } + + // Returns a pointer to the default value for this field. The size and type + // of the underlying data depends on the field's type. + const void *GetFieldDefault(const FieldDescriptor* field) const { + return field->containing_oneof() + ? reinterpret_cast<const uint8*>(default_oneof_instance_) + + offsets_[field->index()] + : reinterpret_cast<const uint8*>(default_instance_) + + offsets_[field->index()]; + } + + // These members are intended to be private, but we cannot actually make them + // private because this prevents us from using aggregate initialization of + // them, ie. + // + // ReflectionSchema schema = {a, b, c, d, e, ...}; + // private: + const Message* default_instance_; + const uint32* offsets_; + const uint32* has_bit_indices_; + int has_bits_offset_; + int metadata_offset_; + int extensions_offset_; + const void* default_oneof_instance_; + int oneof_case_offset_; + int object_size_; +}; + +// Structs that the code generator emits directly to describe a message. +// These should never used directly except to build a ReflectionSchema +// object. +// +// EXPERIMENTAL: these are changing rapidly, and may completely disappear +// or merge with ReflectionSchema. +struct DefaultInstanceData { + const Message* default_instance; + const void* default_oneof_instance; +}; + +struct MigrationSchema { + int32 offsets_index; + int32 has_bit_indices_index; + int object_size; +}; + // THIS CLASS IS NOT INTENDED FOR DIRECT USE. It is intended for use // by generated code. This class is just a big hack that reduces code // size. @@ -97,109 +249,23 @@ class ExtensionSet; // extension_set.h // of whatever type the individual field would be. Strings and // Messages use RepeatedPtrFields while everything else uses // RepeatedFields. -class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { +class LIBPROTOBUF_EXPORT GeneratedMessageReflection PROTOBUF_FINAL : public Reflection { public: // Constructs a GeneratedMessageReflection. // Parameters: // descriptor: The descriptor for the message type being implemented. - // default_instance: The default instance of the message. This is only - // used to obtain pointers to default instances of embedded - // messages, which GetMessage() will return if the particular - // sub-message has not been initialized yet. (Thus, all - // embedded message fields *must* have non-NULL pointers - // in the default instance.) - // offsets: An array of ints giving the byte offsets, relative to - // the start of the message object, of each field. These can - // be computed at compile time using the - // GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro, defined - // below. - // has_bits_offset: Offset in the message of an array of uint32s of size - // descriptor->field_count()/32, rounded up. This is a - // bitfield where each bit indicates whether or not the - // corresponding field of the message has been initialized. - // The bit for field index i is obtained by the expression: - // has_bits[i / 32] & (1 << (i % 32)) - // unknown_fields_offset: Offset in the message of the UnknownFieldSet for - // the message. - // extensions_offset: Offset in the message of the ExtensionSet for the - // message, or -1 if the message type has no extension - // ranges. + // schema: The description of the internal guts of the message. // pool: DescriptorPool to search for extension definitions. Only // used by FindKnownExtensionByName() and // FindKnownExtensionByNumber(). // factory: MessageFactory to use to construct extension messages. - // object_size: The size of a message object of this type, as measured - // 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 ReflectionSchema& schema, const DescriptorPool* pool, - MessageFactory* factory, int object_size, - int arena_offset); + MessageFactory* factory); - // Similar with the construction above. Call this construction if the - // message has oneof definition. - // Parameters: - // offsets: An array of ints giving the byte offsets. - // For each oneof field, the offset is relative to the - // default_oneof_instance. These can be computed at compile - // time using the - // PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET() macro. - // For each none oneof field, the offset is related to - // the start of the message object. These can be computed - // at compile time using the - // GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro. - // Besides offsets for all fields, this array also contains - // offsets for oneof unions. The offset of the i-th oneof - // union is offsets[descriptor->field_count() + i]. - // default_oneof_instance: The default instance of the oneofs. It is a - // struct holding the default value of all oneof fields - // for this message. It is only used to obtain pointers - // to default instances of oneof fields, which Get - // methods will return if the field is not set. - // oneof_case_offset: Offset in the message of an array of uint32s of - // size descriptor->oneof_decl_count(). Each uint32 - // indicates what field is set for each oneof. - // 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 void* default_oneof_instance, - 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 - // pool and factory are the usual, namely, DescriptorPool::generated_pool() - // and MessageFactory::generated_factory(). - - static GeneratedMessageReflection* NewGeneratedMessageReflection( - 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, - int object_size, - int arena_offset, - int is_default_instance_offset = -1); - - static GeneratedMessageReflection* NewGeneratedMessageReflection( - const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, - int object_size, - int arena_offset, - int is_default_instance_offset = -1); - // implements Reflection ------------------------------------------- const UnknownFieldSet& GetUnknownFields(const Message& message) const; @@ -424,36 +490,42 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { private: friend class GeneratedMessage; - - // To parse directly into a proto2 generated class, the class GMR_Handlers - // needs access to member offsets and hasbits. friend class upb::google_opensource::GMR_Handlers; - const Descriptor* descriptor_; - const Message* default_instance_; - const void* default_oneof_instance_; - const int* offsets_; - - int has_bits_offset_; - int oneof_case_offset_; - int unknown_fields_offset_; - int extensions_offset_; - int arena_offset_; - int object_size_; + const Descriptor* const descriptor_; + const ReflectionSchema schema_; + const DescriptorPool* const descriptor_pool_; + MessageFactory* const message_factory_; - const DescriptorPool* descriptor_pool_; - MessageFactory* message_factory_; + // To parse directly into a proto2 generated class, the class GMR_Handlers + // needs access to member offsets and hasbits. + // upb still needs these. + // TODO(haberman) clean this up. + const Message* const default_instance_; + const void* const default_oneof_instance_; + const uint32* const offsets_; + const uint32* const has_bits_indices_; + const int has_bits_offset_; + const int oneof_case_offset_; + const int unknown_fields_offset_; + const int extensions_offset_; + const int arena_offset_; + const int object_size_; + + template <class T> + const T& GetRawNonOneof(const Message& message, + const FieldDescriptor* field) const; + template <class T> + T* MutableRawNonOneof(Message* message, const FieldDescriptor* field) const; template <typename Type> - inline const Type& GetRaw(const Message& message, + const Type& GetRaw(const Message& message, const FieldDescriptor* field) const; template <typename Type> inline Type* MutableRaw(Message* message, const FieldDescriptor* field) const; template <typename Type> inline const Type& DefaultRaw(const FieldDescriptor* field) const; - template <typename Type> - inline const Type& DefaultOneofRaw(const FieldDescriptor* field) const; inline const uint32* GetHasBits(const Message& message) const; inline uint32* MutableHasBits(Message* message) const; @@ -466,12 +538,12 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { inline const ExtensionSet& GetExtensionSet(const Message& message) const; inline ExtensionSet* MutableExtensionSet(Message* message) const; inline Arena* GetArena(Message* message) const; - inline const internal::InternalMetadataWithArena& - GetInternalMetadataWithArena(const Message& message) const; - inline internal::InternalMetadataWithArena* - MutableInternalMetadataWithArena(Message* message) const; - inline bool GetIsDefaultInstance(const Message& message) const; + inline const InternalMetadataWithArena& GetInternalMetadataWithArena( + const Message& message) const; + + inline InternalMetadataWithArena* + MutableInternalMetadataWithArena(Message* message) const; inline bool HasBit(const Message& message, const FieldDescriptor* field) const; @@ -559,6 +631,9 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { internal::MapFieldBase* MapData( Message* message, const FieldDescriptor* field) const; + friend inline // inline so nobody can call this function. + void + RegisterAllTypesInternal(const Metadata* file_level_metadata, int size); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratedMessageReflection); }; @@ -592,7 +667,7 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { #endif #define PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ONEOF, FIELD) \ - static_cast<int>( \ + static_cast< ::google::protobuf::uint32>( \ reinterpret_cast<const char*>(&(ONEOF->FIELD)) \ - reinterpret_cast<const char*>(ONEOF)) @@ -664,6 +739,25 @@ T* DynamicCastToGenerated(Message* from) { return const_cast<T*>(DynamicCastToGenerated<const T>(message_const)); } +LIBPROTOBUF_EXPORT void AssignDescriptors( + const string& filename, const MigrationSchema* schemas, + const DefaultInstanceData* default_instance_data, const uint32* offsets, + MessageFactory* factory, + // update the following descriptor arrays. + Metadata* file_level_metadata, + const EnumDescriptor** file_level_enum_descriptors, + const ServiceDescriptor** file_level_service_descriptors); + +LIBPROTOBUF_EXPORT void AssignDescriptors( + const string& filename, const ReflectionSchema* schemas, + MessageFactory* factory, + // update the following descriptor arrays. + Metadata* file_level_metadata, + const EnumDescriptor** file_level_enum_descriptors, + const ServiceDescriptor** file_level_service_descriptors); + +LIBPROTOBUF_EXPORT void RegisterAllTypes(const Metadata* file_level_metadata, int size); + } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/generated_message_reflection_unittest.cc b/src/google/protobuf/generated_message_reflection_unittest.cc index 6276b667..e2c6cdc0 100644 --- a/src/google/protobuf/generated_message_reflection_unittest.cc +++ b/src/google/protobuf/generated_message_reflection_unittest.cc @@ -222,7 +222,7 @@ TEST(GeneratedMessageReflectionTest, SwapFields) { message2.set_optional_string("hello"); message2.mutable_repeated_int64()->Add(30); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; const Descriptor* descriptor = message1.GetDescriptor(); fields.push_back(descriptor->FindFieldByName("optional_double")); fields.push_back(descriptor->FindFieldByName("repeated_int32")); @@ -255,7 +255,7 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsAll) { TestUtil::SetAllFields(&message2); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; const Reflection* reflection = message1.GetReflection(); reflection->ListFields(message2, &fields); reflection->SwapFields(&message1, &message2, fields); @@ -270,7 +270,7 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsAllExtension) { TestUtil::SetAllExtensions(&message1); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; const Reflection* reflection = message1.GetReflection(); reflection->ListFields(message1, &fields); reflection->SwapFields(&message1, &message2, fields); @@ -306,7 +306,7 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsOneof) { unittest::TestOneof2 message1, message2; TestUtil::SetOneof1(&message1); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; const Descriptor* descriptor = message1.GetDescriptor(); for (int i = 0; i < descriptor->field_count(); i++) { fields.push_back(descriptor->field(i)); @@ -608,7 +608,7 @@ TEST(GeneratedMessageReflectionTest, ListFieldsOneOf) { TestUtil::SetOneof1(&message); const Reflection* reflection = message.GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message, &fields); EXPECT_EQ(4, fields.size()); } diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index 73f55927..b4d2c9c1 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -51,9 +51,7 @@ double NaN() { ExplicitlyConstructed< ::std::string> fixed_address_empty_string; GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_); -void DeleteEmptyString() { - GetEmptyStringAlreadyInited().~string(); -} +void DeleteEmptyString() { fixed_address_empty_string.Shutdown(); } void InitEmptyString() { fixed_address_empty_string.DefaultConstruct(); @@ -73,10 +71,8 @@ int StringSpaceUsedExcludingSelf(const string& str) { -void MergeFromFail(const char* file, int line) { - GOOGLE_CHECK(false) << file << ":" << line; - // Open-source GOOGLE_CHECK(false) is not NORETURN. - exit(1); +void InitProtobufDefaults() { + GetEmptyString(); } } // namespace internal diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h index 8dc64c49..b1c49e37 100644 --- a/src/google/protobuf/generated_message_util.h +++ b/src/google/protobuf/generated_message_util.h @@ -45,6 +45,14 @@ #include <google/protobuf/stubs/once.h> #include <google/protobuf/has_bits.h> +#ifndef PROTOBUF_FINAL +#if __cplusplus >= 201103L +#define PROTOBUF_FINAL final +#else +#define PROTOBUF_FINAL +#endif +#endif // !PROTOBUF_FINAL + namespace google { namespace protobuf { @@ -91,7 +99,13 @@ class ExplicitlyConstructed { } } - const T& get() const { return reinterpret_cast<const T&>(union_); } +#if __cplusplus >= 201103L + constexpr +#endif + const T& + get() const { + return reinterpret_cast<const T&>(union_); + } T* get_mutable() { return reinterpret_cast<T*>(&union_); } private: @@ -140,9 +154,7 @@ template <class Type> bool AllAreInitialized(const Type& t) { return true; } -// 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; +LIBPROTOBUF_EXPORT void InitProtobufDefaults(); // 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 diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc index 08394ca7..93748ee3 100644 --- a/src/google/protobuf/io/coded_stream.cc +++ b/src/google/protobuf/io/coded_stream.cc @@ -47,7 +47,6 @@ #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 { @@ -550,9 +549,15 @@ bool CodedInputStream::ReadVarint64Slow(uint64* value) { uint32 b; do { - if (count == kMaxVarintBytes) return false; + if (count == kMaxVarintBytes) { + *value = 0; + return false; + } while (buffer_ == buffer_end_) { - if (!Refresh()) return false; + if (!Refresh()) { + *value = 0; + return false; + } } b = *buffer_; result |= static_cast<uint64>(b & 0x7F) << (7 * count); @@ -602,13 +607,13 @@ bool CodedInputStream::Refresh() { if (total_bytes_warning_threshold_ >= 0 && total_bytes_read_ >= total_bytes_warning_threshold_) { - GOOGLE_LOG(WARNING) << "Reading dangerously large protocol message. If the " - "message turns out to be larger than " - << total_bytes_limit_ << " bytes, parsing will be halted " - "for security reasons. To increase the limit (or to " - "disable these warnings), see " - "CodedInputStream::SetTotalBytesLimit() in " - "google/protobuf/io/coded_stream.h."; + GOOGLE_LOG(INFO) << "Reading dangerously large protocol message. If the " + "message turns out to be larger than " + << total_bytes_limit_ << " bytes, parsing will be halted " + "for security reasons. To increase the limit (or to " + "disable these warnings), see " + "CodedInputStream::SetTotalBytesLimit() in " + "google/protobuf/io/coded_stream.h."; // Don't warn again for this stream, and print total size at the end. total_bytes_warning_threshold_ = -2; @@ -789,104 +794,12 @@ void CodedOutputStream::WriteVarint32SlowPath(uint32 value) { WriteRaw(bytes, size); } -inline uint8* CodedOutputStream::WriteVarint64ToArrayInline( - uint64 value, uint8* target) { - // Splitting into 32-bit pieces gives better performance on 32-bit - // processors. - uint32 part0 = static_cast<uint32>(value ); - uint32 part1 = static_cast<uint32>(value >> 28); - uint32 part2 = static_cast<uint32>(value >> 56); - - int size; - - // Here we can't really optimize for small numbers, since the value is - // split into three parts. Cheking for numbers < 128, for instance, - // would require three comparisons, since you'd have to make sure part1 - // and part2 are zero. However, if the caller is using 64-bit integers, - // it is likely that they expect the numbers to often be very large, so - // we probably don't want to optimize for small numbers anyway. Thus, - // we end up with a hardcoded binary search tree... - if (part2 == 0) { - if (part1 == 0) { - if (part0 < (1 << 14)) { - if (part0 < (1 << 7)) { - size = 1; goto size1; - } else { - size = 2; goto size2; - } - } else { - if (part0 < (1 << 21)) { - size = 3; goto size3; - } else { - size = 4; goto size4; - } - } - } else { - if (part1 < (1 << 14)) { - if (part1 < (1 << 7)) { - size = 5; goto size5; - } else { - size = 6; goto size6; - } - } else { - if (part1 < (1 << 21)) { - size = 7; goto size7; - } else { - size = 8; goto size8; - } - } - } - } else { - if (part2 < (1 << 7)) { - size = 9; goto size9; - } else { - size = 10; goto size10; - } - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - - size10: target[9] = static_cast<uint8>((part2 >> 7) | 0x80); - size9 : target[8] = static_cast<uint8>((part2 ) | 0x80); - size8 : target[7] = static_cast<uint8>((part1 >> 21) | 0x80); - size7 : target[6] = static_cast<uint8>((part1 >> 14) | 0x80); - size6 : target[5] = static_cast<uint8>((part1 >> 7) | 0x80); - size5 : target[4] = static_cast<uint8>((part1 ) | 0x80); - size4 : target[3] = static_cast<uint8>((part0 >> 21) | 0x80); - size3 : target[2] = static_cast<uint8>((part0 >> 14) | 0x80); - size2 : target[1] = static_cast<uint8>((part0 >> 7) | 0x80); - size1 : target[0] = static_cast<uint8>((part0 ) | 0x80); - - target[size-1] &= 0x7F; - return target + size; -} - -void CodedOutputStream::WriteVarint64(uint64 value) { - if (buffer_size_ >= kMaxVarintBytes) { - // Fast path: We have enough bytes left in the buffer to guarantee that - // this write won't cross the end, so we can skip the checks. - uint8* target = buffer_; - - uint8* end = WriteVarint64ToArrayInline(value, target); - int size = end - target; - Advance(size); - } else { - // Slow path: This write might cross the end of the buffer, so we - // compose the bytes first then use WriteRaw(). - uint8 bytes[kMaxVarintBytes]; - int size = 0; - while (value > 0x7F) { - bytes[size++] = (static_cast<uint8>(value) & 0x7F) | 0x80; - value >>= 7; - } - bytes[size++] = static_cast<uint8>(value) & 0x7F; - WriteRaw(bytes, size); - } -} - -uint8* CodedOutputStream::WriteVarint64ToArray( - uint64 value, uint8* target) { - return WriteVarint64ToArrayInline(value, target); +void CodedOutputStream::WriteVarint64SlowPath(uint64 value) { + uint8 bytes[kMaxVarintBytes]; + uint8* target = &bytes[0]; + uint8* end = WriteVarint64ToArray(value, target); + int size = end - target; + WriteRaw(bytes, size); } bool CodedOutputStream::Refresh() { @@ -904,17 +817,22 @@ bool CodedOutputStream::Refresh() { } size_t CodedOutputStream::VarintSize32Fallback(uint32 value) { + // This computes floor(log2(value)) / 7 + 1 + // Use an explicit multiplication to implement the divide of + // a number in the 1..31 range. GOOGLE_DCHECK_NE(0, value); // This is enforced by our caller. - return 1 + Bits::Log2FloorNonZero(value) / 7; + uint32 log2value = Bits::Log2FloorNonZero(value); + return static_cast<size_t>((log2value * 9 + 73) / 64); } size_t CodedOutputStream::VarintSize64(uint64 value) { - if (value < (1 << 7)) { - return 1; - } - - return 1 + Bits::Log2FloorNonZero64(value) / 7; + // This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1 + // Use an explicit multiplication to implement the divide of + // a number in the 1..63 range. + // Explicit OR 0x1 to avoid calling clz(0), which is undefined. + uint32 log2value = Bits::Log2FloorNonZero64(value | 0x1); + return static_cast<size_t>((log2value * 9 + 73) / 64); } 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 1402cc17..d2a3e279 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -249,12 +249,16 @@ class LIBPROTOBUF_EXPORT CodedInputStream { bool ReadVarintSizeAsInt(int* value); // Read a tag. This calls ReadVarint32() and returns the result, or returns - // zero (which is not a valid tag) if ReadVarint32() fails. Also, it updates - // the last tag value, which can be checked with LastTagWas(). + // zero (which is not a valid tag) if ReadVarint32() fails. Also, ReadTag + // (but not ReadTagNoLastTag) updates the last tag value, which can be checked + // with LastTagWas(). + // // Always inline because this is only called in one place per parse loop // but it is called for every iteration of said loop, so it should be fast. // GCC doesn't want to inline this by default. GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTag(); + GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTagNoLastTag(); + // This usually a faster alternative to ReadTag() when cutoff is a manifest // constant. It does particularly well for cutoff >= 127. The first part @@ -266,6 +270,8 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // to avoid an extra "is tag == 0?" check here.) GOOGLE_ATTRIBUTE_ALWAYS_INLINE std::pair<uint32, bool> ReadTagWithCutoff( uint32 cutoff); + GOOGLE_ATTRIBUTE_ALWAYS_INLINE std::pair<uint32, bool> ReadTagWithCutoffNoLastTag( + uint32 cutoff); // Usually returns true if calling ReadVarint32() now would produce the given // value. Will always return false if ReadVarint32() would not return the @@ -293,8 +299,10 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // zero, and ConsumedEntireMessage() will return true. bool ExpectAtEnd(); - // If the last call to ReadTag() or ReadTagWithCutoff() returned the - // given value, returns true. Otherwise, returns false; + // If the last call to ReadTag() or ReadTagWithCutoff() returned the given + // value, returns true. Otherwise, returns false. + // ReadTagNoLastTag/ReadTagWithCutoffNoLastTag do not preserve the last + // returned value. // // This is needed because parsers for some types of embedded messages // (with field type TYPE_GROUP) don't actually know that they've reached the @@ -612,6 +620,13 @@ class LIBPROTOBUF_EXPORT CodedInputStream { int ReadVarintSizeAsIntSlow(); bool ReadLittleEndian32Fallback(uint32* value); bool ReadLittleEndian64Fallback(uint64* value); + + template<bool update_last_tag> + GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTagImplementation(); + template<bool update_last_tag> + GOOGLE_ATTRIBUTE_ALWAYS_INLINE + std::pair<uint32, bool> ReadTagWithCutoffImplementation(uint32 cutoff); + // Fallback/slow methods for reading tags. These do not update last_tag_, // but will set legitimate_message_end_ if we are at the end of the input // stream. @@ -622,7 +637,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // Return the size of the buffer. int BufferSize() const; - static const int kDefaultTotalBytesLimit = 64 << 20; // 64MB + static const int kDefaultTotalBytesLimit = INT_MAX; static const int kDefaultTotalBytesWarningThreshold = 32 << 20; // 32MB @@ -842,10 +857,10 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { serialization_deterministic_override_ = value; } // See above. Also, note that users of this CodedOutputStream may need to - // call IsSerializationDeterminstic() to serialize in the intended way. This + // call IsSerializationDeterministic() to serialize in the intended way. This // CodedOutputStream cannot enforce a desire for deterministic serialization // by itself. - bool IsSerializationDeterminstic() const { + bool IsSerializationDeterministic() const { return serialization_deterministic_is_overridden_ ? serialization_deterministic_override_ : default_serialization_deterministic_; @@ -879,16 +894,7 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { // If this write might cross the end of the buffer, we compose the bytes first // then use WriteRaw(). void WriteVarint32SlowPath(uint32 value); - - // Always-inlined versions of WriteVarint* functions so that code can be - // reused, while still controlling size. For instance, WriteVarint32ToArray() - // should not directly call this: since it is inlined itself, doing so - // would greatly increase the size of generated code. Instead, it should call - // WriteVarint32FallbackToArray. Meanwhile, WriteVarint32() is already - // out-of-line, so it should just invoke this directly to avoid any extra - // function call overhead. - GOOGLE_ATTRIBUTE_ALWAYS_INLINE static uint8* WriteVarint64ToArrayInline( - uint64 value, uint8* target); + void WriteVarint64SlowPath(uint64 value); static size_t VarintSize32Fallback(uint32 value); @@ -1007,21 +1013,47 @@ inline bool CodedInputStream::ReadLittleEndian64(uint64* value) { } inline uint32 CodedInputStream::ReadTag() { + return ReadTagImplementation<true>(); +} + +inline uint32 CodedInputStream::ReadTagNoLastTag() { + return ReadTagImplementation<false>(); +} + +template<bool update_last_tag> +inline uint32 CodedInputStream::ReadTagImplementation() { uint32 v = 0; if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) { v = *buffer_; if (v < 0x80) { - last_tag_ = v; + if (update_last_tag) { + last_tag_ = v; + } Advance(1); return v; } } - last_tag_ = ReadTagFallback(v); - return last_tag_; + v = ReadTagFallback(v); + if (update_last_tag) { + last_tag_ = v; + } + return v; } inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff( uint32 cutoff) { + return ReadTagWithCutoffImplementation<true>(cutoff); +} + +inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoffNoLastTag( + uint32 cutoff) { + return ReadTagWithCutoffImplementation<false>(cutoff); +} + +template<bool update_last_tag> +inline std::pair<uint32, bool> +CodedInputStream::ReadTagWithCutoffImplementation( + uint32 cutoff) { // In performance-sensitive code we can expect cutoff to be a compile-time // constant, and things like "cutoff >= kMax1ByteVarint" to be evaluated at // compile time. @@ -1033,7 +1065,10 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff( first_byte_or_zero = buffer_[0]; if (static_cast<int8>(buffer_[0]) > 0) { const uint32 kMax1ByteVarint = 0x7f; - uint32 tag = last_tag_ = buffer_[0]; + uint32 tag = buffer_[0]; + if (update_last_tag) { + last_tag_ = tag; + } Advance(1); return std::make_pair(tag, cutoff >= kMax1ByteVarint || tag <= cutoff); } @@ -1044,7 +1079,10 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff( GOOGLE_PREDICT_TRUE(buffer_ + 1 < buffer_end_) && GOOGLE_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) { const uint32 kMax2ByteVarint = (0x7f << 7) + 0x7f; - uint32 tag = last_tag_ = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80); + uint32 tag = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80); + if (update_last_tag) { + last_tag_ = tag; + } Advance(2); // It might make sense to test for tag == 0 now, but it is so rare that // that we don't bother. A varint-encoded 0 should be one byte unless @@ -1057,8 +1095,11 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff( } } // Slow path - last_tag_ = ReadTagFallback(first_byte_or_zero); - return std::make_pair(last_tag_, static_cast<uint32>(last_tag_ - 1) < cutoff); + const uint32 tag = ReadTagFallback(first_byte_or_zero); + if (update_last_tag) { + last_tag_ = tag; + } + return std::make_pair(tag, static_cast<uint32>(tag - 1) < cutoff); } inline bool CodedInputStream::LastTagWas(uint32 expected) { @@ -1153,21 +1194,24 @@ inline uint8* CodedOutputStream::WriteVarint32ToArray(uint32 value, return target + 1; } -inline void CodedOutputStream::WriteVarint32SignExtended(int32 value) { - if (value < 0) { - WriteVarint64(static_cast<uint64>(value)); - } else { - WriteVarint32(static_cast<uint32>(value)); +inline uint8* CodedOutputStream::WriteVarint64ToArray(uint64 value, + uint8* target) { + while (value >= 0x80) { + *target = static_cast<uint8>(value | 0x80); + value >>= 7; + ++target; } + *target = static_cast<uint8>(value); + return target + 1; +} + +inline void CodedOutputStream::WriteVarint32SignExtended(int32 value) { + WriteVarint64(static_cast<uint64>(value)); } inline uint8* CodedOutputStream::WriteVarint32SignExtendedToArray( int32 value, uint8* target) { - if (value < 0) { - return WriteVarint64ToArray(static_cast<uint64>(value), target); - } else { - return WriteVarint32ToArray(static_cast<uint32>(value), target); - } + return WriteVarint64ToArray(static_cast<uint64>(value), target); } inline uint8* CodedOutputStream::WriteLittleEndian32ToArray(uint32 value, @@ -1216,6 +1260,19 @@ inline void CodedOutputStream::WriteVarint32(uint32 value) { } } +inline void CodedOutputStream::WriteVarint64(uint64 value) { + if (buffer_size_ >= 10) { + // Fast path: We have enough bytes left in the buffer to guarantee that + // this write won't cross the end, so we can skip the checks. + uint8* target = buffer_; + uint8* end = WriteVarint64ToArray(value, target); + int size = static_cast<int>(end - target); + Advance(size); + } else { + WriteVarint64SlowPath(value); + } +} + inline void CodedOutputStream::WriteTag(uint32 value) { WriteVarint32(value); } diff --git a/src/google/protobuf/io/coded_stream_unittest.cc b/src/google/protobuf/io/coded_stream_unittest.cc index 9f1ebc3f..31574d5b 100644 --- a/src/google/protobuf/io/coded_stream_unittest.cc +++ b/src/google/protobuf/io/coded_stream_unittest.cc @@ -135,7 +135,7 @@ class CodedStreamTest : public testing::Test { // for further information. static void SetupTotalBytesLimitWarningTest( int total_bytes_limit, int warning_threshold, - vector<string>* out_errors, vector<string>* out_warnings); + std::vector<string>* out_errors, std::vector<string>* out_warnings); // Buffer used during most of the tests. This assumes tests run sequentially. static const int kBufferSize = 1024 * 64; @@ -245,7 +245,7 @@ TEST_F(CodedStreamTest, EmptyInputBeforeEos) { int count_; } in; CodedInputStream input(&in); - input.ReadTag(); + input.ReadTagNoLastTag(); EXPECT_TRUE(input.ConsumedEntireMessage()); } @@ -446,6 +446,21 @@ TEST_2D(CodedStreamTest, ReadVarint32Error, kVarintErrorCases, kBlockSizes) { EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint32(&value)); } +TEST_2D(CodedStreamTest, ReadVarint32Error_LeavesValueInInitializedState, + kVarintErrorCases, kBlockSizes) { + memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size); + ArrayInputStream input(buffer_, kVarintErrorCases_case.size, + kBlockSizes_case); + CodedInputStream coded_input(&input); + + uint32 value = 0; + EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint32(&value)); + // While the specific value following a failure is not critical, we do want to + // ensure that it doesn't get set to an uninitialized value. (This check fails + // in MSAN mode if value has been set to an uninitialized value.) + EXPECT_EQ(value, value); +} + TEST_2D(CodedStreamTest, ReadVarint64Error, kVarintErrorCases, kBlockSizes) { memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size); ArrayInputStream input(buffer_, kVarintErrorCases_case.size, @@ -456,6 +471,21 @@ TEST_2D(CodedStreamTest, ReadVarint64Error, kVarintErrorCases, kBlockSizes) { EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint64(&value)); } +TEST_2D(CodedStreamTest, ReadVarint64Error_LeavesValueInInitializedState, + kVarintErrorCases, kBlockSizes) { + memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size); + ArrayInputStream input(buffer_, kVarintErrorCases_case.size, + kBlockSizes_case); + CodedInputStream coded_input(&input); + + uint64 value = 0; + EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint64(&value)); + // While the specific value following a failure is not critical, we do want to + // ensure that it doesn't get set to an uninitialized value. (This check fails + // in MSAN mode if value has been set to an uninitialized value.) + EXPECT_EQ(value, value); +} + // ------------------------------------------------------------------- // VarintSize @@ -495,6 +525,28 @@ TEST_1D(CodedStreamTest, VarintSize64, kVarintSizeCases) { CodedOutputStream::VarintSize64(kVarintSizeCases_case.value)); } +TEST_F(CodedStreamTest, VarintSize32PowersOfTwo) { + int expected = 1; + for (int i = 1; i < 32; i++) { + if (i % 7 == 0) { + expected += 1; + } + EXPECT_EQ(expected, + CodedOutputStream::VarintSize32(static_cast<uint32>(0x1u << i))); + } +} + +TEST_F(CodedStreamTest, VarintSize64PowersOfTwo) { + int expected = 1; + for (int i = 1; i < 64; i++) { + if (i % 7 == 0) { + expected += 1; + } + EXPECT_EQ(expected, CodedOutputStream::VarintSize64( + static_cast<uint64>(0x1ull << i))); + } +} + // ------------------------------------------------------------------- // Fixed-size int tests @@ -1177,7 +1229,7 @@ TEST_F(CodedStreamTest, TotalBytesLimit) { EXPECT_TRUE(coded_input.ReadString(&str, 16)); EXPECT_EQ(0, coded_input.BytesUntilTotalBytesLimit()); - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog error_log; @@ -1211,7 +1263,7 @@ TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) { // Read a tag. Should fail, but report being a valid endpoint since it's // a regular limit. - EXPECT_EQ(0, coded_input.ReadTag()); + EXPECT_EQ(0, coded_input.ReadTagNoLastTag()); EXPECT_TRUE(coded_input.ConsumedEntireMessage()); // Pop the limit. @@ -1219,7 +1271,7 @@ TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) { // Read a tag. Should fail, and report *not* being a valid endpoint, since // this time we're hitting the total bytes limit. - EXPECT_EQ(0, coded_input.ReadTag()); + EXPECT_EQ(0, coded_input.ReadTagNoLastTag()); EXPECT_FALSE(coded_input.ConsumedEntireMessage()); } @@ -1229,7 +1281,7 @@ TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) { // vectors. void CodedStreamTest::SetupTotalBytesLimitWarningTest( int total_bytes_limit, int warning_threshold, - vector<string>* out_errors, vector<string>* out_warnings) { + std::vector<string>* out_errors, std::vector<string>* out_warnings) { ArrayInputStream raw_input(buffer_, sizeof(buffer_), 128); ScopedMemoryLog scoped_log; @@ -1245,25 +1297,21 @@ void CodedStreamTest::SetupTotalBytesLimitWarningTest( } TEST_F(CodedStreamTest, TotalBytesLimitWarning) { - vector<string> errors; - vector<string> warnings; + std::vector<string> errors; + std::vector<string> warnings; SetupTotalBytesLimitWarningTest(10240, 1024, &errors, &warnings); EXPECT_EQ(0, errors.size()); - ASSERT_EQ(2, warnings.size()); - EXPECT_PRED_FORMAT2(testing::IsSubstring, - "Reading dangerously large protocol message. If the message turns out to " - "be larger than 10240 bytes, parsing will be halted for security reasons.", - warnings[0]); + EXPECT_EQ(1, warnings.size()); EXPECT_PRED_FORMAT2(testing::IsSubstring, "The total number of bytes read was 2048", - warnings[1]); + warnings[0]); } TEST_F(CodedStreamTest, TotalBytesLimitWarningDisabled) { - vector<string> errors; - vector<string> warnings; + std::vector<string> errors; + std::vector<string> warnings; // Test with -1 SetupTotalBytesLimitWarningTest(10240, -1, &errors, &warnings); @@ -1362,7 +1410,7 @@ TEST_F(CodedStreamTest, InputOver2G) { // input.BackUp() with the correct number of bytes on destruction. ReallyBigInputStream input; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog error_log; diff --git a/src/google/protobuf/io/gzip_stream.cc b/src/google/protobuf/io/gzip_stream.cc index 9c621b6a..a569eff0 100644 --- a/src/google/protobuf/io/gzip_stream.cc +++ b/src/google/protobuf/io/gzip_stream.cc @@ -168,7 +168,7 @@ void GzipInputStream::BackUp(int count) { } bool GzipInputStream::Skip(int count) { const void* data; - int size; + int size = 0; bool ok = Next(&data, &size); while (ok && (size < count)) { count -= size; diff --git a/src/google/protobuf/io/printer.cc b/src/google/protobuf/io/printer.cc index 7532b098..99e895f5 100644 --- a/src/google/protobuf/io/printer.cc +++ b/src/google/protobuf/io/printer.cc @@ -70,8 +70,8 @@ Printer::~Printer() { } bool Printer::GetSubstitutionRange(const char* varname, - pair<size_t, size_t>* range) { - map<string, pair<size_t, size_t> >::const_iterator iter = + std::pair<size_t, size_t>* range) { + std::map<string, std::pair<size_t, size_t> >::const_iterator iter = substitutions_.find(varname); if (iter == substitutions_.end()) { GOOGLE_LOG(DFATAL) << " Undefined variable in annotation: " << varname; @@ -87,12 +87,12 @@ bool Printer::GetSubstitutionRange(const char* varname, } void Printer::Annotate(const char* begin_varname, const char* end_varname, - const string& file_path, const vector<int>& path) { + const string& file_path, const std::vector<int>& path) { if (annotation_collector_ == NULL) { // Can't generate signatures with this Printer. return; } - pair<size_t, size_t> begin, end; + std::pair<size_t, size_t> begin, end; if (!GetSubstitutionRange(begin_varname, &begin) || !GetSubstitutionRange(end_varname, &end)) { return; @@ -106,7 +106,8 @@ void Printer::Annotate(const char* begin_varname, const char* end_varname, } } -void Printer::Print(const map<string, string>& variables, const char* text) { +void Printer::Print(const std::map<string, string>& variables, + const char* text) { int size = strlen(text); int pos = 0; // The number of bytes we've written so far. substitutions_.clear(); @@ -143,14 +144,15 @@ void Printer::Print(const map<string, string>& variables, const char* text) { WriteRaw(&variable_delimiter_, 1); } else { // Replace with the variable's value. - map<string, string>::const_iterator iter = variables.find(varname); + std::map<string, string>::const_iterator iter = variables.find(varname); if (iter == variables.end()) { GOOGLE_LOG(DFATAL) << " Undefined variable: " << varname; } else { size_t begin = offset_; WriteRaw(iter->second.data(), iter->second.size()); - pair<map<string, pair<size_t, size_t> >::iterator, bool> inserted = - substitutions_.insert( + std::pair<std::map<string, std::pair<size_t, size_t> >::iterator, + bool> + inserted = substitutions_.insert( std::make_pair(varname, std::make_pair(begin, offset_))); if (!inserted.second) { // This variable was used multiple times. Make its span have @@ -172,13 +174,13 @@ void Printer::Print(const map<string, string>& variables, const char* text) { } void Printer::Print(const char* text) { - static map<string, string> empty; + static std::map<string, string> empty; Print(empty, text); } void Printer::Print(const char* text, const char* variable, const string& value) { - map<string, string> vars; + std::map<string, string> vars; vars[variable] = value; Print(vars, text); } @@ -186,7 +188,7 @@ void Printer::Print(const char* text, void Printer::Print(const char* text, const char* variable1, const string& value1, const char* variable2, const string& value2) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; Print(vars, text); @@ -196,7 +198,7 @@ void Printer::Print(const char* text, const char* variable1, const string& value1, const char* variable2, const string& value2, const char* variable3, const string& value3) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; vars[variable3] = value3; @@ -208,7 +210,7 @@ void Printer::Print(const char* text, const char* variable2, const string& value2, const char* variable3, const string& value3, const char* variable4, const string& value4) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; vars[variable3] = value3; @@ -222,7 +224,7 @@ void Printer::Print(const char* text, const char* variable3, const string& value3, const char* variable4, const string& value4, const char* variable5, const string& value5) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; vars[variable3] = value3; @@ -238,7 +240,7 @@ void Printer::Print(const char* text, const char* variable4, const string& value4, const char* variable5, const string& value5, const char* variable6, const string& value6) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; vars[variable3] = value3; @@ -256,7 +258,7 @@ void Printer::Print(const char* text, const char* variable5, const string& value5, const char* variable6, const string& value6, const char* variable7, const string& value7) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; vars[variable3] = value3; @@ -276,7 +278,7 @@ void Printer::Print(const char* text, const char* variable6, const string& value6, const char* variable7, const string& value7, const char* variable8, const string& value8) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; vars[variable3] = value3; diff --git a/src/google/protobuf/io/printer.h b/src/google/protobuf/io/printer.h index e78e2efd..e666445b 100644 --- a/src/google/protobuf/io/printer.h +++ b/src/google/protobuf/io/printer.h @@ -55,7 +55,7 @@ class LIBPROTOBUF_EXPORT AnnotationCollector { // before end_offset are associated with the SourceCodeInfo-style path. virtual void AddAnnotation(size_t begin_offset, size_t end_offset, const string& file_path, - const vector<int>& path) = 0; + const std::vector<int>& path) = 0; virtual ~AnnotationCollector() {} }; @@ -73,7 +73,8 @@ class AnnotationProtoCollector : public AnnotationCollector { // Override for AnnotationCollector::AddAnnotation. virtual void AddAnnotation(size_t begin_offset, size_t end_offset, - const string& file_path, const vector<int>& path) { + const string& file_path, + const std::vector<int>& path) { typename AnnotationProto::Annotation* annotation = annotation_proto_->add_annotation(); for (int i = 0; i < path.size(); ++i) { @@ -195,7 +196,7 @@ class LIBPROTOBUF_EXPORT Printer { // of building the location path. return; } - vector<int> path; + std::vector<int> path; descriptor->GetLocationPath(&path); Annotate(begin_varname, end_varname, descriptor->file()->name(), path); } @@ -216,7 +217,7 @@ class LIBPROTOBUF_EXPORT Printer { // Annotations aren't turned on for this Printer. return; } - vector<int> empty_path; + std::vector<int> empty_path; Annotate(begin_varname, end_varname, file_name, empty_path); } @@ -225,7 +226,7 @@ class LIBPROTOBUF_EXPORT Printer { // substituted are identified by their names surrounded by delimiter // characters (as given to the constructor). The variable bindings are // defined by the given map. - void Print(const map<string, string>& variables, const char* text); + void Print(const std::map<string, string>& variables, const char* text); // Like the first Print(), except the substitutions are given as parameters. void Print(const char* text); @@ -308,7 +309,7 @@ class LIBPROTOBUF_EXPORT Printer { // substituted for end_varname. Note that begin_varname and end_varname // may refer to the same variable. void Annotate(const char* begin_varname, const char* end_varname, - const string& file_path, const vector<int>& path); + const string& file_path, const std::vector<int>& path); const char variable_delimiter_; @@ -331,13 +332,14 @@ class LIBPROTOBUF_EXPORT Printer { // start offset is the beginning of the substitution; the end offset is the // last byte of the substitution plus one (such that (end - start) is the // length of the substituted string). - map<string, pair<size_t, size_t> > substitutions_; + std::map<string, std::pair<size_t, size_t> > substitutions_; // Returns true and sets range to the substitution range in the output for // varname if varname was used once in the last call to Print. If varname // was not used, or if it was used multiple times, returns false (and // fails a debug assertion). - bool GetSubstitutionRange(const char* varname, pair<size_t, size_t>* range); + bool GetSubstitutionRange(const char* varname, + std::pair<size_t, size_t>* range); // If non-null, annotation_collector_ is used to store annotations about // generated code. diff --git a/src/google/protobuf/io/printer_unittest.cc b/src/google/protobuf/io/printer_unittest.cc index 95f3afa2..0435228a 100644 --- a/src/google/protobuf/io/printer_unittest.cc +++ b/src/google/protobuf/io/printer_unittest.cc @@ -121,7 +121,7 @@ TEST(Printer, VariableSubstitution) { { Printer printer(&output, '$'); - map<string, string> vars; + std::map<string, string> vars; vars["foo"] = "World"; vars["bar"] = "$foo$"; @@ -187,7 +187,7 @@ class MockDescriptorFile { // annotations. class MockDescriptor { public: - MockDescriptor(const string& file, const vector<int>& path) + MockDescriptor(const string& file, const std::vector<int>& path) : file_(file), path_(path) {} // The mock file in which this descriptor was defined. @@ -201,7 +201,7 @@ class MockDescriptor { void GetLocationPath(std::vector<int>* output) const { *output = path_; } MockDescriptorFile file_; - vector<int> path_; + std::vector<int> path_; }; TEST(Printer, AnnotateMap) { @@ -211,13 +211,13 @@ TEST(Printer, AnnotateMap) { AnnotationProtoCollector<GeneratedCodeInfo> info_collector(&info); { Printer printer(&output, '$', &info_collector); - map<string, string> vars; + std::map<string, string> vars; vars["foo"] = "3"; vars["bar"] = "5"; printer.Print(vars, "012$foo$4$bar$\n"); - vector<int> path_1; + std::vector<int> path_1; path_1.push_back(33); - vector<int> path_2; + std::vector<int> path_2; path_2.push_back(11); path_2.push_back(22); MockDescriptor descriptor_1("path_1", path_1); @@ -255,9 +255,9 @@ TEST(Printer, AnnotateInline) { { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$bar$\n", "foo", "3", "bar", "5"); - vector<int> path_1; + std::vector<int> path_1; path_1.push_back(33); - vector<int> path_2; + std::vector<int> path_2; path_2.push_back(11); path_2.push_back(22); MockDescriptor descriptor_1("path_1", path_1); @@ -295,7 +295,7 @@ TEST(Printer, AnnotateRange) { { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$bar$\n", "foo", "3", "bar", "5"); - vector<int> path; + std::vector<int> path; path.push_back(33); MockDescriptor descriptor("path", path); printer.Annotate("foo", "bar", &descriptor); @@ -320,7 +320,7 @@ TEST(Printer, AnnotateEmptyRange) { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$baz$$bam$$bar$\n", "foo", "3", "bar", "5", "baz", "", "bam", ""); - vector<int> path; + std::vector<int> path; path.push_back(33); MockDescriptor descriptor("path", path); printer.Annotate("baz", "bam", &descriptor); @@ -344,7 +344,7 @@ TEST(Printer, AnnotateDespiteUnrelatedMultipleUses) { { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$foo$$bar$\n", "foo", "3", "bar", "5"); - vector<int> path; + std::vector<int> path; path.push_back(33); MockDescriptor descriptor("path", path); printer.Annotate("bar", "bar", &descriptor); @@ -368,7 +368,7 @@ TEST(Printer, Indenting) { { Printer printer(&output, '$'); - map<string, string> vars; + std::map<string, string> vars; vars["newline"] = "\n"; @@ -432,7 +432,7 @@ TEST(Printer, AnnotateMultipleUsesDeath) { { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$foo$\n", "foo", "3"); - vector<int> path; + std::vector<int> path; path.push_back(33); MockDescriptor descriptor("path", path); EXPECT_DEBUG_DEATH(printer.Annotate("foo", "foo", &descriptor), "multiple"); @@ -447,7 +447,7 @@ TEST(Printer, AnnotateNegativeLengthDeath) { { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$bar$\n", "foo", "3", "bar", "5"); - vector<int> path; + std::vector<int> path; path.push_back(33); MockDescriptor descriptor("path", path); EXPECT_DEBUG_DEATH(printer.Annotate("bar", "foo", &descriptor), "negative"); @@ -462,7 +462,7 @@ TEST(Printer, AnnotateUndefinedDeath) { { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$foo$\n", "foo", "3"); - vector<int> path; + std::vector<int> path; path.push_back(33); MockDescriptor descriptor("path", path); EXPECT_DEBUG_DEATH(printer.Annotate("bar", "bar", &descriptor), diff --git a/src/google/protobuf/io/tokenizer.cc b/src/google/protobuf/io/tokenizer.cc index b3550dfb..916d1606 100644 --- a/src/google/protobuf/io/tokenizer.cc +++ b/src/google/protobuf/io/tokenizer.cc @@ -665,7 +665,7 @@ namespace { class CommentCollector { public: CommentCollector(string* prev_trailing_comments, - vector<string>* detached_comments, + std::vector<string>* detached_comments, string* next_leading_comments) : prev_trailing_comments_(prev_trailing_comments), detached_comments_(detached_comments), @@ -737,7 +737,7 @@ class CommentCollector { private: string* prev_trailing_comments_; - vector<string>* detached_comments_; + std::vector<string>* detached_comments_; string* next_leading_comments_; string comment_buffer_; @@ -757,7 +757,7 @@ class CommentCollector { } // namespace bool Tokenizer::NextWithComments(string* prev_trailing_comments, - vector<string>* detached_comments, + std::vector<string>* detached_comments, string* next_leading_comments) { CommentCollector collector(prev_trailing_comments, detached_comments, next_leading_comments); diff --git a/src/google/protobuf/io/tokenizer.h b/src/google/protobuf/io/tokenizer.h index 77a873bc..e80d564c 100644 --- a/src/google/protobuf/io/tokenizer.h +++ b/src/google/protobuf/io/tokenizer.h @@ -191,7 +191,7 @@ class LIBPROTOBUF_EXPORT Tokenizer { // * grault. */ // optional int32 grault = 6; bool NextWithComments(string* prev_trailing_comments, - vector<string>* detached_comments, + std::vector<string>* detached_comments, string* next_leading_comments); // Parse helpers --------------------------------------------------- diff --git a/src/google/protobuf/io/tokenizer_unittest.cc b/src/google/protobuf/io/tokenizer_unittest.cc index ae0811f8..a2c19522 100644 --- a/src/google/protobuf/io/tokenizer_unittest.cc +++ b/src/google/protobuf/io/tokenizer_unittest.cc @@ -693,7 +693,7 @@ TEST_2D(TokenizerTest, DocComments, kDocCommentCases, kBlockSizes) { EXPECT_EQ("prev", tokenizer2.current().text); string prev_trailing_comments; - vector<string> detached_comments; + std::vector<string> detached_comments; string next_leading_comments; tokenizer.NextWithComments(&prev_trailing_comments, &detached_comments, &next_leading_comments); diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 2d295510..efd421e6 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -523,13 +523,13 @@ class Map { typedef size_t size_type; typedef hash<Key> hasher; - explicit Map(bool old_style = true) + explicit Map(bool old_style = false) : arena_(NULL), default_enum_value_(0), old_style_(old_style) { Init(); } - explicit Map(Arena* arena, bool old_style = true) + explicit Map(Arena* arena, bool old_style = false) : arena_(arena), default_enum_value_(0), old_style_(old_style) { @@ -543,7 +543,7 @@ class Map { insert(other.begin(), other.end()); } template <class InputIt> - Map(const InputIt& first, const InputIt& last, bool old_style = true) + Map(const InputIt& first, const InputIt& last, bool old_style = false) : arena_(NULL), default_enum_value_(0), old_style_(old_style) { @@ -654,7 +654,8 @@ class Map { // To support Visual Studio 2008 size_type max_size() const { - return std::numeric_limits<size_type>::max(); + // parentheses around (std::...:max) prevents macro warning of max() + return (std::numeric_limits<size_type>::max)(); } // To support gcc-4.4, which does not properly @@ -1084,8 +1085,9 @@ class Map { // index_of_first_non_null_, so we skip the code to update it. return InsertUniqueInTree(b, node); } + // parentheses around (std::min) prevents macro expansion of min(...) index_of_first_non_null_ = - std::min(index_of_first_non_null_, result.bucket_index_); + (std::min)(index_of_first_non_null_, result.bucket_index_); return result; } diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h index abcd4529..07c24c02 100644 --- a/src/google/protobuf/map_entry.h +++ b/src/google/protobuf/map_entry.h @@ -244,14 +244,19 @@ class MapEntry : public MapEntryBase { // to distinguish instances of the same MapEntry class. static MapEntry* CreateDefaultInstance(const Descriptor* descriptor) { MapEntry* entry = new MapEntry; - const Reflection* reflection = new GeneratedMessageReflection( - descriptor, entry, offsets_, + ReflectionSchema schema = { + entry, + offsets_, + has_bits_, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_._has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _unknown_fields_), -1, - DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(MapEntry), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _internal_metadata_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _internal_metadata_), + -1, + NULL, + -1, + sizeof(MapEntry)}; + const Reflection* reflection = new GeneratedMessageReflection( + descriptor, schema, DescriptorPool::generated_pool(), + MessageFactory::generated_factory()); entry->descriptor_ = descriptor; entry->reflection_ = reflection; entry->set_default_instance(entry); @@ -278,8 +283,8 @@ class MapEntry : public MapEntryBase { entry_lite_.set_default_instance(&default_instance->entry_lite_); } - static int offsets_[2]; - UnknownFieldSet _unknown_fields_; + static uint32 offsets_[2]; + static uint32 has_bits_[2]; InternalMetadataWithArena _internal_metadata_; MapEntry* default_instance_; EntryLiteType entry_lite_; @@ -297,12 +302,17 @@ class MapEntry : public MapEntryBase { template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, WireFormatLite::FieldType kValueFieldType, int default_enum_value> -int MapEntry<Key, Value, kKeyFieldType, kValueFieldType, +uint32 MapEntry<Key, Value, kKeyFieldType, kValueFieldType, default_enum_value>::offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_.key_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_.value_), }; +template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, + WireFormatLite::FieldType kValueFieldType, int default_enum_value> +uint32 MapEntry<Key, Value, kKeyFieldType, kValueFieldType, + default_enum_value>::has_bits_[2] = {0, 1}; + } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h index 3fb58220..bb1d7e06 100644 --- a/src/google/protobuf/map_entry_lite.h +++ b/src/google/protobuf/map_entry_lite.h @@ -171,7 +171,7 @@ class MapEntryLite : public MessageLite { // need to care whether the value is unknown enum; // 4) missing key/value: missed key/value will have default value. caller // should take this entry as if key/value is set to default value. - tag = input->ReadTag(); + tag = input->ReadTagNoLastTag(); switch (tag) { case kKeyTag: if (!KeyTypeHandler::Read(input, mutable_key())) { @@ -333,7 +333,7 @@ class MapEntryLite : public MessageLite { int size; input->GetDirectBufferPointerInline(&data, &size); // We could use memcmp here, but we don't bother. The tag is one byte. - assert(kTagSize == 1); + GOOGLE_COMPILE_ASSERT(kTagSize == 1, tag_size_error); if (size > 0 && *reinterpret_cast<const char*>(data) == kValueTag) { typename Map::size_type size = map_->size(); value_ptr_ = &(*map_)[key_]; @@ -357,15 +357,17 @@ class MapEntryLite : public MessageLite { entry_.reset(mf_->NewEntry()); *entry_->mutable_key() = key_; - if (!entry_->MergePartialFromCodedStream(input)) return false; - return UseKeyAndValueFromEntry(); + const bool result = entry_->MergePartialFromCodedStream(input); + if (result) UseKeyAndValueFromEntry(); + if (entry_->GetArena() != NULL) entry_.release(); + return result; } const Key& key() const { return key_; } const Value& value() const { return *value_ptr_; } private: - bool UseKeyAndValueFromEntry() GOOGLE_ATTRIBUTE_COLD { + void UseKeyAndValueFromEntry() GOOGLE_ATTRIBUTE_COLD { // Update key_ in case we need it later (because key() is called). // This is potentially inefficient, especially if the key is // expensive to copy (e.g., a long string), but this is a cold @@ -377,8 +379,6 @@ class MapEntryLite : public MessageLite { ValueTypeHandler::kWireType == WireFormatLite::WIRETYPE_LENGTH_DELIMITED, Value>::Move(entry_->mutable_value(), value_ptr_); - if (entry_->GetArena() != NULL) entry_.release(); - return true; } // After reading a key and value successfully, and inserting that data @@ -400,15 +400,18 @@ class MapEntryLite : public MessageLite { ValueMover::Move(value_ptr_, entry_->mutable_value()); map_->erase(key_); KeyMover::Move(&key_, entry_->mutable_key()); - if (!entry_->MergePartialFromCodedStream(input)) return false; - return UseKeyAndValueFromEntry(); + const bool result = entry_->MergePartialFromCodedStream(input); + if (result) UseKeyAndValueFromEntry(); + if (entry_->GetArena() != NULL) entry_.release(); + return result; } MapField* const mf_; Map* const map_; Key key_; Value* value_ptr_; - // On the fast path entry_ is not used. + // On the fast path entry_ is not used. And, when entry_ is used, it's set + // to mf_->NewEntry(), so in the arena case we must call entry_.release. google::protobuf::scoped_ptr<MapEntryLite> entry_; }; diff --git a/src/google/protobuf/map_field_lite.h b/src/google/protobuf/map_field_lite.h index a9f30f59..cb0a4a45 100644 --- a/src/google/protobuf/map_field_lite.h +++ b/src/google/protobuf/map_field_lite.h @@ -68,13 +68,14 @@ class MapFieldLite { // Set default enum value only for proto2 map field whose value is enum type. void SetDefaultEnumValue(); - // Used in the implementation of parsing. Caller should take the ownership. + // Used in the implementation of parsing. Caller should take the ownership iff + // arena_ is NULL. EntryType* NewEntry() const; // Used in the implementation of serializing enum value type. Caller should - // take the ownership. + // take the ownership iff arena_ is NULL. EntryType* NewEnumEntryWrapper(const Key& key, const T t) const; // Used in the implementation of serializing other value types. Caller should - // take the ownership. + // take the ownership iff arena_ is NULL. EntryType* NewEntryWrapper(const Key& key, const T& t) const; protected: diff --git a/src/google/protobuf/map_proto2_unittest.proto b/src/google/protobuf/map_proto2_unittest.proto index ddc2a582..e9360a5a 100644 --- a/src/google/protobuf/map_proto2_unittest.proto +++ b/src/google/protobuf/map_proto2_unittest.proto @@ -29,7 +29,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. syntax = "proto2"; - +option cc_enable_arenas = true; import "google/protobuf/unittest_import.proto"; diff --git a/src/google/protobuf/map_test.cc b/src/google/protobuf/map_test.cc index 03954e75..d0a34d01 100644 --- a/src/google/protobuf/map_test.cc +++ b/src/google/protobuf/map_test.cc @@ -298,7 +298,7 @@ TEST_P(MapImplTest, IteratorBasic) { template <typename Iterator> static int64 median(Iterator i0, Iterator i1) { - vector<int64> v(i0, i1); + std::vector<int64> v(i0, i1); std::nth_element(v.begin(), v.begin() + v.size() / 2, v.end()); return v[v.size() / 2]; } @@ -334,7 +334,7 @@ TEST_P(MapImplTest, BeginIsFast) { GOOGLE_DCHECK_GE(last_key, 0); map[last_key] = last_key ^ 1; } - vector<int64> times; + std::vector<int64> times; // We're going to do map.erase(map.begin()) over and over again. But, // just in case one iteration is fast compared to the granularity of // our time keeping, we measure kChunkSize iterations per outer-loop iter. @@ -379,7 +379,7 @@ TEST_P(MapImplTest, HashFlood) { // 1024 (or 512 or 2048 or ...) entries. This assumes that map_ uses powers // of 2 for table sizes, and that it's sufficient to "flood" with respect to // the low bits of the output of map_.hash_function(). - vector<int64> times; + std::vector<int64> times; std::set<int>::iterator it = s.begin(); int count = 0; do { @@ -506,7 +506,7 @@ static void StressTestIterators(int n, bool test_old_style_proto2_maps) { // Finally, ensure erase(iterator) doesn't reorder anything, because that is // what its documentation says. m[last_key] = m[last_key ^ 999] = 0; - vector<Map<int, int>::iterator> v; + std::vector<Map<int, int>::iterator> v; v.reserve(m.size()); int position_of_last_key = 0; for (Map<int, int>::iterator it = m.begin(); it != m.end(); ++it) { @@ -563,7 +563,7 @@ TEST_P(MapImplTest, EraseRevalidates) { map_[3] = map_[13] = map_[20] = 0; const int initial_size = map_.size(); EXPECT_EQ(3, initial_size); - vector<Map<int, int>::iterator> v; + std::vector<Map<int, int>::iterator> v; for (Map<int, int>::iterator it = map_.begin(); it != map_.end(); ++it) { v.push_back(it); } @@ -2437,7 +2437,7 @@ TEST(GeneratedMapFieldReflectionTest, SwapFields) { MapTestUtil::SetMapFields(&message2); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; const Reflection* reflection = message1.GetReflection(); reflection->ListFields(message2, &fields); reflection->SwapFields(&message1, &message2, fields); @@ -2873,6 +2873,33 @@ TEST(WireFormatForMapFieldTest, MapParseHelpers) { // Deterministic Serialization Test ========================================== template <typename T> +static string DeterministicSerializationWithSerializePartialToCodedStream( + const T& t) { + const int size = t.ByteSize(); + string result(size, '\0'); + io::ArrayOutputStream array_stream(string_as_array(&result), size); + io::CodedOutputStream output_stream(&array_stream); + output_stream.SetSerializationDeterministic(true); + t.SerializePartialToCodedStream(&output_stream); + EXPECT_FALSE(output_stream.HadError()); + EXPECT_EQ(size, output_stream.ByteCount()); + return result; +} + +template <typename T> +static string DeterministicSerializationWithSerializeToCodedStream(const T& t) { + const int size = t.ByteSize(); + string result(size, '\0'); + io::ArrayOutputStream array_stream(string_as_array(&result), size); + io::CodedOutputStream output_stream(&array_stream); + output_stream.SetSerializationDeterministic(true); + t.SerializeToCodedStream(&output_stream); + EXPECT_FALSE(output_stream.HadError()); + EXPECT_EQ(size, output_stream.ByteCount()); + return result; +} + +template <typename T> static string DeterministicSerialization(const T& t) { const int size = t.ByteSize(); string result(size, '\0'); @@ -2882,6 +2909,9 @@ static string DeterministicSerialization(const T& t) { t.SerializeWithCachedSizes(&output_stream); EXPECT_FALSE(output_stream.HadError()); EXPECT_EQ(size, output_stream.ByteCount()); + EXPECT_EQ(result, DeterministicSerializationWithSerializeToCodedStream(t)); + EXPECT_EQ(result, + DeterministicSerializationWithSerializePartialToCodedStream(t)); return result; } @@ -2983,6 +3013,18 @@ TEST(TextFormatMapTest, Sorted) { EXPECT_EQ(message2.DebugString(), expected_text); } +TEST(TextFormatMapTest, ParseCorruptedString) { + string serialized_message; + GOOGLE_CHECK_OK(File::GetContents( + TestSourceDir() + + "/google/protobuf/testdata/golden_message_maps", + &serialized_message, true)); + protobuf_unittest::TestMaps message; + GOOGLE_CHECK(message.ParseFromString(serialized_message)); + TestParseCorruptedString<protobuf_unittest::TestMaps, true>(message); + TestParseCorruptedString<protobuf_unittest::TestMaps, false>(message); +} + // arena support ================================================= TEST(ArenaTest, ParsingAndSerializingNoHeapAllocation) { diff --git a/src/google/protobuf/map_test_util.cc b/src/google/protobuf/map_test_util.cc index ae094647..3dd6aae5 100644 --- a/src/google/protobuf/map_test_util.cc +++ b/src/google/protobuf/map_test_util.cc @@ -867,7 +867,7 @@ void MapReflectionTester::RemoveLastMapsViaReflection( Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> output; + std::vector<const FieldDescriptor*> output; reflection->ListFields(*message, &output); for (int i = 0; i < output.size(); ++i) { const FieldDescriptor* field = output[i]; @@ -880,7 +880,7 @@ void MapReflectionTester::ReleaseLastMapsViaReflection( Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> output; + std::vector<const FieldDescriptor*> output; reflection->ListFields(*message, &output); for (int i = 0; i < output.size(); ++i) { const FieldDescriptor* field = output[i]; @@ -896,7 +896,7 @@ void MapReflectionTester::ReleaseLastMapsViaReflection( void MapReflectionTester::SwapMapsViaReflection(Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> output; + std::vector<const FieldDescriptor*> output; reflection->ListFields(*message, &output); for (int i = 0; i < output.size(); ++i) { const FieldDescriptor* field = output[i]; diff --git a/src/google/protobuf/map_type_handler.h b/src/google/protobuf/map_type_handler.h index a21c92d9..ac987cbc 100644 --- a/src/google/protobuf/map_type_handler.h +++ b/src/google/protobuf/map_type_handler.h @@ -556,7 +556,7 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::MapEntryAccessorType& \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ Type>::GetExternalReference(const TypeOnMemory& value) { \ - return value.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); \ + return value.Get(); \ } \ template <typename Type> \ inline int \ @@ -581,11 +581,9 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, arena); \ } \ template <typename Type> \ - inline void \ - MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ - Type>::ClearMaybeByDefaultEnum(TypeOnMemory* value, \ - Arena* arena, \ - int default_enum) { \ + inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \ + ClearMaybeByDefaultEnum(TypeOnMemory* value, Arena* arena, \ + int default_enum) { \ Clear(value, arena); \ } \ template <typename Type> \ @@ -609,11 +607,9 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, &::google::protobuf::internal::GetEmptyStringAlreadyInited()); \ } \ template <typename Type> \ - inline void \ - MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ - Type>::InitializeMaybeByDefaultEnum(TypeOnMemory* value, \ - int default_enum_value, \ - Arena* arena) { \ + inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \ + InitializeMaybeByDefaultEnum(TypeOnMemory* value, \ + int default_enum_value, Arena* arena) { \ Initialize(value, arena); \ } \ template <typename Type> \ @@ -631,7 +627,7 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::DefaultIfNotInitialized(const TypeOnMemory& value, \ const TypeOnMemory& \ default_value) { \ - return value.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); \ + return value.Get(); \ } \ template <typename Type> \ inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index c8de458c..a5a7feb6 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -96,12 +96,12 @@ bool Message::IsInitialized() const { return ReflectionOps::IsInitialized(*this); } -void Message::FindInitializationErrors(vector<string>* errors) const { +void Message::FindInitializationErrors(std::vector<string>* errors) const { return ReflectionOps::FindInitializationErrors(*this, "", errors); } string Message::InitializationErrorString() const { - vector<string> errors; + std::vector<string> errors; FindInitializationErrors(&errors); return Join(errors, ", "); } @@ -225,38 +225,6 @@ void* Reflection::MutableRawRepeatedString( } -// Default EnumValue API implementations. Real reflection implementations should -// override these. However, there are several legacy implementations that do -// not, and cannot easily be changed at the same time as the Reflection API, so -// we provide these for now. -// TODO: Remove these once all Reflection implementations are updated. -int Reflection::GetEnumValue(const Message& message, - const FieldDescriptor* field) const { - GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API."; - return 0; -} -void Reflection::SetEnumValue(Message* message, - const FieldDescriptor* field, - int value) const { - GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API."; -} -int Reflection::GetRepeatedEnumValue( - const Message& message, - const FieldDescriptor* field, int index) const { - GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API."; - return 0; -} -void Reflection::SetRepeatedEnumValue(Message* message, - const FieldDescriptor* field, int index, - int value) const { - GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API."; -} -void Reflection::AddEnumValue(Message* message, - const FieldDescriptor* field, - int value) const { - GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API."; -} - MapIterator Reflection::MapBegin( Message* message, const FieldDescriptor* field) const { diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index bee25f77..872df7a9 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -519,7 +519,7 @@ class LIBPROTOBUF_EXPORT Reflection { // will only be present when the new unknown-enum-value semantics are enabled // for a message.) virtual int GetEnumValue( - const Message& message, const FieldDescriptor* field) const; + const Message& message, const FieldDescriptor* field) const = 0; // See MutableMessage() for the meaning of the "factory" parameter. virtual const Message& GetMessage(const Message& message, @@ -575,7 +575,7 @@ class LIBPROTOBUF_EXPORT Reflection { // messages with new unknown-enum-value semantics. virtual void SetEnumValue(Message* message, const FieldDescriptor* field, - int value) const; + int value) const = 0; // Get a mutable pointer to a field with a message type. If a MessageFactory // is provided, it will be used to construct instances of the sub-message; @@ -646,7 +646,7 @@ class LIBPROTOBUF_EXPORT Reflection { // for a message.) virtual int GetRepeatedEnumValue( const Message& message, - const FieldDescriptor* field, int index) const; + const FieldDescriptor* field, int index) const = 0; virtual const Message& GetRepeatedMessage( const Message& message, const FieldDescriptor* field, int index) const = 0; @@ -693,7 +693,7 @@ class LIBPROTOBUF_EXPORT Reflection { // messages with new unknown-enum-value semantics. virtual void SetRepeatedEnumValue(Message* message, const FieldDescriptor* field, int index, - int value) const; + int value) const = 0; // Get a mutable pointer to an element of a repeated field with a message // type. virtual Message* MutableRepeatedMessage( @@ -729,7 +729,7 @@ class LIBPROTOBUF_EXPORT Reflection { // messages with new unknown-enum-value semantics. virtual void AddEnumValue(Message* message, const FieldDescriptor* field, - int value) const; + int value) const = 0; // See MutableMessage() for comments on the "factory" parameter. virtual Message* AddMessage(Message* message, const FieldDescriptor* field, @@ -848,34 +848,31 @@ class LIBPROTOBUF_EXPORT Reflection { // downgrade to a compatible value or use the UnknownFieldSet if not. For // example: // - // int new_value = GetValueFromApplicationLogic(); - // if (reflection->SupportsUnknownEnumValues()) { + // int new_value = GetValueFromApplicationLogic(); + // if (reflection->SupportsUnknownEnumValues()) { // reflection->SetEnumValue(message, field, new_value); - // } else { + // } else { // if (field_descriptor->enum_type()-> // FindValueByNumver(new_value) != NULL) { - // reflection->SetEnumValue(message, field, new_value); + // reflection->SetEnumValue(message, field, new_value); // } else if (emit_unknown_enum_values) { - // reflection->MutableUnknownFields(message)->AddVarint( - // field->number(), - // new_value); + // reflection->MutableUnknownFields(message)->AddVarint( + // field->number(), new_value); // } else { - // // convert value to a compatible/default value. - // new_value = CompatibleDowngrade(new_value); - // reflection->SetEnumValue(message, field, new_value); + // // convert value to a compatible/default value. + // new_value = CompatibleDowngrade(new_value); + // reflection->SetEnumValue(message, field, new_value); // } - // } + // } virtual bool SupportsUnknownEnumValues() const { return false; } // Returns the MessageFactory associated with this message. This can be // useful for determining if a message is a generated message or not, for // example: - // - // if (message->GetReflection()->GetMessageFactory() == - // google::protobuf::MessageFactory::generated_factory()) { - // // This is a generated message. - // } - // + // if (message->GetReflection()->GetMessageFactory() == + // google::protobuf::MessageFactory::generated_factory()) { + // // This is a generated message. + // } // It can also be used to create more messages of this type, though // Message::New() is an easier way to accomplish this. virtual MessageFactory* GetMessageFactory() const; diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc index 1c6786db..a42e9ec3 100644 --- a/src/google/protobuf/message_lite.cc +++ b/src/google/protobuf/message_lite.cc @@ -34,6 +34,7 @@ // Sanjay Ghemawat, Jeff Dean, and others. #include <climits> + #include <google/protobuf/arena.h> #include <google/protobuf/generated_message_util.h> #include <google/protobuf/message_lite.h> @@ -238,21 +239,18 @@ 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 size_t size = ByteSizeLong(); // Force size to be cached. if (size > INT_MAX) { - GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB."; + GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB: " << size; return false; } uint8* buffer = output->GetDirectBufferForNBytesAndAdvance(size); if (buffer != NULL) { - uint8* end = SerializeWithCachedSizesToArray(buffer); + uint8* end = InternalSerializeWithCachedSizesToArray( + output->IsSerializationDeterministic(), buffer); if (end - buffer != size) { ByteSizeConsistencyError(size, ByteSizeLong(), end - buffer, *this); } @@ -295,7 +293,7 @@ bool MessageLite::AppendPartialToString(string* output) const { 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."; + GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB: " << byte_size; return false; } diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index 88455669..d5de8cdb 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -40,6 +40,7 @@ #define GOOGLE_PROTOBUF_MESSAGE_LITE_H__ #include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/logging.h> namespace google { @@ -239,17 +240,22 @@ class LIBPROTOBUF_EXPORT MessageLite { bool AppendPartialToString(string* output) const; // Computes the serialized size of the message. This recursively calls - // ByteSize() on all embedded messages. Subclasses MUST override either - // ByteSize() or ByteSizeLong() (overriding both is fine). + // ByteSizeLong() on all embedded messages. // - // ByteSize() is generally linear in the number of fields defined for the + // ByteSizeLong() is generally linear in the number of fields defined for the // proto. - virtual int ByteSize() const { return static_cast<int>(ByteSizeLong()); } - virtual size_t ByteSizeLong() const; + virtual size_t ByteSizeLong() const = 0; - // Serializes the message without recomputing the size. The message must - // not have changed since the last call to ByteSize(); if it has, the results - // are undefined. + // Legacy ByteSize() API. + int ByteSize() const { + size_t result = ByteSizeLong(); + GOOGLE_DCHECK_LE(result, static_cast<size_t>(INT_MAX)); + return static_cast<int>(result); + } + + // Serializes the message without recomputing the size. The message must not + // have changed since the last call to ByteSize(), and the value returned by + // ByteSize must be non-negative. Otherwise the results are undefined. virtual void SerializeWithCachedSizes( io::CodedOutputStream* output) const = 0; diff --git a/src/google/protobuf/message_unittest.cc b/src/google/protobuf/message_unittest.cc index 3af05808..de39fff8 100644 --- a/src/google/protobuf/message_unittest.cc +++ b/src/google/protobuf/message_unittest.cc @@ -48,6 +48,7 @@ #include <google/protobuf/test_util.h> #include <google/protobuf/unittest.pb.h> #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/descriptor.pb.h> #include <google/protobuf/descriptor.h> @@ -182,7 +183,7 @@ TEST(MessageTest, ParseHelpers) { TEST(MessageTest, ParseFailsIfNotInitialized) { unittest::TestRequired message; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; @@ -286,28 +287,96 @@ TEST(MessageTest, CheckBigOverflow) { #endif // PROTOBUF_HAS_DEATH_TEST namespace { - -class NegativeByteSize : public unittest::TestRequired { +// An input stream that repeats a string's content for a number of times. It +// helps us create a really large input without consuming too much memory. Used +// to test the parsing behavior when the input size exceeds 2G or close to it. +class RepeatedInputStream : public io::ZeroCopyInputStream { public: - virtual int ByteSize() const { return -1; } + RepeatedInputStream(const string& data, size_t count) + : data_(data), count_(count), position_(0), total_byte_count_(0) {} + + virtual bool Next(const void** data, int* size) { + if (position_ == data_.size()) { + if (--count_ == 0) { + return false; + } + position_ = 0; + } + *data = &data_[position_]; + *size = static_cast<int>(data_.size() - position_); + position_ = data_.size(); + total_byte_count_ += *size; + return true; + } - // 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()); + virtual void BackUp(int count) { + position_ -= static_cast<size_t>(count); + total_byte_count_ -= count; } -}; + virtual bool Skip(int count) { + while (count > 0) { + const void* data; + int size; + if (!Next(&data, &size)) { + break; + } + if (size >= count) { + BackUp(size - count); + return true; + } else { + count -= size; + } + } + return false; + } + + virtual int64 ByteCount() const { return total_byte_count_; } + + private: + string data_; + size_t count_; // The number of strings that haven't been consuemd. + size_t position_; // Position in the string for the next read. + int64 total_byte_count_; +}; } // namespace -TEST(MessageTest, SerializationFailsOnNegativeByteSize) { - NegativeByteSize message; - string string_output; - EXPECT_FALSE(message.AppendPartialToString(&string_output)); +TEST(MessageTest, TestParseMessagesCloseTo2G) { + // Create a message with a large string field. + string value = string(64 * 1024 * 1024, 'x'); + protobuf_unittest::TestAllTypes message; + message.set_optional_string(value); + + // Repeat this message in the input stream to make the total input size + // close to 2G. + string data = message.SerializeAsString(); + size_t count = static_cast<size_t>(kint32max) / data.size(); + RepeatedInputStream input(data, count); + + // The parsing should succeed. + protobuf_unittest::TestAllTypes result; + EXPECT_TRUE(result.ParseFromZeroCopyStream(&input)); + + // When there are multiple occurences of a singulr field, the last one + // should win. + EXPECT_EQ(value, result.optional_string()); +} + +TEST(MessageTest, TestParseMessagesOver2G) { + // Create a message with a large string field. + string value = string(64 * 1024 * 1024, 'x'); + protobuf_unittest::TestAllTypes message; + message.set_optional_string(value); + + // Repeat this message in the input stream to make the total input size + // larger than 2G. + string data = message.SerializeAsString(); + size_t count = static_cast<size_t>(kint32max) / data.size() + 1; + RepeatedInputStream input(data, count); - io::ArrayOutputStream coded_raw_output(NULL, 100); - io::CodedOutputStream coded_output(&coded_raw_output); - EXPECT_FALSE(message.SerializePartialToCodedStream(&coded_output)); + // The parsing should fail. + protobuf_unittest::TestAllTypes result; + EXPECT_FALSE(result.ParseFromZeroCopyStream(&input)); } TEST(MessageTest, BypassInitializationCheckOnSerialize) { @@ -319,7 +388,7 @@ TEST(MessageTest, BypassInitializationCheckOnSerialize) { TEST(MessageTest, FindInitializationErrors) { unittest::TestRequired message; - vector<string> errors; + std::vector<string> errors; message.FindInitializationErrors(&errors); ASSERT_EQ(3, errors.size()); EXPECT_EQ("a", errors[0]); diff --git a/src/google/protobuf/metadata.h b/src/google/protobuf/metadata.h index 6e3eef63..f9257534 100644 --- a/src/google/protobuf/metadata.h +++ b/src/google/protobuf/metadata.h @@ -40,6 +40,8 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/arena.h> +#include <google/protobuf/arenastring.h> +#include <google/protobuf/generated_message_util.h> #include <google/protobuf/unknown_field_set.h> namespace google { @@ -56,30 +58,30 @@ namespace internal { // The tagged pointer uses the LSB to disambiguate cases, and uses bit 0 == 0 to // indicate an arena pointer and bit 0 == 1 to indicate a UFS+Arena-container // pointer. -class LIBPROTOBUF_EXPORT InternalMetadataWithArena { +template <class T, class Derived> +class InternalMetadataWithArenaBase { public: - InternalMetadataWithArena() : ptr_(NULL) {} - explicit InternalMetadataWithArena(Arena* arena) - : ptr_ (arena) {} + InternalMetadataWithArenaBase() : ptr_(NULL) {} + explicit InternalMetadataWithArenaBase(Arena* arena) : ptr_(arena) {} - ~InternalMetadataWithArena() { + ~InternalMetadataWithArenaBase() { if (have_unknown_fields() && arena() == NULL) { delete PtrValue<Container>(); } ptr_ = NULL; } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE const UnknownFieldSet& unknown_fields() const { + GOOGLE_ATTRIBUTE_ALWAYS_INLINE const T& unknown_fields() const { if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) { - return PtrValue<Container>()->unknown_fields_; + return PtrValue<Container>()->unknown_fields; } else { - return *UnknownFieldSet::default_instance(); + return Derived::default_instance(); } } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE UnknownFieldSet* mutable_unknown_fields() { + GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* mutable_unknown_fields() { if (GOOGLE_PREDICT_TRUE(have_unknown_fields())) { - return &PtrValue<Container>()->unknown_fields_; + return &PtrValue<Container>()->unknown_fields; } else { return mutable_unknown_fields_slow(); } @@ -87,7 +89,7 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena { GOOGLE_ATTRIBUTE_ALWAYS_INLINE Arena* arena() const { if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) { - return PtrValue<Container>()->arena_; + return PtrValue<Container>()->arena; } else { return PtrValue<Arena>(); } @@ -97,7 +99,7 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena { return PtrTag() == kTagContainer; } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(InternalMetadataWithArena* other) { + GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(Derived* other) { // Semantics here are that we swap only the unknown fields, not the arena // pointer. We cannot simply swap ptr_ with other->ptr_ because we need to // maintain our own arena ptr. Also, our ptr_ and other's ptr_ may be in @@ -105,7 +107,19 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena { // cannot simply swap ptr_ and then restore the arena pointers. We reuse // UFS's swap implementation instead. if (have_unknown_fields() || other->have_unknown_fields()) { - mutable_unknown_fields()->Swap(other->mutable_unknown_fields()); + static_cast<Derived*>(this)->DoSwap(other->mutable_unknown_fields()); + } + } + + GOOGLE_ATTRIBUTE_ALWAYS_INLINE void MergeFrom(const Derived& other) { + if (other.have_unknown_fields()) { + static_cast<Derived*>(this)->DoMergeFrom(other.unknown_fields()); + } + } + + GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Clear() { + if (have_unknown_fields()) { + static_cast<Derived*>(this)->DoClear(); } } @@ -131,24 +145,78 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena { return reinterpret_cast<intptr_t>(ptr_) & kPtrTagMask; } - template<typename T> T* PtrValue() const { - return reinterpret_cast<T*>( + template<typename U> U* PtrValue() const { + return reinterpret_cast<U*>( reinterpret_cast<intptr_t>(ptr_) & kPtrValueMask); } // If ptr_'s tag is kTagContainer, it points to an instance of this struct. struct Container { - UnknownFieldSet unknown_fields_; - Arena* arena_; + T unknown_fields; + Arena* arena; }; - GOOGLE_ATTRIBUTE_NOINLINE UnknownFieldSet* mutable_unknown_fields_slow() { + GOOGLE_ATTRIBUTE_NOINLINE T* mutable_unknown_fields_slow() { Arena* my_arena = arena(); Container* container = Arena::Create<Container>(my_arena); ptr_ = reinterpret_cast<void*>( reinterpret_cast<intptr_t>(container) | kTagContainer); - container->arena_ = my_arena; - return &(container->unknown_fields_); + container->arena = my_arena; + return &(container->unknown_fields); + } +}; + +class InternalMetadataWithArena + : public InternalMetadataWithArenaBase<UnknownFieldSet, + InternalMetadataWithArena> { + public: + InternalMetadataWithArena() {} + explicit InternalMetadataWithArena(Arena* arena) + : InternalMetadataWithArenaBase(arena) {} + + void DoSwap(UnknownFieldSet* other) { + mutable_unknown_fields()->Swap(other); + } + + void DoMergeFrom(const UnknownFieldSet& other) { + mutable_unknown_fields()->MergeFrom(other); + } + + void DoClear() { + mutable_unknown_fields()->Clear(); + } + + static const UnknownFieldSet& default_instance() { + return *UnknownFieldSet::default_instance(); + } +}; + +// We store unknown fields as a string right now, because there is currently no +// good interface for reading unknown fields into an ArenaString. We may want +// to revisit this to allow unknown fields to be parsed onto the Arena. +class InternalMetadataWithArenaLite + : public InternalMetadataWithArenaBase<string, + InternalMetadataWithArenaLite> { + public: + InternalMetadataWithArenaLite() {} + + explicit InternalMetadataWithArenaLite(Arena* arena) + : InternalMetadataWithArenaBase(arena) {} + + void DoSwap(string* other) { + mutable_unknown_fields()->swap(*other); + } + + void DoMergeFrom(const string& other) { + mutable_unknown_fields()->append(other); + } + + void DoClear() { + mutable_unknown_fields()->clear(); + } + + static const string& default_instance() { + return GetEmptyStringAlreadyInited(); } }; diff --git a/src/google/protobuf/reflection_ops.cc b/src/google/protobuf/reflection_ops.cc index 4629dec2..bb9c7f8b 100644 --- a/src/google/protobuf/reflection_ops.cc +++ b/src/google/protobuf/reflection_ops.cc @@ -63,7 +63,7 @@ void ReflectionOps::Merge(const Message& from, Message* to) { const Reflection* from_reflection = from.GetReflection(); const Reflection* to_reflection = to->GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; from_reflection->ListFields(from, &fields); for (int i = 0; i < fields.size(); i++) { const FieldDescriptor* field = fields[i]; @@ -129,7 +129,7 @@ void ReflectionOps::Merge(const Message& from, Message* to) { void ReflectionOps::Clear(Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(*message, &fields); for (int i = 0; i < fields.size(); i++) { reflection->ClearField(message, fields[i]); @@ -152,7 +152,7 @@ bool ReflectionOps::IsInitialized(const Message& message) { } // Check that sub-messages are initialized. - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message, &fields); for (int i = 0; i < fields.size(); i++) { const FieldDescriptor* field = fields[i]; @@ -183,7 +183,7 @@ void ReflectionOps::DiscardUnknownFields(Message* message) { reflection->MutableUnknownFields(message)->Clear(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(*message, &fields); for (int i = 0; i < fields.size(); i++) { const FieldDescriptor* field = fields[i]; @@ -224,7 +224,7 @@ static string SubMessagePrefix(const string& prefix, void ReflectionOps::FindInitializationErrors( const Message& message, const string& prefix, - vector<string>* errors) { + std::vector<string>* errors) { const Descriptor* descriptor = message.GetDescriptor(); const Reflection* reflection = message.GetReflection(); @@ -238,7 +238,7 @@ void ReflectionOps::FindInitializationErrors( } // Check sub-messages. - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message, &fields); for (int i = 0; i < fields.size(); i++) { const FieldDescriptor* field = fields[i]; diff --git a/src/google/protobuf/reflection_ops_unittest.cc b/src/google/protobuf/reflection_ops_unittest.cc index 88d6bfb6..86453170 100644 --- a/src/google/protobuf/reflection_ops_unittest.cc +++ b/src/google/protobuf/reflection_ops_unittest.cc @@ -419,7 +419,7 @@ TEST(ReflectionOpsTest, OneofIsInitialized) { } static string FindInitializationErrors(const Message& message) { - vector<string> errors; + std::vector<string> errors; ReflectionOps::FindInitializationErrors(message, "", &errors); return Join(errors, ","); } diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index 6ede0e1a..bbdef449 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -61,8 +61,9 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/message_lite.h> -namespace google { +// Forward-declare these so that we can make them friends. +namespace google { namespace upb { namespace google_opensource { class GMR_Handlers; @@ -104,7 +105,7 @@ inline int CalculateReserve(Iter begin, Iter end) { // not ever use a RepeatedField directly; they will use the get-by-index, // set-by-index, and add accessors that are generated for all repeated fields. template <typename Element> -class RepeatedField { +class RepeatedField PROTOBUF_FINAL { public: RepeatedField(); explicit RepeatedField(Arena* arena); @@ -126,6 +127,8 @@ class RepeatedField { void Set(int index, const Element& value); void Add(const Element& value); + // Appends a new element and return a pointer to it. + // The new element is uninitialized if |Element| is a POD type. Element* Add(); // Remove the last element in the array. void RemoveLast(); @@ -138,7 +141,6 @@ 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 @@ -149,6 +151,9 @@ class RepeatedField { void Truncate(int new_size); void AddAlreadyReserved(const Element& value); + // Appends a new element and return a pointer to it. + // The new element is uninitialized if |Element| is a POD type. + // Should be called only if Capacity() > Size(). Element* AddAlreadyReserved(); int Capacity() const; @@ -311,7 +316,7 @@ template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator; namespace internal { -// This is a helper template to copy an array of elements effeciently when they +// This is a helper template to copy an array of elements efficiently when they // have a trivial copy constructor, and correctly otherwise. This really // shouldn't be necessary, but our compiler doesn't optimize std::copy very // effectively. @@ -719,7 +724,7 @@ class LIBPROTOBUF_EXPORT StringTypeHandler { // RepeatedPtrField is like RepeatedField, but used for repeated strings or // Messages. template <typename Element> -class RepeatedPtrField : public internal::RepeatedPtrFieldBase { +class RepeatedPtrField PROTOBUF_FINAL : public internal::RepeatedPtrFieldBase { public: RepeatedPtrField(); explicit RepeatedPtrField(::google::protobuf::Arena* arena); @@ -752,7 +757,6 @@ 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 @@ -859,10 +863,10 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase { // RepeatedPtrField. // It is also useful in legacy code that uses temporary ownership to avoid // copies. Example: - // RepeatedPtrField<T> temp_field; - // temp_field.AddAllocated(new T); - // ... // Do something with temp_field - // temp_field.ExtractSubrange(0, temp_field.size(), NULL); + // RepeatedPtrField<T> temp_field; + // temp_field.AddAllocated(new T); + // ... // Do something with temp_field + // temp_field.ExtractSubrange(0, temp_field.size(), NULL); // If you put temp_field on the arena this fails, because the ownership // transfers to the arena at the "AddAllocated" call and is not released // anymore causing a double delete. UnsafeArenaAddAllocated prevents this. @@ -944,17 +948,13 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase { return GetArenaNoVirtual(); } - protected: - // Note: RepeatedPtrField SHOULD NOT be subclassed by users. We only - // subclass it in one place as a hack for compatibility with proto1. The - // subclass needs to know about TypeHandler in order to call protected - // methods on RepeatedPtrFieldBase. + private: + // Note: RepeatedPtrField SHOULD NOT be subclassed by users. class TypeHandler; // Internal arena accessor expected by helpers in Arena. inline Arena* GetArenaNoVirtual() const; - private: // Implementations for ExtractSubrange(). The copying behavior must be // included only if the type supports the necessary operations (e.g., // MergeFrom()), so we must resolve this at compile time. ExtractSubrange() @@ -997,7 +997,12 @@ inline RepeatedField<Element>::RepeatedField(const RepeatedField& other) : current_size_(0), total_size_(0), rep_(NULL) { - CopyFrom(other); + if (other.current_size_ != 0) { + Reserve(other.current_size_); + CopyArray(rep_->elements, + other.rep_->elements, other.current_size_); + current_size_ = other.current_size_; + } } template <typename Element> @@ -1138,7 +1143,8 @@ inline void RepeatedField<Element>::Clear() { } template <typename Element> -inline void RepeatedField<Element>::UnsafeMergeFrom(const RepeatedField& other) { +inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) { + GOOGLE_DCHECK_NE(&other, this); if (other.current_size_ != 0) { Reserve(current_size_ + other.current_size_); CopyArray(rep_->elements + current_size_, @@ -1148,12 +1154,6 @@ inline void RepeatedField<Element>::UnsafeMergeFrom(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(); @@ -1292,7 +1292,7 @@ void RepeatedField<Element>::Reserve(int new_size) { Element* e = &rep_->elements[0]; Element* limit = &rep_->elements[total_size_]; for (; e < limit; e++) { - new (e) Element(); + new (e) Element; } if (current_size_ > 0) { MoveArray(rep_->elements, old_rep->elements, current_size_); @@ -1792,7 +1792,7 @@ template <typename Element> inline RepeatedPtrField<Element>::RepeatedPtrField( const RepeatedPtrField& other) : RepeatedPtrFieldBase() { - CopyFrom(other); + MergeFrom(other); } template <typename Element> @@ -2469,10 +2469,10 @@ AllocatedRepeatedPtrFieldBackInserter( // UnsafeArenaAddAllocated instead of AddAllocated. // This is slightly faster if that matters. It is also useful in legacy code // that uses temporary ownership to avoid copies. Example: -// RepeatedPtrField<T> temp_field; -// temp_field.AddAllocated(new T); -// ... // Do something with temp_field -// temp_field.ExtractSubrange(0, temp_field.size(), NULL); +// RepeatedPtrField<T> temp_field; +// temp_field.AddAllocated(new T); +// ... // Do something with temp_field +// temp_field.ExtractSubrange(0, temp_field.size(), NULL); // If you put temp_field on the arena this fails, because the ownership // transfers to the arena at the "AddAllocated" call and is not released anymore // causing a double delete. Using UnsafeArenaAddAllocated prevents this. diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc index 33547146..ec1074c9 100644 --- a/src/google/protobuf/repeated_field_unittest.cc +++ b/src/google/protobuf/repeated_field_unittest.cc @@ -268,11 +268,13 @@ TEST(RepeatedField, MergeFrom) { } #ifdef PROTOBUF_HAS_DEATH_TEST +#ifndef NDEBUG TEST(RepeatedField, MergeFromSelf) { RepeatedField<int> me; me.Add(3); EXPECT_DEATH(me.MergeFrom(me), ""); } +#endif // NDEBUG #endif // PROTOBUF_HAS_DEATH_TEST TEST(RepeatedField, CopyFrom) { @@ -344,7 +346,7 @@ TEST(RepeatedField, CopyConstruct) { } TEST(RepeatedField, IteratorConstruct) { - vector<int> values; + std::vector<int> values; values.push_back(1); values.push_back(2); @@ -858,7 +860,7 @@ TEST(RepeatedPtrField, CopyConstruct) { } TEST(RepeatedPtrField, IteratorConstruct_String) { - vector<string> values; + std::vector<string> values; values.push_back("1"); values.push_back("2"); @@ -875,7 +877,7 @@ TEST(RepeatedPtrField, IteratorConstruct_String) { TEST(RepeatedPtrField, IteratorConstruct_Proto) { typedef TestAllTypes::NestedMessage Nested; - vector<Nested> values; + std::vector<Nested> values; values.push_back(Nested()); values.back().set_bb(1); values.push_back(Nested()); @@ -949,7 +951,7 @@ TEST(RepeatedPtrField, ExtractSubrange) { for (int num = 0; num <= sz; ++num) { for (int start = 0; start < sz - num; ++start) { for (int extra = 0; extra < 4; ++extra) { - vector<string*> subject; + std::vector<string*> subject; // Create an array with "sz" elements and "extra" cleared elements. RepeatedPtrField<string> field; @@ -1511,7 +1513,7 @@ TEST_F(RepeatedFieldInsertionIteratorsTest, Nesteds) { TEST_F(RepeatedFieldInsertionIteratorsTest, AllocatedRepeatedPtrFieldWithStringIntData) { - vector<Nested*> data; + std::vector<Nested*> data; TestAllTypes goldenproto; for (int i = 0; i < 10; ++i) { Nested* new_data = new Nested; @@ -1530,7 +1532,7 @@ TEST_F(RepeatedFieldInsertionIteratorsTest, TEST_F(RepeatedFieldInsertionIteratorsTest, AllocatedRepeatedPtrFieldWithString) { - vector<string*> data; + std::vector<string*> data; TestAllTypes goldenproto; for (int i = 0; i < 10; ++i) { string* new_data = new string; @@ -1548,7 +1550,7 @@ TEST_F(RepeatedFieldInsertionIteratorsTest, TEST_F(RepeatedFieldInsertionIteratorsTest, UnsafeArenaAllocatedRepeatedPtrFieldWithStringIntData) { - vector<Nested*> data; + std::vector<Nested*> data; TestAllTypes goldenproto; for (int i = 0; i < 10; ++i) { Nested* new_data = new Nested; @@ -1567,7 +1569,7 @@ TEST_F(RepeatedFieldInsertionIteratorsTest, TEST_F(RepeatedFieldInsertionIteratorsTest, UnsafeArenaAllocatedRepeatedPtrFieldWithString) { - vector<string*> data; + std::vector<string*> data; TestAllTypes goldenproto; for (int i = 0; i < 10; ++i) { string* new_data = new string; diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index 951a0bcc..b9e5a73b 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -19,84 +19,88 @@ namespace google { namespace protobuf { +class SourceContextDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> {}; +SourceContextDefaultTypeInternal _SourceContext_default_instance_; namespace { -const ::google::protobuf::Descriptor* SourceContext_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - SourceContext_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/source_context.proto"); - GOOGLE_CHECK(file != NULL); - SourceContext_descriptor_ = file->message_type(0); - static const int SourceContext_offsets_[1] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fsource_5fcontext_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fsource_5fcontext_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, file_name_), }; - SourceContext_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - SourceContext_descriptor_, - SourceContext::internal_default_instance(), - SourceContext_offsets_, - -1, - -1, - -1, - sizeof(SourceContext), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(SourceContext)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_SourceContext_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/source_context.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fsource_5fcontext_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceContext_descriptor_, SourceContext::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto() { - SourceContext_default_instance_.Shutdown(); - delete SourceContext_reflection_; + _SourceContext_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } 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::internal::InitProtobufDefaults(); + _SourceContext_default_instance_.DefaultConstruct(); } -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); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&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(); + static const char descriptor[] = { + "\n$google/protobuf/source_context.proto\022\017" + "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile" + "_name\030\001 \001(\tB\225\001\n\023com.google.protobufB\022Sou" + "rceContextProtoP\001ZAgoogle.golang.org/gen" + "proto/protobuf/source_context;source_con" + "text\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTy" + "pesb\006proto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n$google/protobuf/source_context.proto\022\017" - "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile" - "_name\030\001 \001(\tBR\n\023com.google.protobufB\022Sour" - "ceContextProtoP\001\242\002\003GPB\252\002\036Google.Protobuf" - ".WellKnownTypesb\006proto3", 183); + descriptor, 251); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/source_context.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto); @@ -114,16 +118,6 @@ 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 @@ -132,19 +126,21 @@ const int SourceContext::kFileNameFieldNumber; SourceContext::SourceContext() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.SourceContext) } - -void SourceContext::InitAsDefaultInstance() { -} - SourceContext::SourceContext(const SourceContext& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + file_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.file_name().size() > 0) { + file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext) } @@ -169,7 +165,7 @@ void SourceContext::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* SourceContext::descriptor() { protobuf_AssignDescriptorsOnce(); - return SourceContext_descriptor_; + return file_level_metadata[0].descriptor; } const SourceContext& SourceContext::default_instance() { @@ -177,8 +173,6 @@ const SourceContext& SourceContext::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<SourceContext> SourceContext_default_instance_; - SourceContext* SourceContext::New(::google::protobuf::Arena* arena) const { SourceContext* n = new SourceContext; if (arena != NULL) { @@ -198,13 +192,13 @@ bool SourceContext::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.SourceContext) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string file_name = 1; + // string file_name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_file_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -214,7 +208,6 @@ bool SourceContext::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -242,7 +235,7 @@ failure: void SourceContext::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.SourceContext) - // optional string file_name = 1; + // string file_name = 1; if (this->file_name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->file_name().data(), this->file_name().length(), @@ -259,7 +252,7 @@ void SourceContext::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceContext) - // optional string file_name = 1; + // string file_name = 1; if (this->file_name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->file_name().data(), this->file_name().length(), @@ -278,7 +271,7 @@ size_t SourceContext::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceContext) size_t total_size = 0; - // optional string file_name = 1; + // string file_name = 1; if (this->file_name().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( @@ -294,7 +287,7 @@ size_t SourceContext::ByteSizeLong() const { void SourceContext::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceContext) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const SourceContext* source = ::google::protobuf::internal::DynamicCastToGenerated<const SourceContext>( &from); @@ -303,21 +296,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void SourceContext::MergeFrom(const SourceContext& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceContext) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void SourceContext::UnsafeMergeFrom(const SourceContext& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.file_name().size() > 0) { file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_); @@ -335,11 +321,10 @@ void SourceContext::CopyFrom(const SourceContext& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceContext) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool SourceContext::IsInitialized() const { - return true; } @@ -349,28 +334,24 @@ void SourceContext::Swap(SourceContext* other) { } void SourceContext::InternalSwap(SourceContext* other) { file_name_.Swap(&other->file_name_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata SourceContext::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = SourceContext_descriptor_; - metadata.reflection = SourceContext_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // SourceContext -// optional string file_name = 1; +// string file_name = 1; void SourceContext::clear_file_name() { file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } 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()); + return file_name_.GetNoArena(); } void SourceContext::set_file_name(const ::std::string& value) { @@ -408,9 +389,6 @@ void SourceContext::set_allocated_file_name(::std::string* file_name) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name) } -inline const SourceContext* SourceContext::internal_default_instance() { - return &SourceContext_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 18a56941..281249d9 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -24,10 +24,17 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class SourceContext; +class SourceContextDefaultTypeInternal; +extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -35,10 +42,6 @@ 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(); - -class SourceContext; // =================================================================== @@ -57,55 +60,58 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ static const ::google::protobuf::Descriptor* descriptor(); static const SourceContext& default_instance(); - static const SourceContext* internal_default_instance(); + static inline const SourceContext* internal_default_instance() { + return reinterpret_cast<const SourceContext*>( + &_SourceContext_default_instance_); + } void Swap(SourceContext* other); // implements Message ---------------------------------------------- - inline SourceContext* New() const { return New(NULL); } + inline SourceContext* New() const PROTOBUF_FINAL { return New(NULL); } - SourceContext* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + SourceContext* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const SourceContext& from); void MergeFrom(const SourceContext& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(SourceContext* other); - void UnsafeMergeFrom(const SourceContext& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string file_name = 1; + // string file_name = 1; void clear_file_name(); static const int kFileNameFieldNumber = 1; const ::std::string& file_name() const; @@ -124,13 +130,10 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fsource_5fcontext_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> SourceContext_default_instance_; - // =================================================================== @@ -139,13 +142,13 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> Source #if !PROTOBUF_INLINE_NOT_IN_HEADERS // SourceContext -// optional string file_name = 1; +// string file_name = 1; inline void SourceContext::clear_file_name() { file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline 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()); + return file_name_.GetNoArena(); } inline void SourceContext::set_file_name(const ::std::string& value) { @@ -183,13 +186,11 @@ inline void SourceContext::set_allocated_file_name(::std::string* file_name) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name) } -inline const SourceContext* SourceContext::internal_default_instance() { - return &SourceContext_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/source_context.proto b/src/google/protobuf/source_context.proto index 79137ce8..f3b2c966 100644 --- a/src/google/protobuf/source_context.proto +++ b/src/google/protobuf/source_context.proto @@ -37,6 +37,7 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "SourceContextProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; +option go_package = "google.golang.org/genproto/protobuf/source_context;source_context"; // `SourceContext` represents information about the source of a // protobuf element, like the file in which it is defined. diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index c8f5af90..8bd2f8be 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -19,16 +19,17 @@ namespace google { namespace protobuf { +class StructDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Struct> {}; +StructDefaultTypeInternal _Struct_default_instance_; +class ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Value> {}; +ValueDefaultTypeInternal _Value_default_instance_; +class ListValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ListValue> {}; +ListValueDefaultTypeInternal _ListValue_default_instance_; namespace { -const ::google::protobuf::Descriptor* Struct_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Struct_reflection_ = NULL; -const ::google::protobuf::Descriptor* Struct_FieldsEntry_descriptor_ = NULL; -const ::google::protobuf::Descriptor* Value_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Value_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[4]; +const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[1]; struct ValueOneofInstance { int null_value_; double number_value_; @@ -36,157 +37,138 @@ struct ValueOneofInstance { bool bool_value_; const ::google::protobuf::Struct* struct_value_; const ::google::protobuf::ListValue* list_value_; -}* Value_default_oneof_instance_ = NULL; -const ::google::protobuf::Descriptor* ListValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - ListValue_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* NullValue_descriptor_ = NULL; +} Value_default_oneof_instance_; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/struct.proto"); - GOOGLE_CHECK(file != NULL); - Struct_descriptor_ = file->message_type(0); - static const int Struct_offsets_[1] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, fields_), - }; - Struct_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Struct_descriptor_, - Struct::internal_default_instance(), - Struct_offsets_, - -1, - -1, - -1, - sizeof(Struct), - 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] = { - PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, null_value_), - PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, number_value_), - PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, string_value_), - PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, bool_value_), - PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, struct_value_), - PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, list_value_), + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _internal_metadata_), + ~0u, // no _extensions_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _oneof_case_[0]), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), null_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), number_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), string_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), bool_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), struct_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), list_value_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, kind_), - }; - Value_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Value_descriptor_, - Value::internal_default_instance(), - Value_offsets_, - -1, - -1, - -1, - 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_)); - ListValue_descriptor_ = file->message_type(2); - static const int ListValue_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, values_), }; - ListValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - ListValue_descriptor_, - ListValue::internal_default_instance(), - ListValue_offsets_, - -1, - -1, - -1, - sizeof(ListValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_)); - NullValue_descriptor_ = file->enum_type(0); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Struct)}, + { 5, -1, sizeof(Value)}, + { 16, -1, sizeof(ListValue)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Struct_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Value_default_instance_), &Value_default_oneof_instance_}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_ListValue_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/struct.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto(), factory, + file_level_metadata, file_level_enum_descriptors, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 4); + const ::google::protobuf::Descriptor* Struct_FieldsEntry_descriptor = file_level_metadata[0].descriptor; ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Struct_descriptor_, Struct::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Struct_FieldsEntry_descriptor_, + Struct_FieldsEntry_descriptor, ::google::protobuf::internal::MapEntry< ::std::string, ::google::protobuf::Value, ::google::protobuf::internal::WireFormatLite::TYPE_STRING, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0>::CreateDefaultInstance( - Struct_FieldsEntry_descriptor_)); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Value_descriptor_, Value::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ListValue_descriptor_, ListValue::internal_default_instance()); + Struct_FieldsEntry_descriptor)); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto() { - Struct_default_instance_.Shutdown(); - delete Struct_reflection_; - Value_default_instance_.Shutdown(); - delete Value_default_oneof_instance_; - delete Value_reflection_; - ListValue_default_instance_.Shutdown(); - delete ListValue_reflection_; + _Struct_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; + _Value_default_instance_.Shutdown(); + delete file_level_metadata[2].reflection; + _ListValue_default_instance_.Shutdown(); + delete file_level_metadata[3].reflection; } 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::internal::InitProtobufDefaults(); + _Struct_default_instance_.DefaultConstruct(); + _Value_default_instance_.DefaultConstruct(); + _ListValue_default_instance_.DefaultConstruct(); + 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::internal_default_instance()); + Value_default_oneof_instance_.list_value_ = const_cast< ::google::protobuf::ListValue*>( + ::google::protobuf::ListValue::internal_default_instance()); } -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); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&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(); + static const char descriptor[] = { + "\n\034google/protobuf/struct.proto\022\017google.p" + "rotobuf\"\204\001\n\006Struct\0223\n\006fields\030\001 \003(\0132#.goo" + "gle.protobuf.Struct.FieldsEntry\032E\n\013Field" + "sEntry\022\013\n\003key\030\001 \001(\t\022%\n\005value\030\002 \001(\0132\026.goo" + "gle.protobuf.Value:\0028\001\"\352\001\n\005Value\0220\n\nnull" + "_value\030\001 \001(\0162\032.google.protobuf.NullValue" + "H\000\022\026\n\014number_value\030\002 \001(\001H\000\022\026\n\014string_val" + "ue\030\003 \001(\tH\000\022\024\n\nbool_value\030\004 \001(\010H\000\022/\n\014stru" + "ct_value\030\005 \001(\0132\027.google.protobuf.StructH" + "\000\0220\n\nlist_value\030\006 \001(\0132\032.google.protobuf." + "ListValueH\000B\006\n\004kind\"3\n\tListValue\022&\n\006valu" + "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\370\001\001\242\002\003GPB" + "\252\002\036Google.Protobuf.WellKnownTypesb\006proto" + "3" + }; ::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" - "gle.protobuf.Struct.FieldsEntry\032E\n\013Field" - "sEntry\022\013\n\003key\030\001 \001(\t\022%\n\005value\030\002 \001(\0132\026.goo" - "gle.protobuf.Value:\0028\001\"\352\001\n\005Value\0220\n\nnull" - "_value\030\001 \001(\0162\032.google.protobuf.NullValue" - "H\000\022\026\n\014number_value\030\002 \001(\001H\000\022\026\n\014string_val" - "ue\030\003 \001(\tH\000\022\024\n\nbool_value\030\004 \001(\010H\000\022/\n\014stru" - "ct_value\030\005 \001(\0132\027.google.protobuf.StructH" - "\000\0220\n\nlist_value\030\006 \001(\0132\032.google.protobuf." - "ListValueH\000B\006\n\004kind\"3\n\tListValue\022&\n\006valu" - "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\370\001\001\242\002\003GPB" - "\252\002\036Google.Protobuf.WellKnownTypesb\006proto" - "3", 641); + descriptor, 641); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/struct.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto); @@ -205,7 +187,7 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto { } static_descriptor_initializer_google_2fprotobuf_2fstruct_2eproto_; const ::google::protobuf::EnumDescriptor* NullValue_descriptor() { protobuf_AssignDescriptorsOnce(); - return NullValue_descriptor_; + return file_level_enum_descriptors[0]; } bool NullValue_IsValid(int value) { switch (value) { @@ -217,15 +199,10 @@ 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 PROTOBUF_INLINE_NOT_IN_HEADERS +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -235,7 +212,9 @@ const int Struct::kFieldsFieldNumber; Struct::Struct() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Struct) } @@ -250,23 +229,26 @@ Struct::Struct(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Struct) } - -void Struct::InitAsDefaultInstance() { -} - Struct::Struct(const Struct& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + const ::google::protobuf::Descriptor*& Struct_FieldsEntry_descriptor = file_level_metadata[0].descriptor; + fields_.SetAssignDescriptorCallback( + protobuf_AssignDescriptorsOnce); + fields_.SetEntryDescriptor( + &Struct_FieldsEntry_descriptor); + fields_.MergeFrom(from.fields_); // @@protoc_insertion_point(copy_constructor:google.protobuf.Struct) } void Struct::SharedCtor() { + const ::google::protobuf::Descriptor*& Struct_FieldsEntry_descriptor = file_level_metadata[0].descriptor; fields_.SetAssignDescriptorCallback( protobuf_AssignDescriptorsOnce); fields_.SetEntryDescriptor( - &::google::protobuf::Struct_FieldsEntry_descriptor_); + &Struct_FieldsEntry_descriptor); _cached_size_ = 0; } @@ -296,7 +278,7 @@ void Struct::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Struct::descriptor() { protobuf_AssignDescriptorsOnce(); - return Struct_descriptor_; + return file_level_metadata[1].descriptor; } const Struct& Struct::default_instance() { @@ -304,8 +286,6 @@ const Struct& Struct::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Struct> Struct_default_instance_; - Struct* Struct::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Struct>(arena); } @@ -321,15 +301,14 @@ bool Struct::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Struct) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // map<string, .google.protobuf.Value> fields = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(input->IncrementRecursionDepth()); - parse_loop_fields: Struct_FieldsEntry::Parser< ::google::protobuf::internal::MapField< ::std::string, ::google::protobuf::Value, ::google::protobuf::internal::WireFormatLite::TYPE_STRING, @@ -345,9 +324,7 @@ bool Struct::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_loop_fields; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -390,7 +367,7 @@ void Struct::SerializeWithCachedSizes( } }; - if (output->IsSerializationDeterminstic() && + if (output->IsSerializationDeterministic() && this->fields().size() > 1) { ::google::protobuf::scoped_array<SortItem> items( new SortItem[this->fields().size()]); @@ -533,7 +510,7 @@ size_t Struct::ByteSizeLong() const { void Struct::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Struct) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Struct* source = ::google::protobuf::internal::DynamicCastToGenerated<const Struct>( &from); @@ -542,21 +519,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Struct::MergeFrom(const Struct& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Struct) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Struct::UnsafeMergeFrom(const Struct& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); fields_.MergeFrom(from.fields_); } @@ -571,11 +541,10 @@ void Struct::CopyFrom(const Struct& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Struct) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Struct::IsInitialized() const { - return true; } @@ -584,10 +553,13 @@ void Struct::Swap(Struct* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Struct temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Struct* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Struct::UnsafeArenaSwap(Struct* other) { @@ -597,16 +569,12 @@ void Struct::UnsafeArenaSwap(Struct* other) { } void Struct::InternalSwap(Struct* other) { fields_.Swap(&other->fields_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Struct::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Struct_descriptor_; - metadata.reflection = Struct_reflection_; - return metadata; + return file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -630,9 +598,6 @@ Struct::mutable_fields() { return fields_.MutableMap(); } -inline const Struct* Struct::internal_default_instance() { - return &Struct_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -648,7 +613,9 @@ const int Value::kListValueFieldNumber; Value::Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Value) } @@ -662,23 +629,41 @@ Value::Value(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Value) } - -void Value::InitAsDefaultInstance() { - 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::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(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + clear_has_kind(); + switch (from.kind_case()) { + case kNullValue: { + set_null_value(from.null_value()); + break; + } + case kNumberValue: { + set_number_value(from.number_value()); + break; + } + case kStringValue: { + set_string_value(from.string_value()); + break; + } + case kBoolValue: { + set_bool_value(from.bool_value()); + break; + } + case kStructValue: { + mutable_struct_value()->::google::protobuf::Struct::MergeFrom(from.struct_value()); + break; + } + case kListValue: { + mutable_list_value()->::google::protobuf::ListValue::MergeFrom(from.list_value()); + break; + } + case KIND_NOT_SET: { + break; + } + } // @@protoc_insertion_point(copy_constructor:google.protobuf.Value) } @@ -716,7 +701,7 @@ void Value::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Value::descriptor() { protobuf_AssignDescriptorsOnce(); - return Value_descriptor_; + return file_level_metadata[2].descriptor; } const Value& Value::default_instance() { @@ -724,8 +709,6 @@ const Value& Value::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Value> Value_default_instance_; - Value* Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Value>(arena); } @@ -781,13 +764,13 @@ bool Value::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Value) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional .google.protobuf.NullValue null_value = 1; + // .google.protobuf.NullValue null_value = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -796,13 +779,12 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - goto after_list_value; break; } - // optional double number_value = 2; + // double number_value = 2; case 2: { - if (tag == 17) { + if (tag == 17u) { clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -811,13 +793,12 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - goto after_list_value; break; } - // optional string string_value = 3; + // string string_value = 3; case 3: { - if (tag == 26) { + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_string_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -827,13 +808,12 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - goto after_list_value; break; } - // optional bool bool_value = 4; + // bool bool_value = 4; case 4: { - if (tag == 32) { + if (tag == 32u) { clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -842,33 +822,28 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - goto after_list_value; break; } - // optional .google.protobuf.Struct struct_value = 5; + // .google.protobuf.Struct struct_value = 5; case 5: { - if (tag == 42) { + if (tag == 42u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_struct_value())); } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_list_value; break; } - // optional .google.protobuf.ListValue list_value = 6; + // .google.protobuf.ListValue list_value = 6; case 6: { - if (tag == 50) { - parse_list_value: + if (tag == 50u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_list_value())); } else { goto handle_unusual; } - after_list_value: - if (input->ExpectAtEnd()) goto success; break; } @@ -896,18 +871,18 @@ failure: void Value::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Value) - // optional .google.protobuf.NullValue null_value = 1; + // .google.protobuf.NullValue null_value = 1; if (has_null_value()) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 1, this->null_value(), output); } - // optional double number_value = 2; + // double number_value = 2; if (has_number_value()) { ::google::protobuf::internal::WireFormatLite::WriteDouble(2, this->number_value(), output); } - // optional string string_value = 3; + // string string_value = 3; if (has_string_value()) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->string_value().data(), this->string_value().length(), @@ -917,18 +892,18 @@ void Value::SerializeWithCachedSizes( 3, this->string_value(), output); } - // optional bool bool_value = 4; + // bool bool_value = 4; if (has_bool_value()) { ::google::protobuf::internal::WireFormatLite::WriteBool(4, this->bool_value(), output); } - // optional .google.protobuf.Struct struct_value = 5; + // .google.protobuf.Struct struct_value = 5; if (has_struct_value()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 5, *kind_.struct_value_, output); } - // optional .google.protobuf.ListValue list_value = 6; + // .google.protobuf.ListValue list_value = 6; if (has_list_value()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 6, *kind_.list_value_, output); @@ -941,18 +916,18 @@ void Value::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Value) - // optional .google.protobuf.NullValue null_value = 1; + // .google.protobuf.NullValue null_value = 1; if (has_null_value()) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 1, this->null_value(), target); } - // optional double number_value = 2; + // double number_value = 2; if (has_number_value()) { target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(2, this->number_value(), target); } - // optional string string_value = 3; + // string string_value = 3; if (has_string_value()) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->string_value().data(), this->string_value().length(), @@ -963,19 +938,19 @@ void Value::SerializeWithCachedSizes( 3, this->string_value(), target); } - // optional bool bool_value = 4; + // bool bool_value = 4; if (has_bool_value()) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->bool_value(), target); } - // optional .google.protobuf.Struct struct_value = 5; + // .google.protobuf.Struct struct_value = 5; if (has_struct_value()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( 5, *kind_.struct_value_, false, target); } - // optional .google.protobuf.ListValue list_value = 6; + // .google.protobuf.ListValue list_value = 6; if (has_list_value()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( @@ -991,37 +966,37 @@ size_t Value::ByteSizeLong() const { size_t total_size = 0; switch (kind_case()) { - // optional .google.protobuf.NullValue null_value = 1; + // .google.protobuf.NullValue null_value = 1; case kNullValue: { total_size += 1 + ::google::protobuf::internal::WireFormatLite::EnumSize(this->null_value()); break; } - // optional double number_value = 2; + // double number_value = 2; case kNumberValue: { total_size += 1 + 8; break; } - // optional string string_value = 3; + // string string_value = 3; case kStringValue: { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->string_value()); break; } - // optional bool bool_value = 4; + // bool bool_value = 4; case kBoolValue: { total_size += 1 + 1; break; } - // optional .google.protobuf.Struct struct_value = 5; + // .google.protobuf.Struct struct_value = 5; case kStructValue: { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( *kind_.struct_value_); break; } - // optional .google.protobuf.ListValue list_value = 6; + // .google.protobuf.ListValue list_value = 6; case kListValue: { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( @@ -1041,7 +1016,7 @@ size_t Value::ByteSizeLong() const { void Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const Value>( &from); @@ -1050,21 +1025,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Value::MergeFrom(const Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Value) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Value::UnsafeMergeFrom(const Value& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); switch (from.kind_case()) { case kNullValue: { set_null_value(from.null_value()); @@ -1107,11 +1075,10 @@ void Value::CopyFrom(const Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Value) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Value::IsInitialized() const { - return true; } @@ -1120,10 +1087,13 @@ void Value::Swap(Value* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Value temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Value* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Value::UnsafeArenaSwap(Value* other) { @@ -1134,22 +1104,18 @@ void Value::UnsafeArenaSwap(Value* other) { void Value::InternalSwap(Value* other) { std::swap(kind_, other->kind_); std::swap(_oneof_case_[0], other->_oneof_case_[0]); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Value::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Value_descriptor_; - metadata.reflection = Value_reflection_; - return metadata; + return file_level_metadata[2]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Value -// optional .google.protobuf.NullValue null_value = 1; +// .google.protobuf.NullValue null_value = 1; bool Value::has_null_value() const { return kind_case() == kNullValue; } @@ -1178,7 +1144,7 @@ void Value::set_null_value(::google::protobuf::NullValue value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.null_value) } -// optional double number_value = 2; +// double number_value = 2; bool Value::has_number_value() const { return kind_case() == kNumberValue; } @@ -1207,7 +1173,7 @@ void Value::set_number_value(double value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.number_value) } -// optional string string_value = 3; +// string string_value = 3; bool Value::has_string_value() const { return kind_case() == kStringValue; } @@ -1224,7 +1190,7 @@ void Value::clear_string_value() { 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_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return kind_.string_value_.Get(); } return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); } @@ -1316,7 +1282,7 @@ void Value::unsafe_arena_set_allocated_string_value(::std::string* string_value) // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.string_value) } -// optional bool bool_value = 4; +// bool bool_value = 4; bool Value::has_bool_value() const { return kind_case() == kBoolValue; } @@ -1345,7 +1311,7 @@ void Value::set_bool_value(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value) } -// optional .google.protobuf.Struct struct_value = 5; +// .google.protobuf.Struct struct_value = 5; bool Value::has_struct_value() const { return kind_case() == kStructValue; } @@ -1433,7 +1399,7 @@ void Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value) // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value) } -// optional .google.protobuf.ListValue list_value = 6; +// .google.protobuf.ListValue list_value = 6; bool Value::has_list_value() const { return kind_case() == kListValue; } @@ -1530,9 +1496,6 @@ void Value::clear_has_kind() { Value::KindCase Value::kind_case() const { return Value::KindCase(_oneof_case_[0]); } -inline const Value* Value::internal_default_instance() { - return &Value_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1543,7 +1506,9 @@ const int ListValue::kValuesFieldNumber; ListValue::ListValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ListValue) } @@ -1558,15 +1523,12 @@ ListValue::ListValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.ListValue) } - -void ListValue::InitAsDefaultInstance() { -} - ListValue::ListValue(const ListValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + values_(from.values_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.ListValue) } @@ -1600,7 +1562,7 @@ void ListValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* ListValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return ListValue_descriptor_; + return file_level_metadata[3].descriptor; } const ListValue& ListValue::default_instance() { @@ -1608,8 +1570,6 @@ const ListValue& ListValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<ListValue> ListValue_default_instance_; - ListValue* ListValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<ListValue>(arena); } @@ -1625,23 +1585,20 @@ bool ListValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.ListValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.Value values = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(input->IncrementRecursionDepth()); - parse_loop_values: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_values())); } else { goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_loop_values; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -1717,7 +1674,7 @@ size_t ListValue::ByteSizeLong() const { void ListValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ListValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const ListValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const ListValue>( &from); @@ -1726,21 +1683,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void ListValue::MergeFrom(const ListValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ListValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void ListValue::UnsafeMergeFrom(const ListValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); values_.MergeFrom(from.values_); } @@ -1755,11 +1705,10 @@ void ListValue::CopyFrom(const ListValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ListValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool ListValue::IsInitialized() const { - return true; } @@ -1768,10 +1717,13 @@ void ListValue::Swap(ListValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - ListValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + ListValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void ListValue::UnsafeArenaSwap(ListValue* other) { @@ -1781,16 +1733,12 @@ void ListValue::UnsafeArenaSwap(ListValue* other) { } void ListValue::InternalSwap(ListValue* other) { values_.UnsafeArenaSwap(&other->values_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata ListValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = ListValue_descriptor_; - metadata.reflection = ListValue_reflection_; - return metadata; + return file_level_metadata[3]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -1826,9 +1774,6 @@ ListValue::values() const { return values_; } -inline const ListValue* ListValue::internal_default_instance() { - return &ListValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index ff77bb45..4d89c11c 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -24,13 +24,26 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/map.h> #include <google/protobuf/map_field_inl.h> #include <google/protobuf/generated_enum_reflection.h> #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class ListValue; +class ListValueDefaultTypeInternal; +extern ListValueDefaultTypeInternal _ListValue_default_instance_; +class Struct; +class StructDefaultTypeInternal; +extern StructDefaultTypeInternal _Struct_default_instance_; +class Value; +class ValueDefaultTypeInternal; +extern ValueDefaultTypeInternal _Value_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -38,12 +51,6 @@ 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(); - -class ListValue; -class Struct; -class Value; enum NullValue { NULL_VALUE = 0, @@ -67,6 +74,9 @@ inline bool NullValue_Parse( } // =================================================================== + +// ------------------------------------------------------------------- + class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Struct) */ { public: Struct(); @@ -79,47 +89,52 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Struct& default_instance(); - static const Struct* internal_default_instance(); + static inline const Struct* internal_default_instance() { + return reinterpret_cast<const Struct*>( + &_Struct_default_instance_); + } void UnsafeArenaSwap(Struct* other); void Swap(Struct* other); // implements Message ---------------------------------------------- - inline Struct* New() const { return New(NULL); } + inline Struct* New() const PROTOBUF_FINAL { return New(NULL); } - Struct* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Struct* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Struct& from); void MergeFrom(const Struct& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Struct* other); - void UnsafeMergeFrom(const Struct& from); protected: explicit Struct(::google::protobuf::Arena* arena); private: @@ -134,7 +149,7 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -171,13 +186,10 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Struct> Struct_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ { @@ -192,8 +204,10 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); @@ -209,40 +223,43 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ KIND_NOT_SET = 0, }; - static const Value* internal_default_instance(); + static inline const Value* internal_default_instance() { + return reinterpret_cast<const Value*>( + &_Value_default_instance_); + } void UnsafeArenaSwap(Value* other); void Swap(Value* other); // implements Message ---------------------------------------------- - inline Value* New() const { return New(NULL); } + inline Value* New() const PROTOBUF_FINAL { return New(NULL); } - Value* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Value& from); void MergeFrom(const Value& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Value* other); - void UnsafeMergeFrom(const Value& from); protected: explicit Value(::google::protobuf::Arena* arena); private: @@ -257,13 +274,13 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional .google.protobuf.NullValue null_value = 1; + // .google.protobuf.NullValue null_value = 1; private: bool has_null_value() const; public: @@ -272,7 +289,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ ::google::protobuf::NullValue null_value() const; void set_null_value(::google::protobuf::NullValue value); - // optional double number_value = 2; + // double number_value = 2; private: bool has_number_value() const; public: @@ -281,7 +298,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ double number_value() const; void set_number_value(double value); - // optional string string_value = 3; + // string string_value = 3; private: bool has_string_value() const; public: @@ -298,7 +315,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ void unsafe_arena_set_allocated_string_value( ::std::string* string_value); - // optional bool bool_value = 4; + // bool bool_value = 4; private: bool has_bool_value() const; public: @@ -307,7 +324,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ bool bool_value() const; void set_bool_value(bool value); - // optional .google.protobuf.Struct struct_value = 5; + // .google.protobuf.Struct struct_value = 5; bool has_struct_value() const; void clear_struct_value(); static const int kStructValueFieldNumber = 5; @@ -325,7 +342,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ void unsafe_arena_set_allocated_struct_value( ::google::protobuf::Struct* struct_value); - // optional .google.protobuf.ListValue list_value = 6; + // .google.protobuf.ListValue list_value = 6; bool has_list_value() const; void clear_list_value(); static const int kListValueFieldNumber = 6; @@ -346,12 +363,12 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ KindCase kind_case() const; // @@protoc_insertion_point(class_scope:google.protobuf.Value) private: - inline void set_has_null_value(); - inline void set_has_number_value(); - inline void set_has_string_value(); - inline void set_has_bool_value(); - inline void set_has_struct_value(); - inline void set_has_list_value(); + void set_has_null_value(); + void set_has_number_value(); + void set_has_string_value(); + void set_has_bool_value(); + void set_has_struct_value(); + void set_has_list_value(); inline bool has_kind() const; void clear_kind(); @@ -375,13 +392,10 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Value> Value_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ { @@ -396,47 +410,52 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const ListValue& default_instance(); - static const ListValue* internal_default_instance(); + static inline const ListValue* internal_default_instance() { + return reinterpret_cast<const ListValue*>( + &_ListValue_default_instance_); + } void UnsafeArenaSwap(ListValue* other); void Swap(ListValue* other); // implements Message ---------------------------------------------- - inline ListValue* New() const { return New(NULL); } + inline ListValue* New() const PROTOBUF_FINAL { return New(NULL); } - ListValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + ListValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const ListValue& from); void MergeFrom(const ListValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(ListValue* other); - void UnsafeMergeFrom(const ListValue& from); protected: explicit ListValue(::google::protobuf::Arena* arena); private: @@ -451,7 +470,7 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -480,19 +499,18 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<ListValue> ListValue_default_instance_; - // =================================================================== // =================================================================== #if !PROTOBUF_INLINE_NOT_IN_HEADERS +// ------------------------------------------------------------------- + // Struct // map<string, .google.protobuf.Value> fields = 1; @@ -513,14 +531,11 @@ Struct::mutable_fields() { return fields_.MutableMap(); } -inline const Struct* Struct::internal_default_instance() { - return &Struct_default_instance_.get(); -} // ------------------------------------------------------------------- // Value -// optional .google.protobuf.NullValue null_value = 1; +// .google.protobuf.NullValue null_value = 1; inline bool Value::has_null_value() const { return kind_case() == kNullValue; } @@ -549,7 +564,7 @@ inline void Value::set_null_value(::google::protobuf::NullValue value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.null_value) } -// optional double number_value = 2; +// double number_value = 2; inline bool Value::has_number_value() const { return kind_case() == kNumberValue; } @@ -578,7 +593,7 @@ inline void Value::set_number_value(double value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.number_value) } -// optional string string_value = 3; +// string string_value = 3; inline bool Value::has_string_value() const { return kind_case() == kStringValue; } @@ -595,7 +610,7 @@ inline void Value::clear_string_value() { 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_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return kind_.string_value_.Get(); } return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); } @@ -687,7 +702,7 @@ inline void Value::unsafe_arena_set_allocated_string_value(::std::string* string // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.string_value) } -// optional bool bool_value = 4; +// bool bool_value = 4; inline bool Value::has_bool_value() const { return kind_case() == kBoolValue; } @@ -716,7 +731,7 @@ inline void Value::set_bool_value(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value) } -// optional .google.protobuf.Struct struct_value = 5; +// .google.protobuf.Struct struct_value = 5; inline bool Value::has_struct_value() const { return kind_case() == kStructValue; } @@ -804,7 +819,7 @@ inline void Value::unsafe_arena_set_allocated_struct_value(::google::protobuf:: // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value) } -// optional .google.protobuf.ListValue list_value = 6; +// .google.protobuf.ListValue list_value = 6; inline bool Value::has_list_value() const { return kind_case() == kListValue; } @@ -901,9 +916,6 @@ inline void Value::clear_has_kind() { inline Value::KindCase Value::kind_case() const { return Value::KindCase(_oneof_case_[0]); } -inline const Value* Value::internal_default_instance() { - return &Value_default_instance_.get(); -} // ------------------------------------------------------------------- // ListValue @@ -938,17 +950,17 @@ ListValue::values() const { return values_; } -inline const ListValue* ListValue::internal_default_instance() { - return &ListValue_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- // ------------------------------------------------------------------- +// ------------------------------------------------------------------- + // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/mathlimits.h b/src/google/protobuf/stubs/mathlimits.h index 70e47bff..275d9539 100644 --- a/src/google/protobuf/stubs/mathlimits.h +++ b/src/google/protobuf/stubs/mathlimits.h @@ -43,12 +43,18 @@ #ifndef UTIL_MATH_MATHLIMITS_H__ #define UTIL_MATH_MATHLIMITS_H__ -// <math.h> lacks a lot of prototypes. However, this file needs <math.h> to -// access old-fashioned isinf et al. Even worse more: this file must not -// include <cmath> because that breaks the definition of isinf with gcc 4.9. -// -// TODO(mec): after C++11 everywhere, use <cmath> and std::isinf in this file. +// GCC 4.9 has a bug that makes it impossible to use isinf and isnan when both +// <math.h> and <cmath> get pulled into the same translation unit. +// Unfortunately it is difficult to prevent this from happening, so to work +// around the problem we use std::isinf and std::isnan from <cmath> for C++11 +// builds and otherwise use the plain isinf and isnan functions from <math.h>. +// Note that for Windows we do something different because it does not support +// the plain isinf and isnan. +#if __cplusplus >= 201103L +#include <cmath> +#else #include <math.h> +#endif #include <string.h> #include <cfloat> @@ -220,6 +226,17 @@ DECL_UNSIGNED_INT_LIMITS(unsigned long long int) #undef UNSIGNED_MAX_10_EXP #undef DECL_INT_LIMIT_FUNCS +// For non-Windows builds we use the std:: versions of isinf and isnan if they +// are available; see the comment about <cmath> at the top of this file for the +// details on why we need to do this. +#if __cplusplus >= 201103L +#define ISINF std::isinf +#define ISNAN std::isnan +#else +#define ISINF isinf +#define ISNAN isnan +#endif + // ========================================================================= // #ifdef WIN32 // Lacks built-in isnan() and isinf() #define DECL_FP_LIMIT_FUNCS \ @@ -230,11 +247,11 @@ DECL_UNSIGNED_INT_LIMITS(unsigned long long int) static bool IsNegInf(const Type x) { return _fpclass(x) == _FPCLASS_NINF; } #else #define DECL_FP_LIMIT_FUNCS \ - static bool IsFinite(const Type x) { return !isinf(x) && !isnan(x); } \ - static bool IsNaN(const Type x) { return isnan(x); } \ - static bool IsInf(const Type x) { return isinf(x); } \ - static bool IsPosInf(const Type x) { return isinf(x) && x > 0; } \ - static bool IsNegInf(const Type x) { return isinf(x) && x < 0; } + static bool IsFinite(const Type x) { return !ISINF(x) && !ISNAN(x); } \ + static bool IsNaN(const Type x) { return ISNAN(x); } \ + static bool IsInf(const Type x) { return ISINF(x); } \ + static bool IsPosInf(const Type x) { return ISINF(x) && x > 0; } \ + static bool IsNegInf(const Type x) { return ISINF(x) && x < 0; } #endif // We can't put floating-point constant values in the header here because @@ -269,6 +286,8 @@ DECL_FP_LIMITS(float, FLT) DECL_FP_LIMITS(double, DBL) DECL_FP_LIMITS(long double, LDBL) +#undef ISINF +#undef ISNAN #undef DECL_FP_LIMITS #undef DECL_FP_LIMIT_FUNCS diff --git a/src/google/protobuf/stubs/mathutil.h b/src/google/protobuf/stubs/mathutil.h index 27956a8e..8a9f69a0 100644 --- a/src/google/protobuf/stubs/mathutil.h +++ b/src/google/protobuf/stubs/mathutil.h @@ -41,27 +41,6 @@ namespace google { namespace protobuf { namespace internal { template<typename T> -bool IsNan(T value) { - return false; -} -template<> -inline bool IsNan(float value) { -#ifdef _MSC_VER - return _isnan(value); -#else - return isnan(value); -#endif -} -template<> -inline bool IsNan(double value) { -#ifdef _MSC_VER - return _isnan(value); -#else - return isnan(value); -#endif -} - -template<typename T> bool AlmostEquals(T a, T b) { return a == b; } @@ -80,7 +59,7 @@ class MathUtil { public: template<typename T> static T Sign(T value) { - if (value == T(0) || ::google::protobuf::internal::IsNan<T>(value)) { + if (value == T(0) || MathLimits<T>::IsNaN(value)) { return value; } return value > T(0) ? 1 : -1; diff --git a/src/google/protobuf/test_util.cc b/src/google/protobuf/test_util.cc index 658c8ee2..4e02a85d 100644 --- a/src/google/protobuf/test_util.cc +++ b/src/google/protobuf/test_util.cc @@ -3230,7 +3230,7 @@ void TestUtil::ReflectionTester::RemoveLastRepeatedsViaReflection( Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> output; + std::vector<const FieldDescriptor*> output; reflection->ListFields(*message, &output); for (int i=0; i<output.size(); ++i) { const FieldDescriptor* field = output[i]; @@ -3244,7 +3244,7 @@ void TestUtil::ReflectionTester::ReleaseLastRepeatedsViaReflection( Message* message, bool expect_extensions_notnull) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> output; + std::vector<const FieldDescriptor*> output; reflection->ListFields(*message, &output); for (int i=0; i<output.size(); ++i) { const FieldDescriptor* field = output[i]; @@ -3263,7 +3263,7 @@ void TestUtil::ReflectionTester::ReleaseLastRepeatedsViaReflection( void TestUtil::ReflectionTester::SwapRepeatedsViaReflection(Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> output; + std::vector<const FieldDescriptor*> output; reflection->ListFields(*message, &output); for (int i=0; i<output.size(); ++i) { const FieldDescriptor* field = output[i]; @@ -3278,7 +3278,7 @@ SetAllocatedOptionalMessageFieldsToNullViaReflection( Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(*message, &fields); for (int i = 0; i < fields.size(); ++i) { @@ -3298,7 +3298,7 @@ SetAllocatedOptionalMessageFieldsToMessageViaReflection( const Reflection* from_reflection = from_message->GetReflection(); const Reflection* to_reflection = to_message->GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; from_reflection->ListFields(*from_message, &fields); for (int i = 0; i < fields.size(); ++i) { diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index 5192eca9..e3d908ec 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc @@ -154,7 +154,7 @@ TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::CreateNested( const FieldDescriptor* field) { // Owned by us in the map. TextFormat::ParseInfoTree* instance = new TextFormat::ParseInfoTree(); - vector<TextFormat::ParseInfoTree*>* trees = &nested_[field]; + std::vector<TextFormat::ParseInfoTree*>* trees = &nested_[field]; GOOGLE_CHECK(trees); trees->push_back(instance); return instance; @@ -177,7 +177,7 @@ TextFormat::ParseLocation TextFormat::ParseInfoTree::GetLocation( CheckFieldIndex(field, index); if (index == -1) { index = 0; } - const vector<TextFormat::ParseLocation>* locations = + const std::vector<TextFormat::ParseLocation>* locations = FindOrNull(locations_, field); if (locations == NULL || index >= locations->size()) { return TextFormat::ParseLocation(); @@ -191,7 +191,8 @@ TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::GetTreeForNested( CheckFieldIndex(field, index); if (index == -1) { index = 0; } - const vector<TextFormat::ParseInfoTree*>* trees = FindOrNull(nested_, field); + const std::vector<TextFormat::ParseInfoTree*>* trees = + FindOrNull(nested_, field); if (trees == NULL || index >= trees->size()) { return NULL; } @@ -518,7 +519,14 @@ class TextFormat::Parser::ParserImpl { // Perform special handling for embedded message types. if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { // ':' is optional here. - TryConsume(":"); + bool consumed_semicolon = TryConsume(":"); + if (consumed_semicolon && field->options().weak() && LookingAtType(io::Tokenizer::TYPE_STRING)) { + // we are getting a bytes string for a weak field. + string tmp; + DO(ConsumeString(&tmp)); + reflection->MutableMessage(message, field)->ParseFromString(tmp); + goto label_skip_parsing; + } } else { // ':' is required here. DO(Consume(":")); @@ -546,7 +554,7 @@ class TextFormat::Parser::ParserImpl { } else { DO(ConsumeFieldValue(message, reflection, field)); } - +label_skip_parsing: // For historical reasons, fields may optionally be separated by commas or // semicolons. TryConsume(";") || TryConsume(","); @@ -1336,7 +1344,7 @@ bool TextFormat::Parser::MergeUsingImpl(io::ZeroCopyInputStream* /* input */, ParserImpl* parser_impl) { if (!parser_impl->Parse(output)) return false; if (!allow_partial_ && !output->IsInitialized()) { - vector<string> missing_fields; + std::vector<string> missing_fields; output->FindInitializationErrors(&missing_fields); parser_impl->ReportError(-1, 0, "Message missing required fields: " + Join(missing_fields, ", ")); @@ -1610,7 +1618,7 @@ void TextFormat::Printer::Print(const Message& message, PrintAny(message, generator)) { return; } - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message, &fields); if (print_message_fields_in_index_order_) { std::sort(fields.begin(), fields.end(), FieldIndexSorter()); diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc index 2f1bd455..e6441339 100644 --- a/src/google/protobuf/text_format_unittest.cc +++ b/src/google/protobuf/text_format_unittest.cc @@ -993,10 +993,14 @@ TEST_F(TextFormatTest, ParseExotic) { EXPECT_EQ(1.235E22 , message.repeated_double(4)); EXPECT_EQ(1.235E-18 , message.repeated_double(5)); EXPECT_EQ(123.456789, message.repeated_double(6)); - EXPECT_EQ(message.repeated_double(7), numeric_limits<double>::infinity()); - EXPECT_EQ(message.repeated_double(8), numeric_limits<double>::infinity()); - EXPECT_EQ(message.repeated_double(9), -numeric_limits<double>::infinity()); - EXPECT_EQ(message.repeated_double(10), -numeric_limits<double>::infinity()); + EXPECT_EQ(message.repeated_double(7), + std::numeric_limits<double>::infinity()); + EXPECT_EQ(message.repeated_double(8), + std::numeric_limits<double>::infinity()); + EXPECT_EQ(message.repeated_double(9), + -std::numeric_limits<double>::infinity()); + EXPECT_EQ(message.repeated_double(10), + -std::numeric_limits<double>::infinity()); EXPECT_TRUE(MathLimits<double>::IsNaN(message.repeated_double(11))); EXPECT_TRUE(MathLimits<double>::IsNaN(message.repeated_double(12))); @@ -1500,7 +1504,7 @@ TEST_F(TextFormatParserTest, ExplicitDelimiters) { } TEST_F(TextFormatParserTest, PrintErrorsToStderr) { - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; @@ -1517,7 +1521,7 @@ TEST_F(TextFormatParserTest, PrintErrorsToStderr) { } TEST_F(TextFormatParserTest, FailsOnTokenizationError) { - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; @@ -1576,7 +1580,7 @@ TEST_F(TextFormatMessageSetTest, Deserialize) { protobuf_unittest::TestMessageSetExtension2::message_set_extension).str()); // Ensure that these are the only entries present. - vector<const FieldDescriptor*> descriptors; + std::vector<const FieldDescriptor*> descriptors; proto.message_set().GetReflection()->ListFields( proto.message_set(), &descriptors); EXPECT_EQ(2, descriptors.size()); diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index b4258ae4..482c0e39 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -19,85 +19,88 @@ namespace google { namespace protobuf { +class TimestampDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> {}; +TimestampDefaultTypeInternal _Timestamp_default_instance_; namespace { -const ::google::protobuf::Descriptor* Timestamp_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Timestamp_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/timestamp.proto"); - GOOGLE_CHECK(file != NULL); - Timestamp_descriptor_ = file->message_type(0); - static const int Timestamp_offsets_[2] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftimestamp_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftimestamp_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, seconds_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, nanos_), }; - Timestamp_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Timestamp_descriptor_, - Timestamp::internal_default_instance(), - Timestamp_offsets_, - -1, - -1, - -1, - sizeof(Timestamp), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Timestamp)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Timestamp_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/timestamp.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2ftimestamp_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Timestamp_descriptor_, Timestamp::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto() { - Timestamp_default_instance_.Shutdown(); - delete Timestamp_reflection_; + _Timestamp_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - Timestamp_default_instance_.DefaultConstruct(); - Timestamp_default_instance_.get_mutable()->InitAsDefaultInstance(); + ::google::protobuf::internal::InitProtobufDefaults(); + _Timestamp_default_instance_.DefaultConstruct(); } -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); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&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(); + static const char descriptor[] = { + "\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~\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" + }; ::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~\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); + descriptor, 231); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/timestamp.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto); @@ -115,16 +118,6 @@ 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 @@ -134,7 +127,9 @@ const int Timestamp::kNanosFieldNumber; Timestamp::Timestamp() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Timestamp) } @@ -148,15 +143,14 @@ Timestamp::Timestamp(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Timestamp) } - -void Timestamp::InitAsDefaultInstance() { -} - Timestamp::Timestamp(const Timestamp& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::memcpy(&seconds_, &from.seconds_, + reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Timestamp) } @@ -192,7 +186,7 @@ void Timestamp::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Timestamp::descriptor() { protobuf_AssignDescriptorsOnce(); - return Timestamp_descriptor_; + return file_level_metadata[0].descriptor; } const Timestamp& Timestamp::default_instance() { @@ -200,35 +194,14 @@ const Timestamp& Timestamp::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Timestamp> Timestamp_default_instance_; - Timestamp* Timestamp::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Timestamp>(arena); } void Timestamp::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Timestamp) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(Timestamp, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<Timestamp*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(seconds_, nanos_); - -#undef ZR_HELPER_ -#undef ZR_ - + ::memset(&seconds_, 0, reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); } bool Timestamp::MergePartialFromCodedStream( @@ -237,13 +210,13 @@ bool Timestamp::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Timestamp) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional int64 seconds = 1; + // int64 seconds = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -251,14 +224,12 @@ bool Timestamp::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_nanos; break; } - // optional int32 nanos = 2; + // int32 nanos = 2; case 2: { - if (tag == 16) { - parse_nanos: + if (tag == 16u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -266,7 +237,6 @@ bool Timestamp::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -294,12 +264,12 @@ failure: void Timestamp::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Timestamp) - // optional int64 seconds = 1; + // int64 seconds = 1; if (this->seconds() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->seconds(), output); } - // optional int32 nanos = 2; + // int32 nanos = 2; if (this->nanos() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->nanos(), output); } @@ -311,12 +281,12 @@ void Timestamp::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Timestamp) - // optional int64 seconds = 1; + // int64 seconds = 1; if (this->seconds() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->seconds(), target); } - // optional int32 nanos = 2; + // int32 nanos = 2; if (this->nanos() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->nanos(), target); } @@ -329,14 +299,14 @@ size_t Timestamp::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Timestamp) size_t total_size = 0; - // optional int64 seconds = 1; + // int64 seconds = 1; if (this->seconds() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int64Size( this->seconds()); } - // optional int32 nanos = 2; + // int32 nanos = 2; if (this->nanos() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( @@ -352,7 +322,7 @@ size_t Timestamp::ByteSizeLong() const { void Timestamp::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Timestamp) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Timestamp* source = ::google::protobuf::internal::DynamicCastToGenerated<const Timestamp>( &from); @@ -361,21 +331,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Timestamp::MergeFrom(const Timestamp& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Timestamp) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Timestamp::UnsafeMergeFrom(const Timestamp& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.seconds() != 0) { set_seconds(from.seconds()); } @@ -395,11 +358,10 @@ void Timestamp::CopyFrom(const Timestamp& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Timestamp) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Timestamp::IsInitialized() const { - return true; } @@ -408,10 +370,13 @@ void Timestamp::Swap(Timestamp* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Timestamp temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Timestamp* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Timestamp::UnsafeArenaSwap(Timestamp* other) { @@ -422,22 +387,18 @@ void Timestamp::UnsafeArenaSwap(Timestamp* other) { void Timestamp::InternalSwap(Timestamp* other) { std::swap(seconds_, other->seconds_); std::swap(nanos_, other->nanos_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Timestamp::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Timestamp_descriptor_; - metadata.reflection = Timestamp_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Timestamp -// optional int64 seconds = 1; +// int64 seconds = 1; void Timestamp::clear_seconds() { seconds_ = GOOGLE_LONGLONG(0); } @@ -451,7 +412,7 @@ void Timestamp::set_seconds(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.seconds) } -// optional int32 nanos = 2; +// int32 nanos = 2; void Timestamp::clear_nanos() { nanos_ = 0; } @@ -465,9 +426,6 @@ void Timestamp::set_nanos(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.nanos) } -inline const Timestamp* Timestamp::internal_default_instance() { - return &Timestamp_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 1abe8d0c..38ddb635 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -24,10 +24,17 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class Timestamp; +class TimestampDefaultTypeInternal; +extern TimestampDefaultTypeInternal _Timestamp_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -35,10 +42,6 @@ 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(); - -class Timestamp; // =================================================================== @@ -54,47 +57,52 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Timestamp& default_instance(); - static const Timestamp* internal_default_instance(); + static inline const Timestamp* internal_default_instance() { + return reinterpret_cast<const Timestamp*>( + &_Timestamp_default_instance_); + } void UnsafeArenaSwap(Timestamp* other); void Swap(Timestamp* other); // implements Message ---------------------------------------------- - inline Timestamp* New() const { return New(NULL); } + inline Timestamp* New() const PROTOBUF_FINAL { return New(NULL); } - Timestamp* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Timestamp* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Timestamp& from); void MergeFrom(const Timestamp& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Timestamp* other); - void UnsafeMergeFrom(const Timestamp& from); protected: explicit Timestamp(::google::protobuf::Arena* arena); private: @@ -109,19 +117,19 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional int64 seconds = 1; + // int64 seconds = 1; void clear_seconds(); static const int kSecondsFieldNumber = 1; ::google::protobuf::int64 seconds() const; void set_seconds(::google::protobuf::int64 value); - // optional int32 nanos = 2; + // int32 nanos = 2; void clear_nanos(); static const int kNanosFieldNumber = 2; ::google::protobuf::int32 nanos() const; @@ -139,13 +147,10 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftimestamp_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> Timestamp_default_instance_; - // =================================================================== @@ -154,7 +159,7 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> Timestamp_ #if !PROTOBUF_INLINE_NOT_IN_HEADERS // Timestamp -// optional int64 seconds = 1; +// int64 seconds = 1; inline void Timestamp::clear_seconds() { seconds_ = GOOGLE_LONGLONG(0); } @@ -168,7 +173,7 @@ inline void Timestamp::set_seconds(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.seconds) } -// optional int32 nanos = 2; +// int32 nanos = 2; inline void Timestamp::clear_nanos() { nanos_ = 0; } @@ -182,13 +187,11 @@ inline void Timestamp::set_nanos(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.nanos) } -inline const Timestamp* Timestamp::internal_default_instance() { - return &Timestamp_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index cc80dd92..6e41dde8 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -19,59 +19,42 @@ namespace google { namespace protobuf { +class TypeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Type> {}; +TypeDefaultTypeInternal _Type_default_instance_; +class FieldDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Field> {}; +FieldDefaultTypeInternal _Field_default_instance_; +class EnumDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Enum> {}; +EnumDefaultTypeInternal _Enum_default_instance_; +class EnumValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValue> {}; +EnumValueDefaultTypeInternal _EnumValue_default_instance_; +class OptionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Option> {}; +OptionDefaultTypeInternal _Option_default_instance_; namespace { -const ::google::protobuf::Descriptor* Type_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Type_reflection_ = NULL; -const ::google::protobuf::Descriptor* Field_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Field_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor_ = NULL; -const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor_ = NULL; -const ::google::protobuf::Descriptor* Enum_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Enum_reflection_ = NULL; -const ::google::protobuf::Descriptor* EnumValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumValue_reflection_ = NULL; -const ::google::protobuf::Descriptor* Option_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Option_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* Syntax_descriptor_ = NULL; +::google::protobuf::Metadata file_level_metadata[5]; +const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[3]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/type.proto"); - GOOGLE_CHECK(file != NULL); - Type_descriptor_ = file->message_type(0); - static const int Type_offsets_[6] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, fields_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, oneofs_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, source_context_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, syntax_), - }; - Type_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Type_descriptor_, - Type::internal_default_instance(), - Type_offsets_, - -1, - -1, - -1, - sizeof(Type), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_)); - Field_descriptor_ = file->message_type(1); - static const int Field_offsets_[10] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, kind_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, cardinality_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, number_), @@ -82,107 +65,82 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, json_name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, default_value_), - }; - Field_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Field_descriptor_, - Field::internal_default_instance(), - Field_offsets_, - -1, - -1, - -1, - sizeof(Field), - 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); - static const int Enum_offsets_[5] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, enumvalue_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, source_context_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, syntax_), - }; - Enum_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Enum_descriptor_, - Enum::internal_default_instance(), - Enum_offsets_, - -1, - -1, - -1, - sizeof(Enum), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_)); - EnumValue_descriptor_ = file->message_type(3); - static const int EnumValue_offsets_[3] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, number_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, options_), - }; - EnumValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - EnumValue_descriptor_, - EnumValue::internal_default_instance(), - EnumValue_offsets_, - -1, - -1, - -1, - sizeof(EnumValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_)); - Option_descriptor_ = file->message_type(4); - static const int Option_offsets_[2] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, value_), }; - Option_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Option_descriptor_, - Option::internal_default_instance(), - Option_offsets_, - -1, - -1, - -1, - sizeof(Option), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_)); - Syntax_descriptor_ = file->enum_type(0); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Type)}, + { 10, -1, sizeof(Field)}, + { 24, -1, sizeof(Enum)}, + { 33, -1, sizeof(EnumValue)}, + { 40, -1, sizeof(Option)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Type_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Field_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Enum_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValue_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Option_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/type.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2ftype_2eproto(), factory, + file_level_metadata, file_level_enum_descriptors, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Type_descriptor_, Type::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Field_descriptor_, Field::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Enum_descriptor_, Enum::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValue_descriptor_, EnumValue::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Option_descriptor_, Option::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 5); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto() { - Type_default_instance_.Shutdown(); - delete Type_reflection_; - Field_default_instance_.Shutdown(); - delete Field_reflection_; - Enum_default_instance_.Shutdown(); - delete Enum_reflection_; - EnumValue_default_instance_.Shutdown(); - delete EnumValue_reflection_; - Option_default_instance_.Shutdown(); - delete Option_reflection_; + _Type_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; + _Field_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; + _Enum_default_instance_.Shutdown(); + delete file_level_metadata[2].reflection; + _EnumValue_default_instance_.Shutdown(); + delete file_level_metadata[3].reflection; + _Option_default_instance_.Shutdown(); + delete file_level_metadata[4].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl() { @@ -190,72 +148,70 @@ void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl() { ::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_); + ::google::protobuf::internal::InitProtobufDefaults(); + _Type_default_instance_.DefaultConstruct(); + _Field_default_instance_.DefaultConstruct(); + _Enum_default_instance_.DefaultConstruct(); + _EnumValue_default_instance_.DefaultConstruct(); + _Option_default_instance_.DefaultConstruct(); + _Type_default_instance_.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); + _Enum_default_instance_.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); + _Option_default_instance_.get_mutable()->value_ = const_cast< ::google::protobuf::Any*>( + ::google::protobuf::Any::internal_default_instance()); +} + void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&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(); + static const char descriptor[] = { + "\n\032google/protobuf/type.proto\022\017google.pro" + "tobuf\032\031google/protobuf/any.proto\032$google" + "/protobuf/source_context.proto\"\327\001\n\004Type\022" + "\014\n\004name\030\001 \001(\t\022&\n\006fields\030\002 \003(\0132\026.google.p" + "rotobuf.Field\022\016\n\006oneofs\030\003 \003(\t\022(\n\007options" + "\030\004 \003(\0132\027.google.protobuf.Option\0226\n\016sourc" + "e_context\030\005 \001(\0132\036.google.protobuf.Source" + "Context\022\'\n\006syntax\030\006 \001(\0162\027.google.protobu" + "f.Syntax\"\325\005\n\005Field\022)\n\004kind\030\001 \001(\0162\033.googl" + "e.protobuf.Field.Kind\0227\n\013cardinality\030\002 \001" + "(\0162\".google.protobuf.Field.Cardinality\022\016" + "\n\006number\030\003 \001(\005\022\014\n\004name\030\004 \001(\t\022\020\n\010type_url" + "\030\006 \001(\t\022\023\n\013oneof_index\030\007 \001(\005\022\016\n\006packed\030\010 " + "\001(\010\022(\n\007options\030\t \003(\0132\027.google.protobuf.O" + "ption\022\021\n\tjson_name\030\n \001(\t\022\025\n\rdefault_valu" + "e\030\013 \001(\t\"\310\002\n\004Kind\022\020\n\014TYPE_UNKNOWN\020\000\022\017\n\013TY" + "PE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE_INT6" + "4\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020\005\022\020\n\014" + "TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n\tTYPE" + "_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GROUP\020\n" + "\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022\017\n\013TY" + "PE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_SFIXE" + "D32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SINT32\020" + "\021\022\017\n\013TYPE_SINT64\020\022\"t\n\013Cardinality\022\027\n\023CAR" + "DINALITY_UNKNOWN\020\000\022\030\n\024CARDINALITY_OPTION" + "AL\020\001\022\030\n\024CARDINALITY_REQUIRED\020\002\022\030\n\024CARDIN" + "ALITY_REPEATED\020\003\"\316\001\n\004Enum\022\014\n\004name\030\001 \001(\t\022" + "-\n\tenumvalue\030\002 \003(\0132\032.google.protobuf.Enu" + "mValue\022(\n\007options\030\003 \003(\0132\027.google.protobu" + "f.Option\0226\n\016source_context\030\004 \001(\0132\036.googl" + "e.protobuf.SourceContext\022\'\n\006syntax\030\005 \001(\016" + "2\027.google.protobuf.Syntax\"S\n\tEnumValue\022\014" + "\n\004name\030\001 \001(\t\022\016\n\006number\030\002 \001(\005\022(\n\007options\030" + "\003 \003(\0132\027.google.protobuf.Option\";\n\006Option" + "\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\001B}\n\023com.google.protob" + "ufB\tTypeProtoP\001Z/google.golang.org/genpr" + "oto/protobuf/ptype;ptype\370\001\001\242\002\003GPB\252\002\036Goog" + "le.Protobuf.WellKnownTypesb\006proto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\032google/protobuf/type.proto\022\017google.pro" - "tobuf\032\031google/protobuf/any.proto\032$google" - "/protobuf/source_context.proto\"\327\001\n\004Type\022" - "\014\n\004name\030\001 \001(\t\022&\n\006fields\030\002 \003(\0132\026.google.p" - "rotobuf.Field\022\016\n\006oneofs\030\003 \003(\t\022(\n\007options" - "\030\004 \003(\0132\027.google.protobuf.Option\0226\n\016sourc" - "e_context\030\005 \001(\0132\036.google.protobuf.Source" - "Context\022\'\n\006syntax\030\006 \001(\0162\027.google.protobu" - "f.Syntax\"\325\005\n\005Field\022)\n\004kind\030\001 \001(\0162\033.googl" - "e.protobuf.Field.Kind\0227\n\013cardinality\030\002 \001" - "(\0162\".google.protobuf.Field.Cardinality\022\016" - "\n\006number\030\003 \001(\005\022\014\n\004name\030\004 \001(\t\022\020\n\010type_url" - "\030\006 \001(\t\022\023\n\013oneof_index\030\007 \001(\005\022\016\n\006packed\030\010 " - "\001(\010\022(\n\007options\030\t \003(\0132\027.google.protobuf.O" - "ption\022\021\n\tjson_name\030\n \001(\t\022\025\n\rdefault_valu" - "e\030\013 \001(\t\"\310\002\n\004Kind\022\020\n\014TYPE_UNKNOWN\020\000\022\017\n\013TY" - "PE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE_INT6" - "4\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020\005\022\020\n\014" - "TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n\tTYPE" - "_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GROUP\020\n" - "\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022\017\n\013TY" - "PE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_SFIXE" - "D32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SINT32\020" - "\021\022\017\n\013TYPE_SINT64\020\022\"t\n\013Cardinality\022\027\n\023CAR" - "DINALITY_UNKNOWN\020\000\022\030\n\024CARDINALITY_OPTION" - "AL\020\001\022\030\n\024CARDINALITY_REQUIRED\020\002\022\030\n\024CARDIN" - "ALITY_REPEATED\020\003\"\316\001\n\004Enum\022\014\n\004name\030\001 \001(\t\022" - "-\n\tenumvalue\030\002 \003(\0132\032.google.protobuf.Enu" - "mValue\022(\n\007options\030\003 \003(\0132\027.google.protobu" - "f.Option\0226\n\016source_context\030\004 \001(\0132\036.googl" - "e.protobuf.SourceContext\022\'\n\006syntax\030\005 \001(\016" - "2\027.google.protobuf.Syntax\"S\n\tEnumValue\022\014" - "\n\004name\030\001 \001(\t\022\016\n\006number\030\002 \001(\005\022(\n\007options\030" - "\003 \003(\0132\027.google.protobuf.Option\";\n\006Option" - "\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\370\001\001\242\002\003GPB\252\002\036Google.Protob" - "uf.WellKnownTypesb\006proto3", 1545); + descriptor, 1594); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/type.proto", &protobuf_RegisterTypes); ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); @@ -274,29 +230,99 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto { protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); } } static_descriptor_initializer_google_2fprotobuf_2ftype_2eproto_; -const ::google::protobuf::EnumDescriptor* Syntax_descriptor() { +const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor() { protobuf_AssignDescriptorsOnce(); - return Syntax_descriptor_; + return file_level_enum_descriptors[0]; } -bool Syntax_IsValid(int value) { +bool Field_Kind_IsValid(int value) { switch (value) { case 0: case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: return true; default: return false; } } - -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const Field_Kind Field::TYPE_UNKNOWN; +const Field_Kind Field::TYPE_DOUBLE; +const Field_Kind Field::TYPE_FLOAT; +const Field_Kind Field::TYPE_INT64; +const Field_Kind Field::TYPE_UINT64; +const Field_Kind Field::TYPE_INT32; +const Field_Kind Field::TYPE_FIXED64; +const Field_Kind Field::TYPE_FIXED32; +const Field_Kind Field::TYPE_BOOL; +const Field_Kind Field::TYPE_STRING; +const Field_Kind Field::TYPE_GROUP; +const Field_Kind Field::TYPE_MESSAGE; +const Field_Kind Field::TYPE_BYTES; +const Field_Kind Field::TYPE_UINT32; +const Field_Kind Field::TYPE_ENUM; +const Field_Kind Field::TYPE_SFIXED32; +const Field_Kind Field::TYPE_SFIXED64; +const Field_Kind Field::TYPE_SINT32; +const Field_Kind Field::TYPE_SINT64; +const Field_Kind Field::Kind_MIN; +const Field_Kind Field::Kind_MAX; +const int Field::Kind_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[1]; +} +bool Field_Cardinality_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + case 3: + return true; + default: + return false; + } } -} // namespace +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const Field_Cardinality Field::CARDINALITY_UNKNOWN; +const Field_Cardinality Field::CARDINALITY_OPTIONAL; +const Field_Cardinality Field::CARDINALITY_REQUIRED; +const Field_Cardinality Field::CARDINALITY_REPEATED; +const Field_Cardinality Field::Cardinality_MIN; +const Field_Cardinality Field::Cardinality_MAX; +const int Field::Cardinality_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* Syntax_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[2]; +} +bool Syntax_IsValid(int value) { + switch (value) { + case 0: + case 1: + return true; + default: + return false; + } +} // =================================================================== @@ -345,7 +371,9 @@ const int Type::kSyntaxFieldNumber; Type::Type() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Type) } @@ -362,24 +390,32 @@ Type::Type(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Type) } - -void Type::InitAsDefaultInstance() { - 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(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + fields_(from.fields_), + oneofs_(from.oneofs_), + options_(from.options_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); + } + if (from.has_source_context()) { + source_context_ = new ::google::protobuf::SourceContext(*from.source_context_); + } else { + source_context_ = NULL; + } + syntax_ = from.syntax_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Type) } void Type::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - source_context_ = NULL; - syntax_ = 0; + ::memset(&source_context_, 0, reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&source_context_) + sizeof(syntax_)); _cached_size_ = 0; } @@ -395,7 +431,7 @@ void Type::SharedDtor() { } name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); - if (this != &Type_default_instance_.get()) { + if (this != internal_default_instance()) { delete source_context_; } } @@ -413,7 +449,7 @@ void Type::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Type::descriptor() { protobuf_AssignDescriptorsOnce(); - return Type_descriptor_; + return file_level_metadata[0].descriptor; } const Type& Type::default_instance() { @@ -421,21 +457,21 @@ const Type& Type::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Type> Type_default_instance_; - Type* Type::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Type>(arena); } void Type::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Type) - name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; - source_context_ = NULL; - syntax_ = 0; fields_.Clear(); oneofs_.Clear(); options_.Clear(); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + if (GetArenaNoVirtual() == NULL && source_context_ != NULL) { + delete source_context_; + } + source_context_ = NULL; + syntax_ = 0; } bool Type::MergePartialFromCodedStream( @@ -444,13 +480,13 @@ bool Type::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Type) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -460,31 +496,25 @@ bool Type::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_fields; break; } // repeated .google.protobuf.Field fields = 2; case 2: { - if (tag == 18) { - parse_fields: + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_fields: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_fields())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_fields; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(26)) goto parse_oneofs; break; } // repeated string oneofs = 3; case 3: { - if (tag == 26) { - parse_oneofs: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_oneofs())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -495,45 +525,36 @@ bool Type::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_oneofs; - if (input->ExpectTag(34)) goto parse_options; break; } // repeated .google.protobuf.Option options = 4; case 4: { - if (tag == 34) { - parse_options: + if (tag == 34u) { DO_(input->IncrementRecursionDepth()); - parse_loop_options: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(42)) goto parse_source_context; break; } - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; case 5: { - if (tag == 42) { - parse_source_context: + if (tag == 42u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_source_context())); } else { goto handle_unusual; } - if (input->ExpectTag(48)) goto parse_syntax; break; } - // optional .google.protobuf.Syntax syntax = 6; + // .google.protobuf.Syntax syntax = 6; case 6: { - if (tag == 48) { - parse_syntax: + if (tag == 48u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -542,7 +563,6 @@ bool Type::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -570,7 +590,7 @@ failure: void Type::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Type) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -602,13 +622,13 @@ void Type::SerializeWithCachedSizes( 4, this->options(i), output); } - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 5, *this->source_context_, output); } - // optional .google.protobuf.Syntax syntax = 6; + // .google.protobuf.Syntax syntax = 6; if (this->syntax() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 6, this->syntax(), output); @@ -621,7 +641,7 @@ void Type::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Type) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -656,14 +676,14 @@ void Type::SerializeWithCachedSizes( 4, this->options(i), false, target); } - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( 5, *this->source_context_, false, target); } - // optional .google.protobuf.Syntax syntax = 6; + // .google.protobuf.Syntax syntax = 6; if (this->syntax() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 6, this->syntax(), target); @@ -677,26 +697,6 @@ size_t Type::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Type) size_t total_size = 0; - // optional string name = 1; - if (this->name().size() > 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional .google.protobuf.SourceContext source_context = 5; - if (this->has_source_context()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->source_context_); - } - - // optional .google.protobuf.Syntax syntax = 6; - if (this->syntax() != 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); - } - // repeated .google.protobuf.Field fields = 2; { unsigned int count = this->fields_size(); @@ -727,6 +727,26 @@ size_t Type::ByteSizeLong() const { } } + // string name = 1; + if (this->name().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + // .google.protobuf.SourceContext source_context = 5; + if (this->has_source_context()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->source_context_); + } + + // .google.protobuf.Syntax syntax = 6; + if (this->syntax() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); + } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -736,7 +756,7 @@ size_t Type::ByteSizeLong() const { void Type::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Type) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Type* source = ::google::protobuf::internal::DynamicCastToGenerated<const Type>( &from); @@ -745,23 +765,16 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Type::MergeFrom(const Type& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Type) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Type::UnsafeMergeFrom(const Type& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); fields_.MergeFrom(from.fields_); - oneofs_.UnsafeMergeFrom(from.oneofs_); + oneofs_.MergeFrom(from.oneofs_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { set_name(from.name()); @@ -785,11 +798,10 @@ void Type::CopyFrom(const Type& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Type) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Type::IsInitialized() const { - return true; } @@ -798,10 +810,13 @@ void Type::Swap(Type* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Type temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Type* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Type::UnsafeArenaSwap(Type* other) { @@ -810,34 +825,30 @@ void Type::UnsafeArenaSwap(Type* other) { InternalSwap(other); } void Type::InternalSwap(Type* other) { - name_.Swap(&other->name_); fields_.UnsafeArenaSwap(&other->fields_); oneofs_.UnsafeArenaSwap(&other->oneofs_); options_.UnsafeArenaSwap(&other->options_); + name_.Swap(&other->name_); std::swap(source_context_, other->source_context_); std::swap(syntax_, other->syntax_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Type::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Type_descriptor_; - metadata.reflection = Type_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Type -// optional string name = 1; +// string name = 1; void Type::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Type::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } void Type::set_name(const ::std::string& value) { @@ -1012,7 +1023,7 @@ Type::options() const { return options_; } -// optional .google.protobuf.SourceContext source_context = 5; +// .google.protobuf.SourceContext source_context = 5; bool Type::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } @@ -1063,7 +1074,7 @@ const ::google::protobuf::SourceContext& Type::source_context() const { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context) } -// optional .google.protobuf.Syntax syntax = 6; +// .google.protobuf.Syntax syntax = 6; void Type::clear_syntax() { syntax_ = 0; } @@ -1077,93 +1088,10 @@ void Type::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Type.syntax) } -inline const Type* Type::internal_default_instance() { - return &Type_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor() { - protobuf_AssignDescriptorsOnce(); - return Field_Kind_descriptor_; -} -bool Field_Kind_IsValid(int value) { - switch (value) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const Field_Kind Field::TYPE_UNKNOWN; -const Field_Kind Field::TYPE_DOUBLE; -const Field_Kind Field::TYPE_FLOAT; -const Field_Kind Field::TYPE_INT64; -const Field_Kind Field::TYPE_UINT64; -const Field_Kind Field::TYPE_INT32; -const Field_Kind Field::TYPE_FIXED64; -const Field_Kind Field::TYPE_FIXED32; -const Field_Kind Field::TYPE_BOOL; -const Field_Kind Field::TYPE_STRING; -const Field_Kind Field::TYPE_GROUP; -const Field_Kind Field::TYPE_MESSAGE; -const Field_Kind Field::TYPE_BYTES; -const Field_Kind Field::TYPE_UINT32; -const Field_Kind Field::TYPE_ENUM; -const Field_Kind Field::TYPE_SFIXED32; -const Field_Kind Field::TYPE_SFIXED64; -const Field_Kind Field::TYPE_SINT32; -const Field_Kind Field::TYPE_SINT64; -const Field_Kind Field::Kind_MIN; -const Field_Kind Field::Kind_MAX; -const int Field::Kind_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 -const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor() { - protobuf_AssignDescriptorsOnce(); - return Field_Cardinality_descriptor_; -} -bool Field_Cardinality_IsValid(int value) { - switch (value) { - case 0: - case 1: - case 2: - case 3: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const Field_Cardinality Field::CARDINALITY_UNKNOWN; -const Field_Cardinality Field::CARDINALITY_OPTIONAL; -const Field_Cardinality Field::CARDINALITY_REQUIRED; -const Field_Cardinality Field::CARDINALITY_REPEATED; -const Field_Cardinality Field::Cardinality_MIN; -const Field_Cardinality Field::Cardinality_MAX; -const int Field::Cardinality_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Field::kKindFieldNumber; const int Field::kCardinalityFieldNumber; @@ -1179,7 +1107,9 @@ const int Field::kDefaultValueFieldNumber; Field::Field() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Field) } @@ -1194,15 +1124,35 @@ Field::Field(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Field) } - -void Field::InitAsDefaultInstance() { -} - Field::Field(const Field& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + options_(from.options_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); + } + type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.type_url().size() > 0) { + type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url(), + GetArenaNoVirtual()); + } + json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.json_name().size() > 0) { + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name(), + GetArenaNoVirtual()); + } + default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.default_value().size() > 0) { + default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value(), + GetArenaNoVirtual()); + } + ::memcpy(&kind_, &from.kind_, + reinterpret_cast<char*>(&packed_) - + reinterpret_cast<char*>(&kind_) + sizeof(packed_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Field) } @@ -1246,7 +1196,7 @@ void Field::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Field::descriptor() { protobuf_AssignDescriptorsOnce(); - return Field_descriptor_; + return file_level_metadata[1].descriptor; } const Field& Field::default_instance() { @@ -1254,40 +1204,19 @@ const Field& Field::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Field> Field_default_instance_; - Field* Field::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Field>(arena); } void Field::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Field) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(Field, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<Field*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(kind_, packed_); + options_.Clear(); 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_ - - options_.Clear(); + ::memset(&kind_, 0, reinterpret_cast<char*>(&packed_) - + reinterpret_cast<char*>(&kind_) + sizeof(packed_)); } bool Field::MergePartialFromCodedStream( @@ -1296,13 +1225,13 @@ bool Field::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Field) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional .google.protobuf.Field.Kind kind = 1; + // .google.protobuf.Field.Kind kind = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1311,14 +1240,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_cardinality; break; } - // optional .google.protobuf.Field.Cardinality cardinality = 2; + // .google.protobuf.Field.Cardinality cardinality = 2; case 2: { - if (tag == 16) { - parse_cardinality: + if (tag == 16u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1327,14 +1254,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_number; break; } - // optional int32 number = 3; + // int32 number = 3; case 3: { - if (tag == 24) { - parse_number: + if (tag == 24u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1342,14 +1267,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_name; break; } - // optional string name = 4; + // string name = 4; case 4: { - if (tag == 34) { - parse_name: + if (tag == 34u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1359,14 +1282,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_type_url; break; } - // optional string type_url = 6; + // string type_url = 6; case 6: { - if (tag == 50) { - parse_type_url: + if (tag == 50u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1376,14 +1297,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(56)) goto parse_oneof_index; break; } - // optional int32 oneof_index = 7; + // int32 oneof_index = 7; case 7: { - if (tag == 56) { - parse_oneof_index: + if (tag == 56u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1391,14 +1310,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(64)) goto parse_packed; break; } - // optional bool packed = 8; + // bool packed = 8; case 8: { - if (tag == 64) { - parse_packed: + if (tag == 64u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1406,31 +1323,25 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(74)) goto parse_options; break; } // repeated .google.protobuf.Option options = 9; case 9: { - if (tag == 74) { - parse_options: + if (tag == 74u) { DO_(input->IncrementRecursionDepth()); - parse_loop_options: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); } else { goto handle_unusual; } - if (input->ExpectTag(74)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(82)) goto parse_json_name; break; } - // optional string json_name = 10; + // string json_name = 10; case 10: { - if (tag == 82) { - parse_json_name: + if (tag == 82u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_json_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1440,14 +1351,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(90)) goto parse_default_value; break; } - // optional string default_value = 11; + // string default_value = 11; case 11: { - if (tag == 90) { - parse_default_value: + if (tag == 90u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_default_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1457,7 +1366,6 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1485,24 +1393,24 @@ failure: void Field::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Field) - // optional .google.protobuf.Field.Kind kind = 1; + // .google.protobuf.Field.Kind kind = 1; if (this->kind() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 1, this->kind(), output); } - // optional .google.protobuf.Field.Cardinality cardinality = 2; + // .google.protobuf.Field.Cardinality cardinality = 2; if (this->cardinality() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 2, this->cardinality(), output); } - // optional int32 number = 3; + // int32 number = 3; if (this->number() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->number(), output); } - // optional string name = 4; + // string name = 4; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -1512,7 +1420,7 @@ void Field::SerializeWithCachedSizes( 4, this->name(), output); } - // optional string type_url = 6; + // string type_url = 6; if (this->type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->type_url().data(), this->type_url().length(), @@ -1522,12 +1430,12 @@ void Field::SerializeWithCachedSizes( 6, this->type_url(), output); } - // optional int32 oneof_index = 7; + // int32 oneof_index = 7; if (this->oneof_index() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->oneof_index(), output); } - // optional bool packed = 8; + // bool packed = 8; if (this->packed() != 0) { ::google::protobuf::internal::WireFormatLite::WriteBool(8, this->packed(), output); } @@ -1538,7 +1446,7 @@ void Field::SerializeWithCachedSizes( 9, this->options(i), output); } - // optional string json_name = 10; + // string json_name = 10; if (this->json_name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->json_name().data(), this->json_name().length(), @@ -1548,7 +1456,7 @@ void Field::SerializeWithCachedSizes( 10, this->json_name(), output); } - // optional string default_value = 11; + // string default_value = 11; if (this->default_value().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->default_value().data(), this->default_value().length(), @@ -1565,24 +1473,24 @@ void Field::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Field) - // optional .google.protobuf.Field.Kind kind = 1; + // .google.protobuf.Field.Kind kind = 1; if (this->kind() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 1, this->kind(), target); } - // optional .google.protobuf.Field.Cardinality cardinality = 2; + // .google.protobuf.Field.Cardinality cardinality = 2; if (this->cardinality() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 2, this->cardinality(), target); } - // optional int32 number = 3; + // int32 number = 3; if (this->number() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->number(), target); } - // optional string name = 4; + // string name = 4; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -1593,7 +1501,7 @@ void Field::SerializeWithCachedSizes( 4, this->name(), target); } - // optional string type_url = 6; + // string type_url = 6; if (this->type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->type_url().data(), this->type_url().length(), @@ -1604,12 +1512,12 @@ void Field::SerializeWithCachedSizes( 6, this->type_url(), target); } - // optional int32 oneof_index = 7; + // int32 oneof_index = 7; if (this->oneof_index() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(7, this->oneof_index(), target); } - // optional bool packed = 8; + // bool packed = 8; if (this->packed() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(8, this->packed(), target); } @@ -1621,7 +1529,7 @@ void Field::SerializeWithCachedSizes( 9, this->options(i), false, target); } - // optional string json_name = 10; + // string json_name = 10; if (this->json_name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->json_name().data(), this->json_name().length(), @@ -1632,7 +1540,7 @@ void Field::SerializeWithCachedSizes( 10, this->json_name(), target); } - // optional string default_value = 11; + // string default_value = 11; if (this->default_value().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->default_value().data(), this->default_value().length(), @@ -1651,74 +1559,74 @@ size_t Field::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Field) size_t total_size = 0; - // optional .google.protobuf.Field.Kind kind = 1; - if (this->kind() != 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->kind()); + // repeated .google.protobuf.Option options = 9; + { + 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)); + } } - // optional .google.protobuf.Field.Cardinality cardinality = 2; - if (this->cardinality() != 0) { + // string name = 4; + if (this->name().size() > 0) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->cardinality()); + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); } - // optional int32 number = 3; - if (this->number() != 0) { + // string type_url = 6; + if (this->type_url().size() > 0) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->number()); + ::google::protobuf::internal::WireFormatLite::StringSize( + this->type_url()); } - // optional string name = 4; - if (this->name().size() > 0) { + // string json_name = 10; + if (this->json_name().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); + this->json_name()); } - // optional string type_url = 6; - if (this->type_url().size() > 0) { + // string default_value = 11; + if (this->default_value().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( - this->type_url()); + this->default_value()); } - // optional int32 oneof_index = 7; - if (this->oneof_index() != 0) { + // .google.protobuf.Field.Kind kind = 1; + if (this->kind() != 0) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->oneof_index()); + ::google::protobuf::internal::WireFormatLite::EnumSize(this->kind()); } - // optional bool packed = 8; - if (this->packed() != 0) { - total_size += 1 + 1; + // .google.protobuf.Field.Cardinality cardinality = 2; + if (this->cardinality() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->cardinality()); } - // optional string json_name = 10; - if (this->json_name().size() > 0) { + // int32 number = 3; + if (this->number() != 0) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->json_name()); + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->number()); } - // optional string default_value = 11; - if (this->default_value().size() > 0) { + // int32 oneof_index = 7; + if (this->oneof_index() != 0) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->default_value()); + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->oneof_index()); } - // repeated .google.protobuf.Option options = 9; - { - 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)); - } + // bool packed = 8; + if (this->packed() != 0) { + total_size += 1 + 1; } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); @@ -1730,7 +1638,7 @@ size_t Field::ByteSizeLong() const { void Field::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Field) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Field* source = ::google::protobuf::internal::DynamicCastToGenerated<const Field>( &from); @@ -1739,22 +1647,27 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Field::MergeFrom(const Field& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Field) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Field::UnsafeMergeFrom(const Field& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); options_.MergeFrom(from.options_); + if (from.name().size() > 0) { + set_name(from.name()); + } + if (from.type_url().size() > 0) { + set_type_url(from.type_url()); + } + if (from.json_name().size() > 0) { + set_json_name(from.json_name()); + } + if (from.default_value().size() > 0) { + set_default_value(from.default_value()); + } if (from.kind() != 0) { set_kind(from.kind()); } @@ -1764,24 +1677,12 @@ void Field::UnsafeMergeFrom(const Field& from) { if (from.number() != 0) { set_number(from.number()); } - if (from.name().size() > 0) { - set_name(from.name()); - } - if (from.type_url().size() > 0) { - set_type_url(from.type_url()); - } if (from.oneof_index() != 0) { set_oneof_index(from.oneof_index()); } if (from.packed() != 0) { set_packed(from.packed()); } - if (from.json_name().size() > 0) { - set_json_name(from.json_name()); - } - if (from.default_value().size() > 0) { - set_default_value(from.default_value()); - } } void Field::CopyFrom(const ::google::protobuf::Message& from) { @@ -1795,11 +1696,10 @@ void Field::CopyFrom(const Field& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Field) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Field::IsInitialized() const { - return true; } @@ -1808,10 +1708,13 @@ void Field::Swap(Field* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Field temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Field* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Field::UnsafeArenaSwap(Field* other) { @@ -1820,32 +1723,28 @@ void Field::UnsafeArenaSwap(Field* other) { InternalSwap(other); } void Field::InternalSwap(Field* other) { + options_.UnsafeArenaSwap(&other->options_); + name_.Swap(&other->name_); + type_url_.Swap(&other->type_url_); + json_name_.Swap(&other->json_name_); + default_value_.Swap(&other->default_value_); std::swap(kind_, other->kind_); std::swap(cardinality_, other->cardinality_); std::swap(number_, other->number_); - name_.Swap(&other->name_); - type_url_.Swap(&other->type_url_); std::swap(oneof_index_, other->oneof_index_); std::swap(packed_, other->packed_); - options_.UnsafeArenaSwap(&other->options_); - json_name_.Swap(&other->json_name_); - default_value_.Swap(&other->default_value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Field::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Field_descriptor_; - metadata.reflection = Field_reflection_; - return metadata; + return file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Field -// optional .google.protobuf.Field.Kind kind = 1; +// .google.protobuf.Field.Kind kind = 1; void Field::clear_kind() { kind_ = 0; } @@ -1859,7 +1758,7 @@ void Field::set_kind(::google::protobuf::Field_Kind value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.kind) } -// optional .google.protobuf.Field.Cardinality cardinality = 2; +// .google.protobuf.Field.Cardinality cardinality = 2; void Field::clear_cardinality() { cardinality_ = 0; } @@ -1873,7 +1772,7 @@ void Field::set_cardinality(::google::protobuf::Field_Cardinality value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.cardinality) } -// optional int32 number = 3; +// int32 number = 3; void Field::clear_number() { number_ = 0; } @@ -1887,13 +1786,13 @@ void Field::set_number(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.number) } -// optional string name = 4; +// string name = 4; void Field::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Field::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } void Field::set_name(const ::std::string& value) { @@ -1953,13 +1852,13 @@ void Field::unsafe_arena_set_allocated_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.name) } -// optional string type_url = 6; +// string type_url = 6; void Field::clear_type_url() { type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Field::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url) - return type_url_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.Get(); } void Field::set_type_url(const ::std::string& value) { @@ -2019,7 +1918,7 @@ void Field::unsafe_arena_set_allocated_type_url( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.type_url) } -// optional int32 oneof_index = 7; +// int32 oneof_index = 7; void Field::clear_oneof_index() { oneof_index_ = 0; } @@ -2033,7 +1932,7 @@ void Field::set_oneof_index(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.oneof_index) } -// optional bool packed = 8; +// bool packed = 8; void Field::clear_packed() { packed_ = false; } @@ -2077,13 +1976,13 @@ Field::options() const { return options_; } -// optional string json_name = 10; +// string json_name = 10; void Field::clear_json_name() { json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Field::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name) - return json_name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.Get(); } void Field::set_json_name(const ::std::string& value) { @@ -2143,13 +2042,13 @@ void Field::unsafe_arena_set_allocated_json_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.json_name) } -// optional string default_value = 11; +// string default_value = 11; void Field::clear_default_value() { default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Field::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value) - return default_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.Get(); } void Field::set_default_value(const ::std::string& value) { @@ -2209,9 +2108,6 @@ void Field::unsafe_arena_set_allocated_default_value( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.default_value) } -inline const Field* Field::internal_default_instance() { - return &Field_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -2259,7 +2155,9 @@ const int Enum::kSyntaxFieldNumber; Enum::Enum() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Enum) } @@ -2275,24 +2173,31 @@ Enum::Enum(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Enum) } - -void Enum::InitAsDefaultInstance() { - 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(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + enumvalue_(from.enumvalue_), + options_(from.options_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); + } + if (from.has_source_context()) { + source_context_ = new ::google::protobuf::SourceContext(*from.source_context_); + } else { + source_context_ = NULL; + } + syntax_ = from.syntax_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Enum) } void Enum::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - source_context_ = NULL; - syntax_ = 0; + ::memset(&source_context_, 0, reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&source_context_) + sizeof(syntax_)); _cached_size_ = 0; } @@ -2308,7 +2213,7 @@ void Enum::SharedDtor() { } name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); - if (this != &Enum_default_instance_.get()) { + if (this != internal_default_instance()) { delete source_context_; } } @@ -2326,7 +2231,7 @@ void Enum::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Enum::descriptor() { protobuf_AssignDescriptorsOnce(); - return Enum_descriptor_; + return file_level_metadata[2].descriptor; } const Enum& Enum::default_instance() { @@ -2334,20 +2239,20 @@ const Enum& Enum::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Enum> Enum_default_instance_; - Enum* Enum::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Enum>(arena); } void Enum::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Enum) + enumvalue_.Clear(); + options_.Clear(); name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; + if (GetArenaNoVirtual() == NULL && source_context_ != NULL) { + delete source_context_; + } source_context_ = NULL; syntax_ = 0; - enumvalue_.Clear(); - options_.Clear(); } bool Enum::MergePartialFromCodedStream( @@ -2356,13 +2261,13 @@ bool Enum::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Enum) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -2372,60 +2277,49 @@ bool Enum::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_enumvalue; break; } // repeated .google.protobuf.EnumValue enumvalue = 2; case 2: { - if (tag == 18) { - parse_enumvalue: + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_enumvalue: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_enumvalue())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_enumvalue; - if (input->ExpectTag(26)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.Option options = 3; case 3: { - if (tag == 26) { + if (tag == 26u) { DO_(input->IncrementRecursionDepth()); - parse_loop_options: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(34)) goto parse_source_context; break; } - // optional .google.protobuf.SourceContext source_context = 4; + // .google.protobuf.SourceContext source_context = 4; case 4: { - if (tag == 34) { - parse_source_context: + if (tag == 34u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_source_context())); } else { goto handle_unusual; } - if (input->ExpectTag(40)) goto parse_syntax; break; } - // optional .google.protobuf.Syntax syntax = 5; + // .google.protobuf.Syntax syntax = 5; case 5: { - if (tag == 40) { - parse_syntax: + if (tag == 40u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -2434,7 +2328,6 @@ bool Enum::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2462,7 +2355,7 @@ failure: void Enum::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Enum) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -2484,13 +2377,13 @@ void Enum::SerializeWithCachedSizes( 3, this->options(i), output); } - // optional .google.protobuf.SourceContext source_context = 4; + // .google.protobuf.SourceContext source_context = 4; if (this->has_source_context()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 4, *this->source_context_, output); } - // optional .google.protobuf.Syntax syntax = 5; + // .google.protobuf.Syntax syntax = 5; if (this->syntax() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 5, this->syntax(), output); @@ -2503,7 +2396,7 @@ void Enum::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Enum) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -2528,14 +2421,14 @@ void Enum::SerializeWithCachedSizes( 3, this->options(i), false, target); } - // optional .google.protobuf.SourceContext source_context = 4; + // .google.protobuf.SourceContext source_context = 4; if (this->has_source_context()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( 4, *this->source_context_, false, target); } - // optional .google.protobuf.Syntax syntax = 5; + // .google.protobuf.Syntax syntax = 5; if (this->syntax() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 5, this->syntax(), target); @@ -2549,26 +2442,6 @@ size_t Enum::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Enum) size_t total_size = 0; - // optional string name = 1; - if (this->name().size() > 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional .google.protobuf.SourceContext source_context = 4; - if (this->has_source_context()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->source_context_); - } - - // optional .google.protobuf.Syntax syntax = 5; - if (this->syntax() != 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); - } - // repeated .google.protobuf.EnumValue enumvalue = 2; { unsigned int count = this->enumvalue_size(); @@ -2591,6 +2464,26 @@ size_t Enum::ByteSizeLong() const { } } + // string name = 1; + if (this->name().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + // .google.protobuf.SourceContext source_context = 4; + if (this->has_source_context()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->source_context_); + } + + // .google.protobuf.Syntax syntax = 5; + if (this->syntax() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); + } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -2600,7 +2493,7 @@ size_t Enum::ByteSizeLong() const { void Enum::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Enum) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Enum* source = ::google::protobuf::internal::DynamicCastToGenerated<const Enum>( &from); @@ -2609,21 +2502,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Enum::MergeFrom(const Enum& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Enum) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Enum::UnsafeMergeFrom(const Enum& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); enumvalue_.MergeFrom(from.enumvalue_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { @@ -2648,11 +2534,10 @@ void Enum::CopyFrom(const Enum& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Enum) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Enum::IsInitialized() const { - return true; } @@ -2661,10 +2546,13 @@ void Enum::Swap(Enum* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Enum temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Enum* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Enum::UnsafeArenaSwap(Enum* other) { @@ -2673,33 +2561,29 @@ void Enum::UnsafeArenaSwap(Enum* other) { InternalSwap(other); } void Enum::InternalSwap(Enum* other) { - name_.Swap(&other->name_); enumvalue_.UnsafeArenaSwap(&other->enumvalue_); options_.UnsafeArenaSwap(&other->options_); + name_.Swap(&other->name_); std::swap(source_context_, other->source_context_); std::swap(syntax_, other->syntax_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Enum::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Enum_descriptor_; - metadata.reflection = Enum_reflection_; - return metadata; + return file_level_metadata[2]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Enum -// optional string name = 1; +// string name = 1; void Enum::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Enum::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } void Enum::set_name(const ::std::string& value) { @@ -2819,7 +2703,7 @@ Enum::options() const { return options_; } -// optional .google.protobuf.SourceContext source_context = 4; +// .google.protobuf.SourceContext source_context = 4; bool Enum::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } @@ -2870,7 +2754,7 @@ const ::google::protobuf::SourceContext& Enum::source_context() const { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context) } -// optional .google.protobuf.Syntax syntax = 5; +// .google.protobuf.Syntax syntax = 5; void Enum::clear_syntax() { syntax_ = 0; } @@ -2884,9 +2768,6 @@ void Enum::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Enum.syntax) } -inline const Enum* Enum::internal_default_instance() { - return &Enum_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -2899,7 +2780,9 @@ const int EnumValue::kOptionsFieldNumber; EnumValue::EnumValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValue) } @@ -2914,15 +2797,18 @@ EnumValue::EnumValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValue) } - -void EnumValue::InitAsDefaultInstance() { -} - EnumValue::EnumValue(const EnumValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + options_(from.options_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); + } + number_ = from.number_; // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValue) } @@ -2959,7 +2845,7 @@ void EnumValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* EnumValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return EnumValue_descriptor_; + return file_level_metadata[3].descriptor; } const EnumValue& EnumValue::default_instance() { @@ -2967,17 +2853,15 @@ const EnumValue& EnumValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<EnumValue> EnumValue_default_instance_; - EnumValue* EnumValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<EnumValue>(arena); } void EnumValue::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValue) + options_.Clear(); name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); number_ = 0; - options_.Clear(); } bool EnumValue::MergePartialFromCodedStream( @@ -2986,13 +2870,13 @@ bool EnumValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.EnumValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -3002,14 +2886,12 @@ bool EnumValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_number; break; } - // optional int32 number = 2; + // int32 number = 2; case 2: { - if (tag == 16) { - parse_number: + if (tag == 16u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -3017,24 +2899,19 @@ bool EnumValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_options; break; } // repeated .google.protobuf.Option options = 3; case 3: { - if (tag == 26) { - parse_options: + if (tag == 26u) { DO_(input->IncrementRecursionDepth()); - parse_loop_options: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -3062,7 +2939,7 @@ failure: void EnumValue::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.EnumValue) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -3072,7 +2949,7 @@ void EnumValue::SerializeWithCachedSizes( 1, this->name(), output); } - // optional int32 number = 2; + // int32 number = 2; if (this->number() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->number(), output); } @@ -3090,7 +2967,7 @@ void EnumValue::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValue) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -3101,7 +2978,7 @@ void EnumValue::SerializeWithCachedSizes( 1, this->name(), target); } - // optional int32 number = 2; + // int32 number = 2; if (this->number() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->number(), target); } @@ -3121,31 +2998,31 @@ size_t EnumValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValue) size_t total_size = 0; - // optional string name = 1; + // repeated .google.protobuf.Option options = 3; + { + 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)); + } + } + + // string name = 1; if (this->name().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->name()); } - // optional int32 number = 2; + // int32 number = 2; if (this->number() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->number()); } - // repeated .google.protobuf.Option options = 3; - { - 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_ = cached_size; @@ -3155,7 +3032,7 @@ size_t EnumValue::ByteSizeLong() const { void EnumValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const EnumValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumValue>( &from); @@ -3164,21 +3041,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void EnumValue::MergeFrom(const EnumValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void EnumValue::UnsafeMergeFrom(const EnumValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { set_name(from.name()); @@ -3199,11 +3069,10 @@ void EnumValue::CopyFrom(const EnumValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool EnumValue::IsInitialized() const { - return true; } @@ -3212,10 +3081,13 @@ void EnumValue::Swap(EnumValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - EnumValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + EnumValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void EnumValue::UnsafeArenaSwap(EnumValue* other) { @@ -3224,31 +3096,27 @@ void EnumValue::UnsafeArenaSwap(EnumValue* other) { InternalSwap(other); } void EnumValue::InternalSwap(EnumValue* other) { + options_.UnsafeArenaSwap(&other->options_); name_.Swap(&other->name_); std::swap(number_, other->number_); - options_.UnsafeArenaSwap(&other->options_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata EnumValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumValue_descriptor_; - metadata.reflection = EnumValue_reflection_; - return metadata; + return file_level_metadata[3]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // EnumValue -// optional string name = 1; +// string name = 1; void EnumValue::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& EnumValue::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } void EnumValue::set_name(const ::std::string& value) { @@ -3308,7 +3176,7 @@ void EnumValue::unsafe_arena_set_allocated_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValue.name) } -// optional int32 number = 2; +// int32 number = 2; void EnumValue::clear_number() { number_ = 0; } @@ -3352,9 +3220,6 @@ EnumValue::options() const { return options_; } -inline const EnumValue* EnumValue::internal_default_instance() { - return &EnumValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -3399,7 +3264,9 @@ const int Option::kValueFieldNumber; Option::Option() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Option) } @@ -3413,17 +3280,21 @@ Option::Option(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Option) } - -void Option::InitAsDefaultInstance() { - value_ = const_cast< ::google::protobuf::Any*>( - ::google::protobuf::Any::internal_default_instance()); -} - Option::Option(const Option& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); + } + if (from.has_value()) { + value_ = new ::google::protobuf::Any(*from.value_); + } else { + value_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.Option) } @@ -3445,7 +3316,7 @@ void Option::SharedDtor() { } name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); - if (this != &Option_default_instance_.get()) { + if (this != internal_default_instance()) { delete value_; } } @@ -3463,7 +3334,7 @@ void Option::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Option::descriptor() { protobuf_AssignDescriptorsOnce(); - return Option_descriptor_; + return file_level_metadata[4].descriptor; } const Option& Option::default_instance() { @@ -3471,8 +3342,6 @@ const Option& Option::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Option> Option_default_instance_; - Option* Option::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Option>(arena); } @@ -3480,7 +3349,9 @@ Option* Option::New(::google::protobuf::Arena* arena) const { void Option::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Option) name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - if (GetArenaNoVirtual() == NULL && value_ != NULL) delete value_; + if (GetArenaNoVirtual() == NULL && value_ != NULL) { + delete value_; + } value_ = NULL; } @@ -3490,13 +3361,13 @@ bool Option::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Option) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -3506,20 +3377,17 @@ bool Option::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_value; break; } - // optional .google.protobuf.Any value = 2; + // .google.protobuf.Any value = 2; case 2: { - if (tag == 18) { - parse_value: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_value())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -3547,7 +3415,7 @@ failure: void Option::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Option) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -3557,7 +3425,7 @@ void Option::SerializeWithCachedSizes( 1, this->name(), output); } - // optional .google.protobuf.Any value = 2; + // .google.protobuf.Any value = 2; if (this->has_value()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 2, *this->value_, output); @@ -3570,7 +3438,7 @@ void Option::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Option) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -3581,7 +3449,7 @@ void Option::SerializeWithCachedSizes( 1, this->name(), target); } - // optional .google.protobuf.Any value = 2; + // .google.protobuf.Any value = 2; if (this->has_value()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( @@ -3596,14 +3464,14 @@ size_t Option::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Option) size_t total_size = 0; - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->name()); } - // optional .google.protobuf.Any value = 2; + // .google.protobuf.Any value = 2; if (this->has_value()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( @@ -3619,7 +3487,7 @@ size_t Option::ByteSizeLong() const { void Option::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Option) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Option* source = ::google::protobuf::internal::DynamicCastToGenerated<const Option>( &from); @@ -3628,21 +3496,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Option::MergeFrom(const Option& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Option) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Option::UnsafeMergeFrom(const Option& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.name().size() > 0) { set_name(from.name()); } @@ -3662,11 +3523,10 @@ void Option::CopyFrom(const Option& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Option) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Option::IsInitialized() const { - return true; } @@ -3675,10 +3535,13 @@ void Option::Swap(Option* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Option temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Option* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Option::UnsafeArenaSwap(Option* other) { @@ -3689,28 +3552,24 @@ void Option::UnsafeArenaSwap(Option* other) { void Option::InternalSwap(Option* other) { name_.Swap(&other->name_); std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Option::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Option_descriptor_; - metadata.reflection = Option_reflection_; - return metadata; + return file_level_metadata[4]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Option -// optional string name = 1; +// string name = 1; void Option::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Option::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Option.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } void Option::set_name(const ::std::string& value) { @@ -3770,7 +3629,7 @@ void Option::unsafe_arena_set_allocated_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.name) } -// optional .google.protobuf.Any value = 2; +// .google.protobuf.Any value = 2; bool Option::has_value() const { return this != internal_default_instance() && value_ != NULL; } @@ -3821,9 +3680,6 @@ const ::google::protobuf::Any& Option::value() const { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.value) } -inline const Option* Option::internal_default_instance() { - return &Option_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 1b6d3410..6f29ab61 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -24,28 +24,45 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/generated_enum_reflection.h> #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/any.pb.h> #include <google/protobuf/source_context.pb.h> // @@protoc_insertion_point(includes) - namespace google { 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(); - +class Any; +class AnyDefaultTypeInternal; +extern AnyDefaultTypeInternal _Any_default_instance_; class Enum; +class EnumDefaultTypeInternal; +extern EnumDefaultTypeInternal _Enum_default_instance_; class EnumValue; +class EnumValueDefaultTypeInternal; +extern EnumValueDefaultTypeInternal _EnumValue_default_instance_; class Field; +class FieldDefaultTypeInternal; +extern FieldDefaultTypeInternal _Field_default_instance_; class Option; +class OptionDefaultTypeInternal; +extern OptionDefaultTypeInternal _Option_default_instance_; +class SourceContext; +class SourceContextDefaultTypeInternal; +extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; class Type; +class TypeDefaultTypeInternal; +extern TypeDefaultTypeInternal _Type_default_instance_; +} // namespace protobuf +} // namespace google + +namespace google { +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(); enum Field_Kind { Field_Kind_TYPE_UNKNOWN = 0, @@ -143,47 +160,52 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Type& default_instance(); - static const Type* internal_default_instance(); + static inline const Type* internal_default_instance() { + return reinterpret_cast<const Type*>( + &_Type_default_instance_); + } void UnsafeArenaSwap(Type* other); void Swap(Type* other); // implements Message ---------------------------------------------- - inline Type* New() const { return New(NULL); } + inline Type* New() const PROTOBUF_FINAL { return New(NULL); } - Type* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Type* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Type& from); void MergeFrom(const Type& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Type* other); - void UnsafeMergeFrom(const Type& from); protected: explicit Type(::google::protobuf::Arena* arena); private: @@ -198,13 +220,13 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -258,7 +280,7 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; bool has_source_context() const; void clear_source_context(); static const int kSourceContextFieldNumber = 5; @@ -274,7 +296,7 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i void unsafe_arena_set_allocated_source_context( ::google::protobuf::SourceContext* source_context); - // optional .google.protobuf.Syntax syntax = 6; + // .google.protobuf.Syntax syntax = 6; void clear_syntax(); static const int kSyntaxFieldNumber = 6; ::google::protobuf::Syntax syntax() const; @@ -296,13 +318,10 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Type> Type_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Field) */ { @@ -317,47 +336,52 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Field& default_instance(); - static const Field* internal_default_instance(); + static inline const Field* internal_default_instance() { + return reinterpret_cast<const Field*>( + &_Field_default_instance_); + } void UnsafeArenaSwap(Field* other); void Swap(Field* other); // implements Message ---------------------------------------------- - inline Field* New() const { return New(NULL); } + inline Field* New() const PROTOBUF_FINAL { return New(NULL); } - Field* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Field* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Field& from); void MergeFrom(const Field& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Field* other); - void UnsafeMergeFrom(const Field& from); protected: explicit Field(::google::protobuf::Arena* arena); private: @@ -372,7 +396,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -468,25 +492,25 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ // accessors ------------------------------------------------------- - // optional .google.protobuf.Field.Kind kind = 1; + // .google.protobuf.Field.Kind kind = 1; void clear_kind(); static const int kKindFieldNumber = 1; ::google::protobuf::Field_Kind kind() const; void set_kind(::google::protobuf::Field_Kind value); - // optional .google.protobuf.Field.Cardinality cardinality = 2; + // .google.protobuf.Field.Cardinality cardinality = 2; void clear_cardinality(); static const int kCardinalityFieldNumber = 2; ::google::protobuf::Field_Cardinality cardinality() const; void set_cardinality(::google::protobuf::Field_Cardinality value); - // optional int32 number = 3; + // int32 number = 3; void clear_number(); static const int kNumberFieldNumber = 3; ::google::protobuf::int32 number() const; void set_number(::google::protobuf::int32 value); - // optional string name = 4; + // string name = 4; void clear_name(); static const int kNameFieldNumber = 4; const ::std::string& name() const; @@ -500,7 +524,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ void unsafe_arena_set_allocated_name( ::std::string* name); - // optional string type_url = 6; + // string type_url = 6; void clear_type_url(); static const int kTypeUrlFieldNumber = 6; const ::std::string& type_url() const; @@ -514,13 +538,13 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ void unsafe_arena_set_allocated_type_url( ::std::string* type_url); - // optional int32 oneof_index = 7; + // int32 oneof_index = 7; void clear_oneof_index(); static const int kOneofIndexFieldNumber = 7; ::google::protobuf::int32 oneof_index() const; void set_oneof_index(::google::protobuf::int32 value); - // optional bool packed = 8; + // bool packed = 8; void clear_packed(); static const int kPackedFieldNumber = 8; bool packed() const; @@ -538,7 +562,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; - // optional string json_name = 10; + // string json_name = 10; void clear_json_name(); static const int kJsonNameFieldNumber = 10; const ::std::string& json_name() const; @@ -552,7 +576,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ void unsafe_arena_set_allocated_json_name( ::std::string* json_name); - // optional string default_value = 11; + // string default_value = 11; void clear_default_value(); static const int kDefaultValueFieldNumber = 11; const ::std::string& default_value() const; @@ -586,13 +610,10 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Field> Field_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Enum) */ { @@ -607,47 +628,52 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Enum& default_instance(); - static const Enum* internal_default_instance(); + static inline const Enum* internal_default_instance() { + return reinterpret_cast<const Enum*>( + &_Enum_default_instance_); + } void UnsafeArenaSwap(Enum* other); void Swap(Enum* other); // implements Message ---------------------------------------------- - inline Enum* New() const { return New(NULL); } + inline Enum* New() const PROTOBUF_FINAL { return New(NULL); } - Enum* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Enum* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Enum& from); void MergeFrom(const Enum& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Enum* other); - void UnsafeMergeFrom(const Enum& from); protected: explicit Enum(::google::protobuf::Arena* arena); private: @@ -662,13 +688,13 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -706,7 +732,7 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; - // optional .google.protobuf.SourceContext source_context = 4; + // .google.protobuf.SourceContext source_context = 4; bool has_source_context() const; void clear_source_context(); static const int kSourceContextFieldNumber = 4; @@ -722,7 +748,7 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i void unsafe_arena_set_allocated_source_context( ::google::protobuf::SourceContext* source_context); - // optional .google.protobuf.Syntax syntax = 5; + // .google.protobuf.Syntax syntax = 5; void clear_syntax(); static const int kSyntaxFieldNumber = 5; ::google::protobuf::Syntax syntax() const; @@ -743,13 +769,10 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Enum> Enum_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValue) */ { @@ -764,47 +787,52 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const EnumValue& default_instance(); - static const EnumValue* internal_default_instance(); + static inline const EnumValue* internal_default_instance() { + return reinterpret_cast<const EnumValue*>( + &_EnumValue_default_instance_); + } void UnsafeArenaSwap(EnumValue* other); void Swap(EnumValue* other); // implements Message ---------------------------------------------- - inline EnumValue* New() const { return New(NULL); } + inline EnumValue* New() const PROTOBUF_FINAL { return New(NULL); } - EnumValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + EnumValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumValue& from); void MergeFrom(const EnumValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumValue* other); - void UnsafeMergeFrom(const EnumValue& from); protected: explicit EnumValue(::google::protobuf::Arena* arena); private: @@ -819,13 +847,13 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -839,7 +867,7 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro void unsafe_arena_set_allocated_name( ::std::string* name); - // optional int32 number = 2; + // int32 number = 2; void clear_number(); static const int kNumberFieldNumber = 2; ::google::protobuf::int32 number() const; @@ -870,13 +898,10 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<EnumValue> EnumValue_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Option) */ { @@ -891,47 +916,52 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Option& default_instance(); - static const Option* internal_default_instance(); + static inline const Option* internal_default_instance() { + return reinterpret_cast<const Option*>( + &_Option_default_instance_); + } void UnsafeArenaSwap(Option* other); void Swap(Option* other); // implements Message ---------------------------------------------- - inline Option* New() const { return New(NULL); } + inline Option* New() const PROTOBUF_FINAL { return New(NULL); } - Option* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Option* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Option& from); void MergeFrom(const Option& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Option* other); - void UnsafeMergeFrom(const Option& from); protected: explicit Option(::google::protobuf::Arena* arena); private: @@ -946,13 +976,13 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -966,7 +996,7 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc void unsafe_arena_set_allocated_name( ::std::string* name); - // optional .google.protobuf.Any value = 2; + // .google.protobuf.Any value = 2; bool has_value() const; void clear_value(); static const int kValueFieldNumber = 2; @@ -994,13 +1024,10 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Option> Option_default_instance_; - // =================================================================== @@ -1009,13 +1036,13 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Option> Option_defaul #if !PROTOBUF_INLINE_NOT_IN_HEADERS // Type -// optional string name = 1; +// string name = 1; inline void Type::clear_name() { 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_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } inline void Type::set_name(const ::std::string& value) { @@ -1190,7 +1217,7 @@ Type::options() const { return options_; } -// optional .google.protobuf.SourceContext source_context = 5; +// .google.protobuf.SourceContext source_context = 5; inline bool Type::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } @@ -1241,7 +1268,7 @@ inline void Type::set_allocated_source_context(::google::protobuf::SourceContex // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context) } -// optional .google.protobuf.Syntax syntax = 6; +// .google.protobuf.Syntax syntax = 6; inline void Type::clear_syntax() { syntax_ = 0; } @@ -1255,14 +1282,11 @@ inline void Type::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Type.syntax) } -inline const Type* Type::internal_default_instance() { - return &Type_default_instance_.get(); -} // ------------------------------------------------------------------- // Field -// optional .google.protobuf.Field.Kind kind = 1; +// .google.protobuf.Field.Kind kind = 1; inline void Field::clear_kind() { kind_ = 0; } @@ -1276,7 +1300,7 @@ inline void Field::set_kind(::google::protobuf::Field_Kind value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.kind) } -// optional .google.protobuf.Field.Cardinality cardinality = 2; +// .google.protobuf.Field.Cardinality cardinality = 2; inline void Field::clear_cardinality() { cardinality_ = 0; } @@ -1290,7 +1314,7 @@ inline void Field::set_cardinality(::google::protobuf::Field_Cardinality value) // @@protoc_insertion_point(field_set:google.protobuf.Field.cardinality) } -// optional int32 number = 3; +// int32 number = 3; inline void Field::clear_number() { number_ = 0; } @@ -1304,13 +1328,13 @@ inline void Field::set_number(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.number) } -// optional string name = 4; +// string name = 4; inline void Field::clear_name() { 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_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } inline void Field::set_name(const ::std::string& value) { @@ -1370,13 +1394,13 @@ inline void Field::unsafe_arena_set_allocated_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.name) } -// optional string type_url = 6; +// string type_url = 6; inline void Field::clear_type_url() { 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_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.Get(); } inline void Field::set_type_url(const ::std::string& value) { @@ -1436,7 +1460,7 @@ inline void Field::unsafe_arena_set_allocated_type_url( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.type_url) } -// optional int32 oneof_index = 7; +// int32 oneof_index = 7; inline void Field::clear_oneof_index() { oneof_index_ = 0; } @@ -1450,7 +1474,7 @@ inline void Field::set_oneof_index(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.oneof_index) } -// optional bool packed = 8; +// bool packed = 8; inline void Field::clear_packed() { packed_ = false; } @@ -1494,13 +1518,13 @@ Field::options() const { return options_; } -// optional string json_name = 10; +// string json_name = 10; inline void Field::clear_json_name() { 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_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.Get(); } inline void Field::set_json_name(const ::std::string& value) { @@ -1560,13 +1584,13 @@ inline void Field::unsafe_arena_set_allocated_json_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.json_name) } -// optional string default_value = 11; +// string default_value = 11; inline void Field::clear_default_value() { 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_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.Get(); } inline void Field::set_default_value(const ::std::string& value) { @@ -1626,20 +1650,17 @@ inline void Field::unsafe_arena_set_allocated_default_value( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.default_value) } -inline const Field* Field::internal_default_instance() { - return &Field_default_instance_.get(); -} // ------------------------------------------------------------------- // Enum -// optional string name = 1; +// string name = 1; inline void Enum::clear_name() { 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_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } inline void Enum::set_name(const ::std::string& value) { @@ -1759,7 +1780,7 @@ Enum::options() const { return options_; } -// optional .google.protobuf.SourceContext source_context = 4; +// .google.protobuf.SourceContext source_context = 4; inline bool Enum::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } @@ -1810,7 +1831,7 @@ inline void Enum::set_allocated_source_context(::google::protobuf::SourceContex // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context) } -// optional .google.protobuf.Syntax syntax = 5; +// .google.protobuf.Syntax syntax = 5; inline void Enum::clear_syntax() { syntax_ = 0; } @@ -1824,20 +1845,17 @@ inline void Enum::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Enum.syntax) } -inline const Enum* Enum::internal_default_instance() { - return &Enum_default_instance_.get(); -} // ------------------------------------------------------------------- // EnumValue -// optional string name = 1; +// string name = 1; inline void EnumValue::clear_name() { 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_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } inline void EnumValue::set_name(const ::std::string& value) { @@ -1897,7 +1915,7 @@ inline void EnumValue::unsafe_arena_set_allocated_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValue.name) } -// optional int32 number = 2; +// int32 number = 2; inline void EnumValue::clear_number() { number_ = 0; } @@ -1941,20 +1959,17 @@ EnumValue::options() const { return options_; } -inline const EnumValue* EnumValue::internal_default_instance() { - return &EnumValue_default_instance_.get(); -} // ------------------------------------------------------------------- // Option -// optional string name = 1; +// string name = 1; inline void Option::clear_name() { 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_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } inline void Option::set_name(const ::std::string& value) { @@ -2014,7 +2029,7 @@ inline void Option::unsafe_arena_set_allocated_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.name) } -// optional .google.protobuf.Any value = 2; +// .google.protobuf.Any value = 2; inline bool Option::has_value() const { return this != internal_default_instance() && value_ != NULL; } @@ -2065,9 +2080,6 @@ inline void Option::set_allocated_value(::google::protobuf::Any* value) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.value) } -inline const Option* Option::internal_default_instance() { - return &Option_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- @@ -2080,6 +2092,7 @@ inline const Option* Option::internal_default_instance() { // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/type.proto b/src/google/protobuf/type.proto index 504cd25d..c1e696d6 100644 --- a/src/google/protobuf/type.proto +++ b/src/google/protobuf/type.proto @@ -41,6 +41,7 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "TypeProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; +option go_package = "google.golang.org/genproto/protobuf/ptype;ptype"; // A protocol buffer message type. message Type { diff --git a/src/google/protobuf/unittest.proto b/src/google/protobuf/unittest.proto index cc2f4b34..96289cc5 100644 --- a/src/google/protobuf/unittest.proto +++ b/src/google/protobuf/unittest.proto @@ -886,3 +886,34 @@ message TestJsonName { optional int32 FIELD_NAME5 = 5; optional int32 field_name6 = 6 [json_name = "@type"]; } + +message TestHugeFieldNumbers { + optional int32 optional_int32 = 536870000; + optional int32 fixed_32 = 536870001; + repeated int32 repeated_int32 = 536870002 [packed = false]; + repeated int32 packed_int32 = 536870003 [packed = true]; + + optional ForeignEnum optional_enum = 536870004; + optional string optional_string = 536870005; + optional bytes optional_bytes = 536870006; + optional ForeignMessage optional_message = 536870007; + + optional group OptionalGroup = 536870008 { + optional int32 group_a = 536870009; + } + + map<string, string> string_string_map = 536870010; + + oneof oneof_field { + uint32 oneof_uint32 = 536870011; + TestAllTypes oneof_test_all_types = 536870012; + string oneof_string = 536870013; + bytes oneof_bytes = 536870014; + } + + extensions 536860000 to 536869999; +} + +extend TestHugeFieldNumbers { + optional TestAllTypes test_all_types = 536860000; +} diff --git a/src/google/protobuf/unittest_lite.proto b/src/google/protobuf/unittest_lite.proto index 878ec7c1..c39ac6b0 100644 --- a/src/google/protobuf/unittest_lite.proto +++ b/src/google/protobuf/unittest_lite.proto @@ -163,6 +163,9 @@ message TestAllTypesLite { bytes oneof_bytes = 114; NestedMessage oneof_lazy_nested_message = 115 [lazy = true]; } + + // Tests toString for non-repeated fields with a list suffix + optional int32 deceptively_named_list = 116; } message ForeignMessageLite { @@ -405,3 +408,34 @@ message V2MessageLite { required int32 int_field = 1; optional V2EnumLite enum_field = 2 [ default = V2_FIRST ]; } + +message TestHugeFieldNumbersLite { + optional int32 optional_int32 = 536870000; + optional int32 fixed_32 = 536870001; + repeated int32 repeated_int32 = 536870002 [packed = false]; + repeated int32 packed_int32 = 536870003 [packed = true]; + + optional ForeignEnumLite optional_enum = 536870004; + optional string optional_string = 536870005; + optional bytes optional_bytes = 536870006; + optional ForeignMessageLite optional_message = 536870007; + + optional group OptionalGroup = 536870008 { + optional int32 group_a = 536870009; + } + + map<string, string> string_string_map = 536870010; + + oneof oneof_field { + uint32 oneof_uint32 = 536870011; + TestAllTypesLite oneof_test_all_types = 536870012; + string oneof_string = 536870013; + bytes oneof_bytes = 536870014; + } + + extensions 536860000 to 536869999; +} + +extend TestHugeFieldNumbersLite { + optional TestAllTypesLite test_all_types_lite = 536860000; +} diff --git a/src/google/protobuf/unknown_field_set.cc b/src/google/protobuf/unknown_field_set.cc index bca3fbf8..9472c4fa 100644 --- a/src/google/protobuf/unknown_field_set.cc +++ b/src/google/protobuf/unknown_field_set.cc @@ -83,7 +83,7 @@ void UnknownFieldSet::ClearFallback() { void UnknownFieldSet::InternalMergeFrom(const UnknownFieldSet& other) { int other_field_count = other.field_count(); if (other_field_count > 0) { - fields_ = new vector<UnknownField>(); + fields_ = new std::vector<UnknownField>(); for (int i = 0; i < other_field_count; i++) { fields_->push_back((*other.fields_)[i]); fields_->back().DeepCopy((*other.fields_)[i]); @@ -94,7 +94,7 @@ void UnknownFieldSet::InternalMergeFrom(const UnknownFieldSet& other) { void UnknownFieldSet::MergeFrom(const UnknownFieldSet& other) { int other_field_count = other.field_count(); if (other_field_count > 0) { - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); for (int i = 0; i < other_field_count; i++) { fields_->push_back((*other.fields_)[i]); fields_->back().DeepCopy((*other.fields_)[i]); @@ -107,7 +107,7 @@ void UnknownFieldSet::MergeFrom(const UnknownFieldSet& other) { void UnknownFieldSet::MergeFromAndDestroy(UnknownFieldSet* other) { int other_field_count = other->field_count(); if (other_field_count > 0) { - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); for (int i = 0; i < other_field_count; i++) { fields_->push_back((*other->fields_)[i]); (*other->fields_)[i].Reset(); @@ -155,7 +155,7 @@ void UnknownFieldSet::AddVarint(int number, uint64 value) { field.number_ = number; field.SetType(UnknownField::TYPE_VARINT); field.varint_ = value; - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); fields_->push_back(field); } @@ -164,7 +164,7 @@ void UnknownFieldSet::AddFixed32(int number, uint32 value) { field.number_ = number; field.SetType(UnknownField::TYPE_FIXED32); field.fixed32_ = value; - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); fields_->push_back(field); } @@ -173,7 +173,7 @@ void UnknownFieldSet::AddFixed64(int number, uint64 value) { field.number_ = number; field.SetType(UnknownField::TYPE_FIXED64); field.fixed64_ = value; - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); fields_->push_back(field); } @@ -182,7 +182,7 @@ string* UnknownFieldSet::AddLengthDelimited(int number) { field.number_ = number; field.SetType(UnknownField::TYPE_LENGTH_DELIMITED); field.length_delimited_.string_value_ = new string; - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); fields_->push_back(field); return field.length_delimited_.string_value_; } @@ -193,13 +193,13 @@ UnknownFieldSet* UnknownFieldSet::AddGroup(int number) { field.number_ = number; field.SetType(UnknownField::TYPE_GROUP); field.group_ = new UnknownFieldSet; - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); fields_->push_back(field); return field.group_; } void UnknownFieldSet::AddField(const UnknownField& field) { - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); fields_->push_back(field); fields_->back().DeepCopy(field); } diff --git a/src/google/protobuf/unknown_field_set_unittest.cc b/src/google/protobuf/unknown_field_set_unittest.cc index 5de72630..e55bb012 100644 --- a/src/google/protobuf/unknown_field_set_unittest.cc +++ b/src/google/protobuf/unknown_field_set_unittest.cc @@ -488,7 +488,7 @@ TEST_F(UnknownFieldSetTest, UnknownEnumValue) { TEST_F(UnknownFieldSetTest, SpaceUsedExcludingSelf) { UnknownFieldSet empty; empty.AddVarint(1, 0); - EXPECT_EQ(sizeof(vector<UnknownField>) + sizeof(UnknownField), + EXPECT_EQ(sizeof(std::vector<UnknownField>) + sizeof(UnknownField), empty.SpaceUsedExcludingSelf()); } @@ -559,8 +559,9 @@ TEST_F(UnknownFieldSetTest, DeleteSubrange) { } } -void CheckDeleteByNumber(const vector<int>& field_numbers, int deleted_number, - const vector<int>& expected_field_nubmers) { +void CheckDeleteByNumber(const std::vector<int>& field_numbers, + int deleted_number, + const std::vector<int>& expected_field_nubmers) { UnknownFieldSet unknown_fields; for (int i = 0; i < field_numbers.size(); ++i) { unknown_fields.AddFixed32(field_numbers[i], i); @@ -573,9 +574,9 @@ void CheckDeleteByNumber(const vector<int>& field_numbers, int deleted_number, } } -#define MAKE_VECTOR(x) vector<int>(x, x + GOOGLE_ARRAYSIZE(x)) +#define MAKE_VECTOR(x) std::vector<int>(x, x + GOOGLE_ARRAYSIZE(x)) TEST_F(UnknownFieldSetTest, DeleteByNumber) { - CheckDeleteByNumber(vector<int>(), 1, vector<int>()); + CheckDeleteByNumber(std::vector<int>(), 1, std::vector<int>()); static const int kTestFieldNumbers1[] = {1, 2, 3}; static const int kFieldNumberToDelete1 = 1; static const int kExpectedFieldNumbers1[] = {2, 3}; diff --git a/src/google/protobuf/util/field_comparator.h b/src/google/protobuf/util/field_comparator.h index 3c70a314..ad560ebc 100644 --- a/src/google/protobuf/util/field_comparator.h +++ b/src/google/protobuf/util/field_comparator.h @@ -30,8 +30,6 @@ // Defines classes for field comparison. -// Author: ksroka@google.com (Krzysztof Sroka) - #ifndef GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ #define GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ diff --git a/src/google/protobuf/util/field_comparator_test.cc b/src/google/protobuf/util/field_comparator_test.cc index 6fd631d8..249b8d54 100644 --- a/src/google/protobuf/util/field_comparator_test.cc +++ b/src/google/protobuf/util/field_comparator_test.cc @@ -365,10 +365,10 @@ TEST_F(DefaultFieldComparatorTest, // +inf should be equal even though they are not technically within margin or // fraction. - message_1_.set_optional_float(numeric_limits<float>::infinity()); - message_2_.set_optional_float(numeric_limits<float>::infinity()); - message_1_.set_optional_double(numeric_limits<double>::infinity()); - message_2_.set_optional_double(numeric_limits<double>::infinity()); + message_1_.set_optional_float(std::numeric_limits<float>::infinity()); + message_2_.set_optional_float(std::numeric_limits<float>::infinity()); + message_1_.set_optional_double(std::numeric_limits<double>::infinity()); + message_2_.set_optional_double(std::numeric_limits<double>::infinity()); comparator_.SetFractionAndMargin(field_float, 0.0, 0.0); comparator_.SetFractionAndMargin(field_double, 0.0, 0.0); EXPECT_EQ(FieldComparator::SAME, @@ -380,10 +380,10 @@ TEST_F(DefaultFieldComparatorTest, // -inf should be equal even though they are not technically within margin or // fraction. - message_1_.set_optional_float(-numeric_limits<float>::infinity()); - message_2_.set_optional_float(-numeric_limits<float>::infinity()); - message_1_.set_optional_double(-numeric_limits<double>::infinity()); - message_2_.set_optional_double(-numeric_limits<double>::infinity()); + message_1_.set_optional_float(-std::numeric_limits<float>::infinity()); + message_2_.set_optional_float(-std::numeric_limits<float>::infinity()); + message_1_.set_optional_double(-std::numeric_limits<double>::infinity()); + message_2_.set_optional_double(-std::numeric_limits<double>::infinity()); comparator_.SetFractionAndMargin(field_float, 0.0, 0.0); comparator_.SetFractionAndMargin(field_double, 0.0, 0.0); EXPECT_EQ(FieldComparator::SAME, diff --git a/src/google/protobuf/util/field_mask_util.cc b/src/google/protobuf/util/field_mask_util.cc index 9dfcbd72..07550e6d 100644 --- a/src/google/protobuf/util/field_mask_util.cc +++ b/src/google/protobuf/util/field_mask_util.cc @@ -45,7 +45,7 @@ string FieldMaskUtil::ToString(const FieldMask& mask) { void FieldMaskUtil::FromString(StringPiece str, FieldMask* out) { out->Clear(); - vector<string> paths = Split(str, ","); + std::vector<string> paths = Split(str, ","); for (int i = 0; i < paths.size(); ++i) { if (paths[i].empty()) continue; out->add_paths(paths[i]); @@ -116,7 +116,7 @@ bool FieldMaskUtil::ToJsonString(const FieldMask& mask, string* out) { bool FieldMaskUtil::FromJsonString(StringPiece str, FieldMask* out) { out->Clear(); - vector<string> paths = Split(str, ","); + std::vector<string> paths = Split(str, ","); for (int i = 0; i < paths.size(); ++i) { if (paths[i].empty()) continue; string snakecase_path; @@ -128,9 +128,13 @@ bool FieldMaskUtil::FromJsonString(StringPiece str, FieldMask* out) { return true; } -bool FieldMaskUtil::InternalIsValidPath(const Descriptor* descriptor, - StringPiece path) { - vector<string> parts = Split(path, "."); +bool FieldMaskUtil::GetFieldDescriptors( + const Descriptor* descriptor, StringPiece path, + std::vector<const FieldDescriptor*>* field_descriptors) { + if (field_descriptors != NULL) { + field_descriptors->clear(); + } + std::vector<string> parts = Split(path, "."); for (int i = 0; i < parts.size(); ++i) { const string& field_name = parts[i]; if (descriptor == NULL) { @@ -140,6 +144,9 @@ bool FieldMaskUtil::InternalIsValidPath(const Descriptor* descriptor, if (field == NULL) { return false; } + if (field_descriptors != NULL) { + field_descriptors->push_back(field); + } if (!field->is_repeated() && field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { descriptor = field->message_type(); @@ -216,14 +223,14 @@ class FieldMaskTree { ~Node() { ClearChildren(); } void ClearChildren() { - for (map<string, Node*>::iterator it = children.begin(); + for (std::map<string, Node*>::iterator it = children.begin(); it != children.end(); ++it) { delete it->second; } children.clear(); } - map<string, Node*> children; + std::map<string, Node*> children; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Node); @@ -274,7 +281,7 @@ void FieldMaskTree::MergeToFieldMask(const string& prefix, const Node* node, out->add_paths(prefix); return; } - for (map<string, Node*>::const_iterator it = node->children.begin(); + for (std::map<string, Node*>::const_iterator it = node->children.begin(); it != node->children.end(); ++it) { string current_path = prefix.empty() ? it->first : prefix + "." + it->first; MergeToFieldMask(current_path, it->second, out); @@ -282,7 +289,7 @@ void FieldMaskTree::MergeToFieldMask(const string& prefix, const Node* node, } void FieldMaskTree::AddPath(const string& path) { - vector<string> parts = Split(path, "."); + std::vector<string> parts = Split(path, "."); if (parts.empty()) { return; } @@ -309,7 +316,7 @@ void FieldMaskTree::AddPath(const string& path) { } void FieldMaskTree::IntersectPath(const string& path, FieldMaskTree* out) { - vector<string> parts = Split(path, "."); + std::vector<string> parts = Split(path, "."); if (parts.empty()) { return; } @@ -339,7 +346,7 @@ void FieldMaskTree::MergeLeafNodesToTree(const string& prefix, const Node* node, if (node->children.empty()) { out->AddPath(prefix); } - for (map<string, Node*>::const_iterator it = node->children.begin(); + for (std::map<string, Node*>::const_iterator it = node->children.begin(); it != node->children.end(); ++it) { string current_path = prefix.empty() ? it->first : prefix + "." + it->first; MergeLeafNodesToTree(current_path, it->second, out); @@ -353,7 +360,7 @@ void FieldMaskTree::MergeMessage(const Node* node, const Message& source, const Reflection* source_reflection = source.GetReflection(); const Reflection* destination_reflection = destination->GetReflection(); const Descriptor* descriptor = source.GetDescriptor(); - for (map<string, Node*>::const_iterator it = node->children.begin(); + for (std::map<string, Node*>::const_iterator it = node->children.begin(); it != node->children.end(); ++it) { const string& field_name = it->first; const Node* child = it->second; diff --git a/src/google/protobuf/util/field_mask_util.h b/src/google/protobuf/util/field_mask_util.h index 396c9aea..ab1f2e94 100644 --- a/src/google/protobuf/util/field_mask_util.h +++ b/src/google/protobuf/util/field_mask_util.h @@ -59,17 +59,26 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil { static bool ToJsonString(const FieldMask& mask, string* out); static bool FromJsonString(StringPiece str, FieldMask* out); + // Get the descriptors of the fields which the given path from the message + // descriptor traverses, if field_descriptors is not null. + // Return false if the path is not valid, and the content of field_descriptors + // is unspecified. + static bool GetFieldDescriptors( + const Descriptor* descriptor, StringPiece path, + std::vector<const FieldDescriptor*>* field_descriptors); + // Checks whether the given path is valid for type T. template <typename T> static bool IsValidPath(StringPiece path) { - return InternalIsValidPath(T::descriptor(), path); + return GetFieldDescriptors(T::descriptor(), path, NULL); } // Checks whether the given FieldMask is valid for type T. template <typename T> static bool IsValidFieldMask(const FieldMask& mask) { for (int i = 0; i < mask.paths_size(); ++i) { - if (!InternalIsValidPath(T::descriptor(), mask.paths(i))) return false; + if (!GetFieldDescriptors(T::descriptor(), mask.paths(i), NULL)) + return false; } return true; } @@ -149,9 +158,6 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil { // successfully. static bool CamelCaseToSnakeCase(StringPiece input, string* output); - static bool InternalIsValidPath(const Descriptor* descriptor, - StringPiece path); - static void InternalGetFieldMaskForAllFields(const Descriptor* descriptor, FieldMask* out); }; diff --git a/src/google/protobuf/util/field_mask_util_test.cc b/src/google/protobuf/util/field_mask_util_test.cc index 43fb7905..f952786f 100644 --- a/src/google/protobuf/util/field_mask_util_test.cc +++ b/src/google/protobuf/util/field_mask_util_test.cc @@ -159,6 +159,27 @@ TEST(FieldMaskUtilTest, JsonStringFormat) { EXPECT_EQ("baz_quz", mask.paths(1)); } +TEST(FieldMaskUtilTest, GetFieldDescriptors) { + std::vector<const FieldDescriptor*> field_descriptors; + EXPECT_TRUE(FieldMaskUtil::GetFieldDescriptors( + TestAllTypes::descriptor(), "optional_int32", &field_descriptors)); + EXPECT_EQ(1, field_descriptors.size()); + EXPECT_EQ("optional_int32", field_descriptors[0]->name()); + EXPECT_FALSE(FieldMaskUtil::GetFieldDescriptors( + TestAllTypes::descriptor(), "optional_nonexist", NULL)); + EXPECT_TRUE(FieldMaskUtil::GetFieldDescriptors(TestAllTypes::descriptor(), + "optional_nested_message.bb", + &field_descriptors)); + EXPECT_EQ(2, field_descriptors.size()); + EXPECT_EQ("optional_nested_message", field_descriptors[0]->name()); + EXPECT_EQ("bb", field_descriptors[1]->name()); + EXPECT_FALSE(FieldMaskUtil::GetFieldDescriptors( + TestAllTypes::descriptor(), "optional_nested_message.nonexist", NULL)); + // FieldMask cannot be used to specify sub-fields of a repeated message. + EXPECT_FALSE(FieldMaskUtil::GetFieldDescriptors( + TestAllTypes::descriptor(), "repeated_nested_message.bb", NULL)); +} + TEST(FieldMaskUtilTest, TestIsVaildPath) { EXPECT_TRUE(FieldMaskUtil::IsValidPath<TestAllTypes>("optional_int32")); EXPECT_FALSE(FieldMaskUtil::IsValidPath<TestAllTypes>("optional_nonexist")); diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc index eeb55c6b..213c2c40 100644 --- a/src/google/protobuf/util/internal/datapiece.cc +++ b/src/google/protobuf/util/internal/datapiece.cc @@ -94,19 +94,24 @@ StatusOr<To> FloatingPointToIntConvertAndCheck(From before) { } // For conversion between double and float only. -template <typename To, typename From> -StatusOr<To> FloatingPointConvertAndCheck(From before) { - if (MathLimits<From>::IsNaN(before)) { - return std::numeric_limits<To>::quiet_NaN(); - } +StatusOr<double> FloatToDouble(float before) { + // Casting float to double should just work as double has more precision + // than float. + return static_cast<double>(before); +} - To after = static_cast<To>(before); - if (MathUtil::AlmostEquals<To>(after, before)) { - return after; +StatusOr<float> DoubleToFloat(double before) { + if (MathLimits<double>::IsNaN(before)) { + return std::numeric_limits<float>::quiet_NaN(); + } else if (!MathLimits<double>::IsFinite(before)) { + // Converting a double +inf/-inf to float should just work. + return static_cast<float>(before); + } else if (before > std::numeric_limits<float>::max() || + before < -std::numeric_limits<float>::max()) { + // Double value outside of the range of float. + return InvalidArgument(DoubleAsString(before)); } else { - return InvalidArgument(::google::protobuf::internal::is_same<From, double>::value - ? DoubleAsString(before) - : FloatAsString(before)); + return static_cast<float>(before); } } @@ -162,20 +167,27 @@ StatusOr<uint64> DataPiece::ToUint64() const { StatusOr<double> DataPiece::ToDouble() const { if (type_ == TYPE_FLOAT) { - return FloatingPointConvertAndCheck<double, float>(float_); + return FloatToDouble(float_); } if (type_ == TYPE_STRING) { if (str_ == "Infinity") return std::numeric_limits<double>::infinity(); if (str_ == "-Infinity") return -std::numeric_limits<double>::infinity(); if (str_ == "NaN") return std::numeric_limits<double>::quiet_NaN(); - return StringToNumber<double>(safe_strtod); + StatusOr<double> value = StringToNumber<double>(safe_strtod); + if (value.ok() && !MathLimits<double>::IsFinite(value.ValueOrDie())) { + // safe_strtod converts out-of-range values to +inf/-inf, but we want + // to report them as errors. + return InvalidArgument(StrCat("\"", str_, "\"")); + } else { + return value; + } } return GenericConvert<double>(); } StatusOr<float> DataPiece::ToFloat() const { if (type_ == TYPE_DOUBLE) { - return FloatingPointConvertAndCheck<float, double>(double_); + return DoubleToFloat(double_); } if (type_ == TYPE_STRING) { if (str_ == "Infinity") return std::numeric_limits<float>::infinity(); diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.cc b/src/google/protobuf/util/internal/default_value_objectwriter.cc index ac1ed9ab..1772219a 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.cc +++ b/src/google/protobuf/util/internal/default_value_objectwriter.cc @@ -190,7 +190,7 @@ void DefaultValueObjectWriter::RegisterFieldScrubCallBack( DefaultValueObjectWriter::Node::Node( const string& name, const google::protobuf::Type* type, NodeKind kind, - const DataPiece& data, bool is_placeholder, const vector<string>& path, + const DataPiece& data, bool is_placeholder, const std::vector<string>& path, bool suppress_empty_list, FieldScrubCallBack* field_scrub_callback) : name_(name), type_(type), @@ -310,7 +310,7 @@ void DefaultValueObjectWriter::Node::PopulateChildren( // This code is checking if the field to be added to the tree should be // scrubbed or not by calling the field_scrub_callback_ callback function. - vector<string> path; + std::vector<string> path; if (!path_.empty()) { path.insert(path.begin(), path_.begin(), path_.end()); } @@ -466,7 +466,7 @@ DataPiece DefaultValueObjectWriter::CreateDefaultDataPieceForField( DefaultValueObjectWriter* DefaultValueObjectWriter::StartObject( StringPiece name) { if (current_ == NULL) { - vector<string> path; + std::vector<string> path; root_.reset(new Node(name.ToString(), &type_, OBJECT, DataPiece::NullData(), false, path, suppress_empty_list_, field_scrub_callback_.get())); @@ -514,7 +514,7 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::EndObject() { DefaultValueObjectWriter* DefaultValueObjectWriter::StartList( StringPiece name) { if (current_ == NULL) { - vector<string> path; + std::vector<string> path; root_.reset(new Node(name.ToString(), &type_, LIST, DataPiece::NullData(), false, path, suppress_empty_list_, field_scrub_callback_.get())); diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h index 5f3b25f3..dc4551c9 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.h +++ b/src/google/protobuf/util/internal/default_value_objectwriter.h @@ -139,8 +139,9 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { class LIBPROTOBUF_EXPORT Node { public: Node(const string& name, const google::protobuf::Type* type, NodeKind kind, - const DataPiece& data, bool is_placeholder, const vector<string>& path, - bool suppress_empty_list, FieldScrubCallBack* field_scrub_callback); + const DataPiece& data, bool is_placeholder, + const std::vector<string>& path, bool suppress_empty_list, + FieldScrubCallBack* field_scrub_callback); virtual ~Node() { for (int i = 0; i < children_.size(); ++i) { delete children_[i]; @@ -166,7 +167,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // Accessors const string& name() const { return name_; } - const vector<string>& path() const { return path_; } + const std::vector<string>& path() const { return path_; } const google::protobuf::Type* type() const { return type_; } @@ -255,7 +256,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // google::protobuf::Type of the root message type. const google::protobuf::Type& type_; // Holds copies of strings passed to RenderString. - vector<string*> string_values_; + std::vector<string*> string_values_; // The current Node. Owned by its parents. Node* current_; diff --git a/src/google/protobuf/util/internal/field_mask_utility.cc b/src/google/protobuf/util/internal/field_mask_utility.cc index f0e8fc88..53b90fb0 100644 --- a/src/google/protobuf/util/internal/field_mask_utility.cc +++ b/src/google/protobuf/util/internal/field_mask_utility.cc @@ -112,7 +112,7 @@ string ConvertFieldMaskPath(const StringPiece path, util::Status DecodeCompactFieldMaskPaths(StringPiece paths, PathSinkCallback path_sink) { - stack<string> prefix; + std::stack<string> prefix; int length = paths.length(); int previous_position = 0; bool in_map_key = false; diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc index a8d48eff..2af4ad90 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.cc +++ b/src/google/protobuf/util/internal/json_stream_parser.cc @@ -45,6 +45,8 @@ #include <google/protobuf/util/internal/object_writer.h> #include <google/protobuf/util/internal/json_escaping.h> #include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/stubs/mathlimits.h> + namespace google { namespace protobuf { @@ -108,7 +110,8 @@ JsonStreamParser::JsonStreamParser(ObjectWriter* ow) string_open_(0), chunk_storage_(), coerce_to_utf8_(false), - allow_empty_null_(false) { + allow_empty_null_(false), + loose_float_number_conversion_(false) { // Initialize the stack with a single value to be parsed. stack_.push(VALUE); } @@ -532,6 +535,10 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) { if (!safe_strtod(number, &result->double_val)) { return ReportFailure("Unable to parse number."); } + if (!loose_float_number_conversion_ && + !MathLimits<double>::IsFinite(result->double_val)) { + return ReportFailure("Number exceeds the range of double."); + } result->type = NumberResult::DOUBLE; p_.remove_prefix(index); return util::Status::OK; diff --git a/src/google/protobuf/util/internal/json_stream_parser.h b/src/google/protobuf/util/internal/json_stream_parser.h index 78b35cc2..6b9d46ee 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.h +++ b/src/google/protobuf/util/internal/json_stream_parser.h @@ -255,6 +255,9 @@ class LIBPROTOBUF_EXPORT JsonStreamParser { // value. bool allow_empty_null_; + // Whether allows out-of-range floating point numbers or reject them. + bool loose_float_number_conversion_; + 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 eaa7e045..ca71ff24 100644 --- a/src/google/protobuf/util/internal/json_stream_parser_test.cc +++ b/src/google/protobuf/util/internal/json_stream_parser_test.cc @@ -89,7 +89,8 @@ class JsonStreamParserTest : public ::testing::Test { virtual ~JsonStreamParserTest() {} util::Status RunTest(StringPiece json, int split, bool coerce_utf8 = false, - bool allow_empty_null = false) { + bool allow_empty_null = false, + bool loose_float_number_conversion = false) { JsonStreamParser parser(&mock_); // Special case for split == length, test parsing one character at a time. @@ -120,9 +121,10 @@ class JsonStreamParserTest : public ::testing::Test { } 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); + bool allow_empty_null = false, + bool loose_float_number_conversion = false) { + util::Status result = RunTest(json, split, coerce_utf8, allow_empty_null, + loose_float_number_conversion); if (!result.ok()) { GOOGLE_LOG(WARNING) << result; } @@ -142,7 +144,7 @@ class JsonStreamParserTest : public ::testing::Test { #ifndef _MSC_VER // TODO(xiaofeng): We have to disable InSequence check for MSVC because it // causes stack overflow due to its use of a linked list that is desctructed - // recursively. + // recursively. ::testing::InSequence in_sequence_; #endif // !_MSC_VER MockObjectWriter mock_; @@ -322,8 +324,7 @@ TEST_F(JsonStreamParserTest, ObjectKeyTypes) { // - array containing primitive values (true, false, null, num, string) TEST_F(JsonStreamParserTest, ArrayPrimitiveValues) { - StringPiece str = - "[true, false, null, 'one', \"two\"]"; + StringPiece str = "[true, false, null, 'one', \"two\"]"; for (int i = 0; i <= str.length(); ++i) { ow_.StartList("") ->RenderBool("", true) @@ -710,17 +711,19 @@ TEST_F(JsonStreamParserTest, NegativeNumberTooBig) { } } -/* -TODO(sven): Fail parsing when parsing a double that is too large. - TEST_F(JsonStreamParserTest, DoubleTooBig) { - StringPiece str = "[184464073709551232321616.45]"; + StringPiece str = "[1.89769e+308]"; for (int i = 0; i <= str.length(); ++i) { ow_.StartList(""); - DoErrorTest(str, i, "Unable to parse number"); + DoErrorTest(str, i, "Number exceeds the range of double."); + } + str = "[-1.89769e+308]"; + for (int i = 0; i <= str.length(); ++i) { + ow_.StartList(""); + DoErrorTest(str, i, "Number exceeds the range of double."); } } -*/ + // invalid bare backslash. TEST_F(JsonStreamParserTest, UnfinishedEscape) { diff --git a/src/google/protobuf/util/internal/proto_writer.cc b/src/google/protobuf/util/internal/proto_writer.cc index 4dcf4c3b..8bebf2ab 100644 --- a/src/google/protobuf/util/internal/proto_writer.cc +++ b/src/google/protobuf/util/internal/proto_writer.cc @@ -354,7 +354,7 @@ ProtoWriter::ProtoElement* ProtoWriter::ProtoElement::pop() { if (!proto3_) { // Calls the registered error listener for any required field(s) not yet // seen. - for (set<const google::protobuf::Field*>::iterator it = + for (std::set<const google::protobuf::Field*>::iterator it = required_fields_.begin(); it != required_fields_.end(); ++it) { ow_->MissingField((*it)->name()); diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc index df0dbe1b..a970dc12 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource.cc @@ -85,7 +85,7 @@ const google::protobuf::EnumValue* FindEnumValueByNumber( const google::protobuf::Enum& tech_enum, int number); // Utility function to format nanos. -const string FormatNanos(uint32 nanos); +const string FormatNanos(uint32 nanos, bool with_trailing_zeros); StatusOr<string> MapKeyDefaultValueAsString( const google::protobuf::Field& field) { @@ -122,7 +122,8 @@ ProtoStreamObjectSource::ProtoStreamObjectSource( use_lower_camel_for_enums_(false), recursion_depth_(0), max_recursion_depth_(kDefaultMaxRecursionDepth), - render_unknown_fields_(false) { + render_unknown_fields_(false), + add_trailing_zeros_for_timestamp_and_duration_(false) { GOOGLE_LOG_IF(DFATAL, stream == NULL) << "Input stream is NULL."; } @@ -136,7 +137,8 @@ ProtoStreamObjectSource::ProtoStreamObjectSource( use_lower_camel_for_enums_(false), recursion_depth_(0), max_recursion_depth_(kDefaultMaxRecursionDepth), - render_unknown_fields_(false) { + render_unknown_fields_(false), + add_trailing_zeros_for_timestamp_and_duration_(false) { GOOGLE_LOG_IF(DFATAL, stream == NULL) << "Input stream is NULL."; } @@ -318,7 +320,7 @@ Status ProtoStreamObjectSource::RenderPacked( Status ProtoStreamObjectSource::RenderTimestamp( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - pair<int64, int32> p = os->ReadSecondsAndNanos(type); + std::pair<int64, int32> p = os->ReadSecondsAndNanos(type); int64 seconds = p.first; int32 nanos = p.second; if (seconds > kTimestampMaxSeconds || seconds < kTimestampMinSeconds) { @@ -342,7 +344,7 @@ Status ProtoStreamObjectSource::RenderTimestamp( Status ProtoStreamObjectSource::RenderDuration( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - pair<int64, int32> p = os->ReadSecondsAndNanos(type); + std::pair<int64, int32> p = os->ReadSecondsAndNanos(type); int64 seconds = p.first; int32 nanos = p.second; if (seconds > kDurationMaxSeconds || seconds < kDurationMinSeconds) { @@ -372,8 +374,10 @@ Status ProtoStreamObjectSource::RenderDuration( sign = "-"; nanos = -nanos; } - string formatted_duration = StringPrintf("%s%lld%ss", sign.c_str(), seconds, - FormatNanos(nanos).c_str()); + string formatted_duration = StringPrintf( + "%s%lld%ss", sign.c_str(), seconds, + FormatNanos(nanos, os->add_trailing_zeros_for_timestamp_and_duration_) + .c_str()); ow->RenderString(field_name, formatted_duration); return Status::OK; } @@ -1106,8 +1110,10 @@ 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 string FormatNanos(uint32 nanos, bool with_trailing_zeros) { + if (nanos == 0) { + return with_trailing_zeros ? ".000" : ""; + } const char* format = (nanos % 1000 != 0) ? "%.9f" : (nanos % 1000000 != 0) ? "%.6f" : "%.3f"; diff --git a/src/google/protobuf/util/internal/protostream_objectsource.h b/src/google/protobuf/util/internal/protostream_objectsource.h index adecfbd3..88ca652b 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.h +++ b/src/google/protobuf/util/internal/protostream_objectsource.h @@ -294,6 +294,9 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { // Whether to render unknown fields. bool render_unknown_fields_; + // Whether to add trailing zeros for timestamp and duration. + bool add_trailing_zeros_for_timestamp_and_duration_; + GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(ProtoStreamObjectSource); }; diff --git a/src/google/protobuf/util/internal/protostream_objectsource_test.cc b/src/google/protobuf/util/internal/protostream_objectsource_test.cc index cac28a06..bf29c17a 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource_test.cc @@ -101,7 +101,8 @@ class ProtostreamObjectSourceTest : helper_(GetParam()), mock_(), ow_(&mock_), - use_lower_camel_for_enums_(false) { + use_lower_camel_for_enums_(false), + add_trailing_zeros_(false) { helper_.ResetTypeInfo(Book::descriptor(), Proto3Message::descriptor()); } @@ -269,11 +270,14 @@ class ProtostreamObjectSourceTest void UseLowerCamelForEnums() { use_lower_camel_for_enums_ = true; } + void AddTrailingZeros() { add_trailing_zeros_ = true; } + testing::TypeInfoTestHelper helper_; ::testing::NiceMock<MockObjectWriter> mock_; ExpectingObjectWriter ow_; bool use_lower_camel_for_enums_; + bool add_trailing_zeros_; }; INSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest, @@ -1023,6 +1027,7 @@ TEST_P(ProtostreamObjectSourceTimestampTest, TimestampDurationDefaultValue) { DoTest(out, TimestampDuration::descriptor()); } + } // namespace converter } // namespace util } // namespace protobuf diff --git a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc index e7b38520..a9b15e68 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc @@ -113,13 +113,13 @@ class BaseProtoStreamObjectWriterTest listener_(), output_(new GrowingArrayByteSink(1000)), ow_() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(descriptor); ResetTypeInfo(descriptors); } explicit BaseProtoStreamObjectWriterTest( - vector<const Descriptor*> descriptors) + std::vector<const Descriptor*> descriptors) : helper_(GetParam()), listener_(), output_(new GrowingArrayByteSink(1000)), @@ -127,7 +127,7 @@ class BaseProtoStreamObjectWriterTest ResetTypeInfo(descriptors); } - void ResetTypeInfo(vector<const Descriptor*> descriptors) { + void ResetTypeInfo(std::vector<const Descriptor*> descriptors) { GOOGLE_CHECK(!descriptors.empty()) << "Must have at least one descriptor!"; helper_.ResetTypeInfo(descriptors); ow_.reset(helper_.NewProtoWriter(GetTypeUrl(descriptors[0]), output_.get(), @@ -135,7 +135,7 @@ class BaseProtoStreamObjectWriterTest } void ResetTypeInfo(const Descriptor* descriptor) { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(descriptor); ResetTypeInfo(descriptors); } @@ -1078,7 +1078,7 @@ class ProtoStreamObjectWriterTimestampDurationTest : public BaseProtoStreamObjectWriterTest { protected: ProtoStreamObjectWriterTimestampDurationTest() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(TimestampDuration::descriptor()); descriptors.push_back(google::protobuf::Timestamp::descriptor()); descriptors.push_back(google::protobuf::Duration::descriptor()); @@ -1473,7 +1473,7 @@ class ProtoStreamObjectWriterStructTest // Resets ProtoWriter with current set of options and other state. void ResetProtoWriter() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(StructType::descriptor()); descriptors.push_back(google::protobuf::Struct::descriptor()); ResetTypeInfo(descriptors); @@ -1664,7 +1664,7 @@ TEST_P(ProtoStreamObjectWriterMapTest, RepeatedMapKeyTest) { class ProtoStreamObjectWriterAnyTest : public BaseProtoStreamObjectWriterTest { protected: ProtoStreamObjectWriterAnyTest() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(AnyOut::descriptor()); descriptors.push_back(Book::descriptor()); descriptors.push_back(google::protobuf::Any::descriptor()); @@ -2308,7 +2308,7 @@ class ProtoStreamObjectWriterFieldMaskTest : public BaseProtoStreamObjectWriterTest { protected: ProtoStreamObjectWriterFieldMaskTest() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(FieldMaskTest::descriptor()); descriptors.push_back(google::protobuf::FieldMask::descriptor()); ResetTypeInfo(descriptors); @@ -2560,7 +2560,7 @@ class ProtoStreamObjectWriterWrappersTest : public BaseProtoStreamObjectWriterTest { protected: ProtoStreamObjectWriterWrappersTest() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(Int32Wrapper::descriptor()); descriptors.push_back(google::protobuf::Int32Value::descriptor()); ResetTypeInfo(descriptors); @@ -2583,7 +2583,7 @@ class ProtoStreamObjectWriterOneOfsTest : public BaseProtoStreamObjectWriterTest { protected: ProtoStreamObjectWriterOneOfsTest() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(OneOfsRequest::descriptor()); descriptors.push_back(google::protobuf::Struct::descriptor()); ResetTypeInfo(descriptors); diff --git a/src/google/protobuf/util/internal/type_info.cc b/src/google/protobuf/util/internal/type_info.cc index 00a8ee7a..17d58475 100644 --- a/src/google/protobuf/util/internal/type_info.cc +++ b/src/google/protobuf/util/internal/type_info.cc @@ -60,7 +60,8 @@ class TypeInfoForTypeResolver : public TypeInfo { virtual util::StatusOr<const google::protobuf::Type*> ResolveTypeUrl( StringPiece type_url) const { - map<StringPiece, StatusOrType>::iterator it = cached_types_.find(type_url); + std::map<StringPiece, StatusOrType>::iterator it = + cached_types_.find(type_url); if (it != cached_types_.end()) { return it->second; } @@ -85,7 +86,8 @@ class TypeInfoForTypeResolver : public TypeInfo { virtual const google::protobuf::Enum* GetEnumByTypeUrl( StringPiece type_url) const { - map<StringPiece, StatusOrEnum>::iterator it = cached_enums_.find(type_url); + std::map<StringPiece, StatusOrEnum>::iterator it = + cached_enums_.find(type_url); if (it != cached_enums_.end()) { return it->second.ok() ? it->second.ValueOrDie() : NULL; } @@ -123,8 +125,8 @@ class TypeInfoForTypeResolver : public TypeInfo { typedef util::StatusOr<const google::protobuf::Enum*> StatusOrEnum; template <typename T> - static void DeleteCachedTypes(map<StringPiece, T>* cached_types) { - for (typename map<StringPiece, T>::iterator it = cached_types->begin(); + static void DeleteCachedTypes(std::map<StringPiece, T>* cached_types) { + for (typename std::map<StringPiece, T>::iterator it = cached_types->begin(); it != cached_types->end(); ++it) { if (it->second.ok()) { delete it->second.ValueOrDie(); @@ -151,13 +153,13 @@ class TypeInfoForTypeResolver : public TypeInfo { // Stores string values that will be referenced by StringPieces in // cached_types_, cached_enums_ and camel_case_name_table_. - mutable set<string> string_storage_; + mutable std::set<string> string_storage_; - mutable map<StringPiece, StatusOrType> cached_types_; - mutable map<StringPiece, StatusOrEnum> cached_enums_; + mutable std::map<StringPiece, StatusOrType> cached_types_; + mutable std::map<StringPiece, StatusOrEnum> cached_enums_; - mutable set<const google::protobuf::Type*> indexed_types_; - mutable map<StringPiece, StringPiece> camel_case_name_table_; + mutable std::set<const google::protobuf::Type*> indexed_types_; + mutable std::map<StringPiece, StringPiece> camel_case_name_table_; }; } // namespace diff --git a/src/google/protobuf/util/internal/type_info_test_helper.cc b/src/google/protobuf/util/internal/type_info_test_helper.cc index 49e18ed0..737ba9e4 100644 --- a/src/google/protobuf/util/internal/type_info_test_helper.cc +++ b/src/google/protobuf/util/internal/type_info_test_helper.cc @@ -55,7 +55,7 @@ namespace testing { void TypeInfoTestHelper::ResetTypeInfo( - const vector<const Descriptor*>& descriptors) { + const std::vector<const Descriptor*>& descriptors) { switch (type_) { case USE_TYPE_RESOLVER: { const DescriptorPool* pool = descriptors[0]->file()->pool(); @@ -73,14 +73,14 @@ void TypeInfoTestHelper::ResetTypeInfo( } void TypeInfoTestHelper::ResetTypeInfo(const Descriptor* descriptor) { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(descriptor); ResetTypeInfo(descriptors); } void TypeInfoTestHelper::ResetTypeInfo(const Descriptor* descriptor1, const Descriptor* descriptor2) { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(descriptor1); descriptors.push_back(descriptor2); ResetTypeInfo(descriptors); diff --git a/src/google/protobuf/util/internal/type_info_test_helper.h b/src/google/protobuf/util/internal/type_info_test_helper.h index 1a279849..1a196715 100644 --- a/src/google/protobuf/util/internal/type_info_test_helper.h +++ b/src/google/protobuf/util/internal/type_info_test_helper.h @@ -64,7 +64,7 @@ class TypeInfoTestHelper { explicit TypeInfoTestHelper(TypeInfoSource type) : type_(type) {} // Creates a TypeInfo object for the given set of descriptors. - void ResetTypeInfo(const vector<const Descriptor*>& descriptors); + void ResetTypeInfo(const std::vector<const Descriptor*>& descriptors); // Convinent overloads. void ResetTypeInfo(const Descriptor* descriptor); diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc index 05328255..05759e85 100644 --- a/src/google/protobuf/util/internal/utility.cc +++ b/src/google/protobuf/util/internal/utility.cc @@ -30,6 +30,8 @@ #include <google/protobuf/util/internal/utility.h> +#include <algorithm> + #include <google/protobuf/stubs/callback.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/logging.h> @@ -41,8 +43,6 @@ #include <google/protobuf/stubs/map_util.h> #include <google/protobuf/stubs/mathlimits.h> -#include <algorithm> - namespace google { namespace protobuf { namespace util { @@ -324,7 +324,7 @@ string ToSnakeCase(StringPiece input) { return result; } -set<string>* well_known_types_ = NULL; +std::set<string>* well_known_types_ = NULL; GOOGLE_PROTOBUF_DECLARE_ONCE(well_known_types_init_); const char* well_known_types_name_array_[] = { "google.protobuf.Timestamp", "google.protobuf.Duration", @@ -337,7 +337,7 @@ const char* well_known_types_name_array_[] = { void DeleteWellKnownTypes() { delete well_known_types_; } void InitWellKnownTypes() { - well_known_types_ = new set<string>; + well_known_types_ = new std::set<string>; for (int i = 0; i < GOOGLE_ARRAYSIZE(well_known_types_name_array_); ++i) { well_known_types_->insert(well_known_types_name_array_[i]); } diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index 24ff5fd6..3ce779c9 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc @@ -251,11 +251,11 @@ TEST_F(JsonUtilTest, TestDynamicMessage) { EXPECT_EQ(ToJson(generated, options), ToJson(*message, options)); } -typedef pair<char*, int> Segment; +typedef std::pair<char*, int> Segment; // A ZeroCopyOutputStream that writes to multiple buffers. class SegmentedZeroCopyOutputStream : public io::ZeroCopyOutputStream { public: - explicit SegmentedZeroCopyOutputStream(list<Segment> segments) + explicit SegmentedZeroCopyOutputStream(std::list<Segment> segments) : segments_(segments), last_segment_(static_cast<char*>(NULL), 0), byte_count_(0) {} virtual bool Next(void** buffer, int* length) { @@ -281,7 +281,7 @@ class SegmentedZeroCopyOutputStream : public io::ZeroCopyOutputStream { virtual int64 ByteCount() const { return byte_count_; } private: - list<Segment> segments_; + std::list<Segment> segments_; Segment last_segment_; int64 byte_count_; }; @@ -299,7 +299,7 @@ TEST(ZeroCopyStreamByteSinkTest, TestAllInputOutputPatterns) { for (int split_pattern = 0; split_pattern < (1 << (kOutputBufferLength - 1)); split_pattern += kSkippedPatternCount) { // Split the buffer into small segments according to the split_pattern. - list<Segment> segments; + std::list<Segment> segments; int segment_start = 0; for (int i = 0; i < kOutputBufferLength - 1; ++i) { if (split_pattern & (1 << i)) { diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc index 328b40d8..203d8388 100644 --- a/src/google/protobuf/util/message_differencer.cc +++ b/src/google/protobuf/util/message_differencer.cc @@ -73,7 +73,7 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator public: MultipleFieldsMapKeyComparator( MessageDifferencer* message_differencer, - const vector<vector<const FieldDescriptor*> >& key_field_paths) + const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths) : message_differencer_(message_differencer), key_field_paths_(key_field_paths) { GOOGLE_CHECK(!key_field_paths_.empty()); @@ -85,14 +85,14 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator MessageDifferencer* message_differencer, const FieldDescriptor* key) : message_differencer_(message_differencer) { - vector<const FieldDescriptor*> key_field_path; + std::vector<const FieldDescriptor*> key_field_path; key_field_path.push_back(key); key_field_paths_.push_back(key_field_path); } virtual bool IsMatch( const Message& message1, const Message& message2, - const vector<SpecificField>& parent_fields) const { + const std::vector<SpecificField>& parent_fields) const { for (int i = 0; i < key_field_paths_.size(); ++i) { if (!IsMatchInternal(message1, message2, parent_fields, key_field_paths_[i], 0)) { @@ -105,11 +105,11 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator bool IsMatchInternal( const Message& message1, const Message& message2, - const vector<SpecificField>& parent_fields, - const vector<const FieldDescriptor*>& key_field_path, + const std::vector<SpecificField>& parent_fields, + const std::vector<const FieldDescriptor*>& key_field_path, int path_index) const { const FieldDescriptor* field = key_field_path[path_index]; - vector<SpecificField> current_parent_fields(parent_fields); + std::vector<SpecificField> current_parent_fields(parent_fields); if (path_index == key_field_path.size() - 1) { if (field->is_repeated()) { if (!message_differencer_->CompareRepeatedField( @@ -146,7 +146,7 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator } } MessageDifferencer* message_differencer_; - vector<vector<const FieldDescriptor*> > key_field_paths_; + std::vector<std::vector<const FieldDescriptor*> > key_field_paths_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MultipleFieldsMapKeyComparator); }; @@ -283,10 +283,10 @@ void MessageDifferencer::TreatAsMap(const FieldDescriptor* field, void MessageDifferencer::TreatAsMapWithMultipleFieldsAsKey( const FieldDescriptor* field, - const vector<const FieldDescriptor*>& key_fields) { - vector<vector<const FieldDescriptor*> > key_field_paths; + const std::vector<const FieldDescriptor*>& key_fields) { + std::vector<std::vector<const FieldDescriptor*> > key_field_paths; for (int i = 0; i < key_fields.size(); ++i) { - vector<const FieldDescriptor*> key_field_path; + std::vector<const FieldDescriptor*> key_field_path; key_field_path.push_back(key_fields[i]); key_field_paths.push_back(key_field_path); } @@ -295,14 +295,15 @@ void MessageDifferencer::TreatAsMapWithMultipleFieldsAsKey( void MessageDifferencer::TreatAsMapWithMultipleFieldPathsAsKey( const FieldDescriptor* field, - const vector<vector<const FieldDescriptor*> >& key_field_paths) { + const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths) { GOOGLE_CHECK(field->is_repeated()) << "Field must be repeated: " << field->full_name(); GOOGLE_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type()) << "Field has to be message type. Field name is: " << field->full_name(); for (int i = 0; i < key_field_paths.size(); ++i) { - const vector<const FieldDescriptor*>& key_field_path = key_field_paths[i]; + const std::vector<const FieldDescriptor*>& key_field_path = + key_field_paths[i]; for (int j = 0; j < key_field_path.size(); ++j) { const FieldDescriptor* parent_field = j == 0 ? field : key_field_path[j - 1]; @@ -390,7 +391,7 @@ bool MessageDifferencer::FieldBefore(const FieldDescriptor* field1, bool MessageDifferencer::Compare(const Message& message1, const Message& message2) { - vector<SpecificField> parent_fields; + std::vector<SpecificField> parent_fields; bool result = false; @@ -411,20 +412,20 @@ bool MessageDifferencer::Compare(const Message& message1, bool MessageDifferencer::CompareWithFields( const Message& message1, const Message& message2, - const vector<const FieldDescriptor*>& message1_fields_arg, - const vector<const FieldDescriptor*>& message2_fields_arg) { + const std::vector<const FieldDescriptor*>& message1_fields_arg, + const std::vector<const FieldDescriptor*>& message2_fields_arg) { if (message1.GetDescriptor() != message2.GetDescriptor()) { GOOGLE_LOG(DFATAL) << "Comparison between two messages with different " << "descriptors."; return false; } - vector<SpecificField> parent_fields; + std::vector<SpecificField> parent_fields; bool result = false; - vector<const FieldDescriptor*> message1_fields(message1_fields_arg); - vector<const FieldDescriptor*> message2_fields(message2_fields_arg); + std::vector<const FieldDescriptor*> message1_fields(message1_fields_arg); + std::vector<const FieldDescriptor*> message2_fields(message2_fields_arg); std::sort(message1_fields.begin(), message1_fields.end(), FieldBefore); std::sort(message2_fields.begin(), message2_fields.end(), FieldBefore); @@ -451,7 +452,7 @@ bool MessageDifferencer::CompareWithFields( bool MessageDifferencer::Compare( const Message& message1, const Message& message2, - vector<SpecificField>* parent_fields) { + std::vector<SpecificField>* parent_fields) { const Descriptor* descriptor1 = message1.GetDescriptor(); const Descriptor* descriptor2 = message2.GetDescriptor(); if (descriptor1 != descriptor2) { @@ -473,10 +474,10 @@ bool MessageDifferencer::Compare( const Reflection* reflection2 = message2.GetReflection(); // Retrieve all the set fields, including extensions. - vector<const FieldDescriptor*> message1_fields; + std::vector<const FieldDescriptor*> message1_fields; message1_fields.reserve(1 + message1.GetDescriptor()->field_count()); - vector<const FieldDescriptor*> message2_fields; + std::vector<const FieldDescriptor*> message2_fields; message2_fields.reserve(1 + message2.GetDescriptor()->field_count()); reflection1->ListFields(message1, &message1_fields); @@ -514,15 +515,15 @@ bool MessageDifferencer::Compare( bool MessageDifferencer::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) { if (scope_ == FULL) { if (message_field_comparison_ == EQUIVALENT) { // We need to merge the field lists of both messages (i.e. // we are merely checking for a difference in field values, // rather than the addition or deletion of fields). - vector<const FieldDescriptor*> fields_union; + std::vector<const FieldDescriptor*> fields_union; CombineFields(message1_fields, FULL, message2_fields, FULL, &fields_union); return CompareWithFieldsInternal(message1, message2, fields_union, @@ -544,7 +545,7 @@ bool MessageDifferencer::CompareRequestedFieldsUsingSettings( // but only the intersection for message2. This way, any fields // only present in message2 will be ignored, but any fields only // present in message1 will be marked as a difference. - vector<const FieldDescriptor*> fields_intersection; + std::vector<const FieldDescriptor*> fields_intersection; CombineFields(message1_fields, PARTIAL, message2_fields, PARTIAL, &fields_intersection); return CompareWithFieldsInternal(message1, message2, message1_fields, @@ -554,11 +555,11 @@ bool MessageDifferencer::CompareRequestedFieldsUsingSettings( } void MessageDifferencer::CombineFields( - const vector<const FieldDescriptor*>& fields1, + 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) { int index1 = 0; int index2 = 0; @@ -588,9 +589,9 @@ void MessageDifferencer::CombineFields( bool MessageDifferencer::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) { bool isDifferent = false; int field_index1 = 0; int field_index2 = 0; @@ -746,13 +747,12 @@ bool MessageDifferencer::CompareWithFieldsInternal( return !isDifferent; } -bool MessageDifferencer::IsMatch(const FieldDescriptor* repeated_field, - const MapKeyComparator* key_comparator, - const Message* message1, - const Message* message2, - const vector<SpecificField>& parent_fields, - int index1, int index2) { - vector<SpecificField> current_parent_fields(parent_fields); +bool MessageDifferencer::IsMatch( + const FieldDescriptor* repeated_field, + const MapKeyComparator* key_comparator, const Message* message1, + const Message* message2, const std::vector<SpecificField>& parent_fields, + int index1, int index2) { + std::vector<SpecificField> current_parent_fields(parent_fields); if (repeated_field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) { return CompareFieldValueUsingParentFields( *message1, *message2, repeated_field, index1, index2, @@ -792,7 +792,7 @@ bool MessageDifferencer::CompareRepeatedField( const Message& message1, const Message& message2, const FieldDescriptor* repeated_field, - vector<SpecificField>* parent_fields) { + std::vector<SpecificField>* parent_fields) { // the input FieldDescriptor is guaranteed to be repeated field. const Reflection* reflection1 = message1.GetReflection(); const Reflection* reflection2 = message2.GetReflection(); @@ -813,8 +813,8 @@ bool MessageDifferencer::CompareRepeatedField( // These two list are used for store the index of the correspondent // element in peer repeated field. - vector<int> match_list1; - vector<int> match_list2; + std::vector<int> match_list1; + std::vector<int> match_list2; // Try to match indices of the repeated fields. Return false if match fails // and there's no detailed report needed. @@ -899,7 +899,7 @@ bool MessageDifferencer::CompareFieldValue(const Message& message1, bool MessageDifferencer::CompareFieldValueUsingParentFields( const Message& message1, const Message& message2, const FieldDescriptor* field, int index1, int index2, - vector<SpecificField>* parent_fields) { + std::vector<SpecificField>* parent_fields) { FieldContext field_context(parent_fields); FieldComparator::ComparisonResult result = GetFieldComparisonResult( message1, message2, field, index1, index2, &field_context); @@ -938,7 +938,7 @@ bool MessageDifferencer::CompareFieldValueUsingParentFields( } bool MessageDifferencer::CheckPathChanged( - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { for (int i = 0; i < field_path.size(); ++i) { if (field_path[i].index != field_path[i].new_index) return true; } @@ -962,7 +962,7 @@ bool MessageDifferencer::IsIgnored( const Message& message1, const Message& message2, const FieldDescriptor* field, - const vector<SpecificField>& parent_fields) { + const std::vector<SpecificField>& parent_fields) { if (ignored_fields_.find(field) != ignored_fields_.end()) { return true; } @@ -977,7 +977,8 @@ bool MessageDifferencer::IsIgnored( bool MessageDifferencer::IsUnknownFieldIgnored( const Message& message1, const Message& message2, - const SpecificField& field, const vector<SpecificField>& parent_fields) { + const SpecificField& field, + const std::vector<SpecificField>& parent_fields) { for (int i = 0; i < ignore_criteria_.size(); ++i) { if (ignore_criteria_[i]->IsUnknownFieldIgnored(message1, message2, field, parent_fields)) { @@ -999,7 +1000,7 @@ const MessageDifferencer::MapKeyComparator* MessageDifferencer namespace { -typedef pair<int, const UnknownField*> IndexUnknownFieldPair; +typedef std::pair<int, const UnknownField*> IndexUnknownFieldPair; struct UnknownFieldOrdering { inline bool operator()(const IndexUnknownFieldPair& a, @@ -1050,7 +1051,7 @@ bool MessageDifferencer::CompareUnknownFields( const Message& message1, const Message& message2, const google::protobuf::UnknownFieldSet& unknown_field_set1, const google::protobuf::UnknownFieldSet& unknown_field_set2, - vector<SpecificField>* parent_field) { + std::vector<SpecificField>* parent_field) { // Ignore unknown fields in EQUIVALENT mode. if (message_field_comparison_ == EQUIVALENT) return true; @@ -1066,8 +1067,8 @@ bool MessageDifferencer::CompareUnknownFields( // two sets -- that is, differing values for the same tag. We use // IndexUnknownFieldPairs to keep track of the field's original index for // reporting purposes. - vector<IndexUnknownFieldPair> fields1; // unknown_field_set1, sorted - vector<IndexUnknownFieldPair> fields2; // unknown_field_set2, sorted + std::vector<IndexUnknownFieldPair> fields1; // unknown_field_set1, sorted + std::vector<IndexUnknownFieldPair> fields2; // unknown_field_set2, sorted fields1.reserve(unknown_field_set1.field_count()); fields2.reserve(unknown_field_set2.field_count()); @@ -1270,7 +1271,7 @@ class MaximumMatcher { // the x-th node on the right side is matched to y-th node on the left side. // match_list1[i] == -1 means the node is not matched. Same with match_list2. MaximumMatcher(int count1, int count2, NodeMatchCallback* callback, - vector<int>* match_list1, vector<int>* match_list2); + std::vector<int>* match_list1, std::vector<int>* match_list2); // Find a maximum match and return the number of matched node pairs. // If early_return is true, this method will return 0 immediately when it // finds that not all nodes on the left side can be matched. @@ -1282,21 +1283,21 @@ class MaximumMatcher { // Find an argumenting path starting from the node v on the left side. If a // path can be found, update match_list2_ to reflect the path and return // true. - bool FindArgumentPathDFS(int v, vector<bool>* visited); + bool FindArgumentPathDFS(int v, std::vector<bool>* visited); int count1_; int count2_; google::protobuf::scoped_ptr<NodeMatchCallback> match_callback_; - map<pair<int, int>, bool> cached_match_results_; - vector<int>* match_list1_; - vector<int>* match_list2_; + std::map<std::pair<int, int>, bool> cached_match_results_; + std::vector<int>* match_list1_; + std::vector<int>* match_list2_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MaximumMatcher); }; MaximumMatcher::MaximumMatcher(int count1, int count2, NodeMatchCallback* callback, - vector<int>* match_list1, - vector<int>* match_list2) + std::vector<int>* match_list1, + std::vector<int>* match_list2) : count1_(count1), count2_(count2), match_callback_(callback), match_list1_(match_list1), match_list2_(match_list2) { match_list1_->assign(count1, -1); @@ -1306,7 +1307,7 @@ MaximumMatcher::MaximumMatcher(int count1, int count2, int MaximumMatcher::FindMaximumMatch(bool early_return) { int result = 0; for (int i = 0; i < count1_; ++i) { - vector<bool> visited(count1_); + std::vector<bool> visited(count1_); if (FindArgumentPathDFS(i, &visited)) { ++result; } else if (early_return) { @@ -1324,8 +1325,9 @@ int MaximumMatcher::FindMaximumMatch(bool early_return) { } bool MaximumMatcher::Match(int left, int right) { - pair<int, int> p(left, right); - map<pair<int, int>, bool>::iterator it = cached_match_results_.find(p); + std::pair<int, int> p(left, right); + std::map<std::pair<int, int>, bool>::iterator it = + cached_match_results_.find(p); if (it != cached_match_results_.end()) { return it->second; } @@ -1333,7 +1335,7 @@ bool MaximumMatcher::Match(int left, int right) { return cached_match_results_[p]; } -bool MaximumMatcher::FindArgumentPathDFS(int v, vector<bool>* visited) { +bool MaximumMatcher::FindArgumentPathDFS(int v, std::vector<bool>* visited) { (*visited)[v] = true; // We try to match those un-matched nodes on the right side first. This is // the step that the navie greedy matching algorithm uses. In the best cases @@ -1369,9 +1371,9 @@ bool MessageDifferencer::MatchRepeatedFieldIndices( const Message& message1, const Message& message2, const FieldDescriptor* repeated_field, - const vector<SpecificField>& parent_fields, - vector<int>* match_list1, - vector<int>* match_list2) { + const std::vector<SpecificField>& parent_fields, + std::vector<int>* match_list1, + std::vector<int>* match_list2) { const int count1 = message1.GetReflection()->FieldSize(message1, repeated_field); const int count2 = @@ -1392,7 +1394,8 @@ bool MessageDifferencer::MatchRepeatedFieldIndices( // doesn't necessarily imply Compare(b, c). Therefore a naive greedy // algorithm will fail to find a maximum matching. // Here we use the argumenting path algorithm. - MaximumMatcher::NodeMatchCallback* callback = NewPermanentCallback( + MaximumMatcher::NodeMatchCallback* callback = + NewPermanentCallback( this, &MessageDifferencer::IsMatch, repeated_field, key_comparator, &message1, &message2, parent_fields); @@ -1485,7 +1488,7 @@ MessageDifferencer::StreamReporter::~StreamReporter() { } void MessageDifferencer::StreamReporter::PrintPath( - const vector<SpecificField>& field_path, bool left_side) { + const std::vector<SpecificField>& field_path, bool left_side) { for (int i = 0; i < field_path.size(); ++i) { if (i > 0) { printer_->Print("."); @@ -1514,7 +1517,7 @@ void MessageDifferencer::StreamReporter::PrintPath( void MessageDifferencer:: StreamReporter::PrintValue(const Message& message, - const vector<SpecificField>& field_path, + const std::vector<SpecificField>& field_path, bool left_side) { const SpecificField& specific_field = field_path.back(); const FieldDescriptor* field = specific_field.field; @@ -1587,7 +1590,7 @@ void MessageDifferencer::StreamReporter::Print(const string& str) { void MessageDifferencer::StreamReporter::ReportAdded( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { printer_->Print("added: "); PrintPath(field_path, false); printer_->Print(": "); @@ -1598,7 +1601,7 @@ void MessageDifferencer::StreamReporter::ReportAdded( void MessageDifferencer::StreamReporter::ReportDeleted( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { printer_->Print("deleted: "); PrintPath(field_path, true); printer_->Print(": "); @@ -1609,7 +1612,7 @@ void MessageDifferencer::StreamReporter::ReportDeleted( void MessageDifferencer::StreamReporter::ReportModified( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { if (!report_modified_aggregates_ && field_path.back().field == NULL) { if (field_path.back().unknown_field_type == UnknownField::TYPE_GROUP) { // Any changes to the subfields have already been printed. @@ -1639,7 +1642,7 @@ void MessageDifferencer::StreamReporter::ReportModified( void MessageDifferencer::StreamReporter::ReportMoved( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { printer_->Print("moved: "); PrintPath(field_path, true); printer_->Print(" -> "); @@ -1652,7 +1655,7 @@ void MessageDifferencer::StreamReporter::ReportMoved( void MessageDifferencer::StreamReporter::ReportMatched( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { printer_->Print("matched: "); PrintPath(field_path, true); if (CheckPathChanged(field_path)) { @@ -1667,7 +1670,7 @@ void MessageDifferencer::StreamReporter::ReportMatched( void MessageDifferencer::StreamReporter::ReportIgnored( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { printer_->Print("ignored: "); PrintPath(field_path, true); if (CheckPathChanged(field_path)) { @@ -1679,7 +1682,7 @@ void MessageDifferencer::StreamReporter::ReportIgnored( void MessageDifferencer::StreamReporter::ReportUnknownFieldIgnored( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { printer_->Print("ignored: "); PrintPath(field_path, true); if (CheckPathChanged(field_path)) { diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h index fde37cf9..d99223cb 100644 --- a/src/google/protobuf/util/message_differencer.h +++ b/src/google/protobuf/util/message_differencer.h @@ -821,7 +821,6 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { FieldSet ignored_fields_; - bool compare_unknown_fields_; bool report_matches_; string* output_string_; diff --git a/src/google/protobuf/util/message_differencer_unittest.cc b/src/google/protobuf/util/message_differencer_unittest.cc index ed43c512..30b27dba 100755 --- a/src/google/protobuf/util/message_differencer_unittest.cc +++ b/src/google/protobuf/util/message_differencer_unittest.cc @@ -66,7 +66,7 @@ namespace { const FieldDescriptor* GetFieldDescriptor( const Message& message, const string& field_name) { - vector<string> field_path = + std::vector<string> field_path = Split(field_name, ".", true); const Descriptor* descriptor = message.GetDescriptor(); const FieldDescriptor* field = NULL; @@ -790,8 +790,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsEqualityAllTest) { TestUtil::SetAllFields(&msg1); TestUtil::SetAllFields(&msg2); - vector<const FieldDescriptor*> fields1; - vector<const FieldDescriptor*> fields2; + std::vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields2; msg1.GetReflection()->ListFields(msg1, &fields1); msg2.GetReflection()->ListFields(msg2, &fields2); @@ -805,8 +805,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsInequalityAllTest) { TestUtil::SetAllFields(&msg1); - vector<const FieldDescriptor*> fields1; - vector<const FieldDescriptor*> fields2; + std::vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields2; msg1.GetReflection()->ListFields(msg1, &fields1); msg2.GetReflection()->ListFields(msg2, &fields2); @@ -820,7 +820,7 @@ TEST(MessageDifferencerTest, SpecifiedFieldsEmptyListAlwaysSucceeds) { TestUtil::SetAllFields(&msg1); - vector<const FieldDescriptor*> empty_fields; + std::vector<const FieldDescriptor*> empty_fields; util::MessageDifferencer differencer; EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2, @@ -835,7 +835,7 @@ TEST(MessageDifferencerTest, SpecifiedFieldsCompareWithSelf) { unittest::TestAllTypes msg1; TestUtil::SetAllFields(&msg1); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; msg1.GetReflection()->ListFields(msg1, &fields); util::MessageDifferencer differencer; @@ -843,7 +843,7 @@ TEST(MessageDifferencerTest, SpecifiedFieldsCompareWithSelf) { { // Compare with a subset of fields. - vector<const FieldDescriptor*> compare_fields; + std::vector<const FieldDescriptor*> compare_fields; for (int i = 0; i < fields.size(); ++i) { if (i % 2 == 0) { compare_fields.push_back(fields[i]); @@ -856,8 +856,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsCompareWithSelf) { // Specify a different set of fields to compare, even though we're using the // same message. This should fail, since we are explicitly saying that the // set of fields are different. - vector<const FieldDescriptor*> compare_fields1; - vector<const FieldDescriptor*> compare_fields2; + std::vector<const FieldDescriptor*> compare_fields1; + std::vector<const FieldDescriptor*> compare_fields2; for (int i = 0; i < fields.size(); ++i) { if (i % 2 == 0) { compare_fields1.push_back(fields[i]); @@ -880,8 +880,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsEqualityAllShuffledTest) { TestUtil::SetAllFields(&msg1); TestUtil::SetAllFields(&msg2); - vector<const FieldDescriptor*> fields1; - vector<const FieldDescriptor*> fields2; + std::vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields2; msg1.GetReflection()->ListFields(msg1, &fields1); msg2.GetReflection()->ListFields(msg2, &fields2); @@ -899,10 +899,10 @@ TEST(MessageDifferencerTest, SpecifiedFieldsSubsetEqualityTest) { TestUtil::SetAllFields(&msg1); TestUtil::SetAllFields(&msg2); - vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields1; msg1.GetReflection()->ListFields(msg1, &fields1); - vector<const FieldDescriptor*> compare_fields; + std::vector<const FieldDescriptor*> compare_fields; // Only compare the field descriptors with even indices. for (int i = 0; i < fields1.size(); ++i) { if (i % 2 == 0) { @@ -925,11 +925,11 @@ TEST(MessageDifferencerTest, TestUtil::SetAllFields(&msg1); TestUtil::SetAllFields(&msg2); - vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields1; const Reflection* reflection = msg1.GetReflection(); reflection->ListFields(msg1, &fields1); - vector<const FieldDescriptor*> compare_fields; + std::vector<const FieldDescriptor*> compare_fields; // Only compare the field descriptors with even indices. for (int i = 0; i < fields1.size(); ++i) { if (i % 2 == 0) { @@ -954,10 +954,10 @@ TEST(MessageDifferencerTest, SpecifiedFieldsDetectsDifferencesTest) { TestUtil::SetAllFields(&msg2); TestUtil::ModifyRepeatedFields(&msg2); - vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields1; msg1.GetReflection()->ListFields(msg1, &fields1); - vector<const FieldDescriptor*> compare_fields; + std::vector<const FieldDescriptor*> compare_fields; // Only compare the repeated field descriptors. for (int i = 0; i < fields1.size(); ++i) { if (fields1[i]->is_repeated()) { @@ -977,8 +977,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsEquivalenceAllTest) { TestUtil::SetAllFields(&msg1); TestUtil::SetAllFields(&msg2); - vector<const FieldDescriptor*> fields1; - vector<const FieldDescriptor*> fields2; + std::vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields2; msg1.GetReflection()->ListFields(msg1, &fields1); msg2.GetReflection()->ListFields(msg2, &fields2); @@ -1011,8 +1011,8 @@ TEST(MessageDifferencerTest, // actually doing something. msg2.set_optional_uint64(23); - vector<const FieldDescriptor*> fields1; - vector<const FieldDescriptor*> fields2; + std::vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields2; fields1.push_back(optional_int32_desc); fields1.push_back(default_int64_desc); @@ -1286,7 +1286,7 @@ TEST(MessageDifferencerTest, RepeatedFieldMapTest_MultipleFieldsAsKey) { util::MessageDifferencer differencer; differencer.TreatAsSet(GetFieldDescriptor(msg1, "item.ra")); EXPECT_FALSE(differencer.Compare(msg1, msg2)); - vector<const FieldDescriptor*> key_fields; + std::vector<const FieldDescriptor*> key_fields; key_fields.push_back(GetFieldDescriptor(msg1, "item.a")); key_fields.push_back(GetFieldDescriptor(msg1, "item.ra")); differencer.TreatAsMapWithMultipleFieldsAsKey( @@ -1363,11 +1363,11 @@ TEST(MessageDifferencerTest, RepeatedFieldMapTest_MultipleFieldPathsAsKey) { util::MessageDifferencer differencer; differencer.TreatAsSet(GetFieldDescriptor(msg1, "item.m.rc")); EXPECT_FALSE(differencer.Compare(msg1, msg2)); - vector<vector<const FieldDescriptor*> > key_field_paths; - vector<const FieldDescriptor*> key_field_path1; + std::vector<std::vector<const FieldDescriptor*> > key_field_paths; + std::vector<const FieldDescriptor*> key_field_path1; key_field_path1.push_back(GetFieldDescriptor(msg1, "item.m")); key_field_path1.push_back(GetFieldDescriptor(msg1, "item.m.a")); - vector<const FieldDescriptor*> key_field_path2; + std::vector<const FieldDescriptor*> key_field_path2; key_field_path2.push_back(GetFieldDescriptor(msg1, "item.m")); key_field_path2.push_back(GetFieldDescriptor(msg1, "item.m.rc")); key_field_paths.push_back(key_field_path1); @@ -1413,7 +1413,7 @@ TEST(MessageDifferencerTest, RepeatedFieldMapTest_IgnoredKeyFields) { item->set_b("world"); // Compare util::MessageDifferencer differencer; - vector<const FieldDescriptor*> key_fields; + std::vector<const FieldDescriptor*> key_fields; key_fields.push_back(GetFieldDescriptor(msg1, "item.a")); key_fields.push_back(GetFieldDescriptor(msg1, "item.ra")); differencer.TreatAsMapWithMultipleFieldsAsKey( @@ -1457,7 +1457,8 @@ class TestIgnorer : public util::MessageDifferencer::IgnoreCriteria { virtual bool IsIgnored( const Message& message1, const Message& message2, const FieldDescriptor* field, - const vector<util::MessageDifferencer::SpecificField>& parent_fields) { + const std::vector<util::MessageDifferencer::SpecificField>& + parent_fields) { string name = ""; for (int i = 0; i < parent_fields.size(); ++i) { name += parent_fields[i].field->name() + "."; @@ -1502,7 +1503,7 @@ class ValueProductMapKeyComparator typedef util::MessageDifferencer::SpecificField SpecificField; virtual bool IsMatch( const Message &message1, const Message &message2, - const vector<SpecificField>& parent_fields) const { + const std::vector<SpecificField>& parent_fields) const { const Reflection* reflection1 = message1.GetReflection(); const Reflection* reflection2 = message2.GetReflection(); // FieldDescriptor for item.ra @@ -1863,7 +1864,7 @@ TEST(MessageDifferencerTest, IgnoreField_TrumpsCompareWithFields) { const FieldDescriptor* c = GetFieldDescriptor(msg1, "c"); const FieldDescriptor* rc = GetFieldDescriptor(msg1, "rc"); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; fields.push_back(c); fields.push_back(rc); @@ -1899,12 +1900,12 @@ class ParentSavingFieldComparator : public util::FieldComparator { } } - vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields() { + std::vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields() { return parent_fields_; } private: - vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields_; + std::vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields_; }; // Tests if MessageDifferencer sends the parent fields in the FieldContext diff --git a/src/google/protobuf/util/type_resolver_util.cc b/src/google/protobuf/util/type_resolver_util.cc index 96393903..febaa41f 100644 --- a/src/google/protobuf/util/type_resolver_util.cc +++ b/src/google/protobuf/util/type_resolver_util.cc @@ -54,17 +54,6 @@ using util::Status; using util::error::INVALID_ARGUMENT; using util::error::NOT_FOUND; -bool SplitTypeUrl(const string& type_url, string* url_prefix, - string* message_name) { - size_t pos = type_url.find_last_of("/"); - if (pos == string::npos) { - return false; - } - *url_prefix = type_url.substr(0, pos); - *message_name = type_url.substr(pos + 1); - return true; -} - class DescriptorPoolTypeResolver : public TypeResolver { public: DescriptorPoolTypeResolver(const string& url_prefix, @@ -72,38 +61,27 @@ class DescriptorPoolTypeResolver : public TypeResolver { : url_prefix_(url_prefix), pool_(pool) {} Status ResolveMessageType(const string& type_url, Type* type) { - string url_prefix, message_name; - if (!SplitTypeUrl(type_url, &url_prefix, &message_name) || - url_prefix != url_prefix_) { - return Status(INVALID_ARGUMENT, - StrCat("Invalid type URL, type URLs must be of the form '", - url_prefix_, "/<typename>', got: ", type_url)); + string type_name; + Status status = ParseTypeUrl(type_url, &type_name); + if (!status.ok()) { + return status; } - if (url_prefix != url_prefix_) { - return Status(INVALID_ARGUMENT, - "Cannot resolve types from URL: " + url_prefix); - } - const Descriptor* descriptor = pool_->FindMessageTypeByName(message_name); + + const Descriptor* descriptor = pool_->FindMessageTypeByName(type_name); if (descriptor == NULL) { - return Status(NOT_FOUND, - "Invalid type URL, unknown type: " + message_name); + return Status(NOT_FOUND, "Invalid type URL, unknown type: " + type_name); } ConvertDescriptor(descriptor, type); return Status(); } Status ResolveEnumType(const string& type_url, Enum* enum_type) { - string url_prefix, type_name; - if (!SplitTypeUrl(type_url, &url_prefix, &type_name) || - url_prefix != url_prefix_) { - return Status(INVALID_ARGUMENT, - StrCat("Invalid type URL, type URLs must be of the form '", - url_prefix_, "/<typename>', got: ", type_url)); - } - if (url_prefix != url_prefix_) { - return Status(INVALID_ARGUMENT, - "Cannot resolve types from URL: " + url_prefix); + string type_name; + Status status = ParseTypeUrl(type_url, &type_name); + if (!status.ok()) { + return status; } + const EnumDescriptor* descriptor = pool_->FindEnumTypeByName(type_name); if (descriptor == NULL) { return Status(NOT_FOUND, "Invalid type URL, unknown type: " + type_name); @@ -203,6 +181,16 @@ class DescriptorPoolTypeResolver : public TypeResolver { return url_prefix_ + "/" + descriptor->full_name(); } + Status ParseTypeUrl(const string& type_url, string* type_name) { + if (type_url.substr(0, url_prefix_.size() + 1) != url_prefix_ + "/") { + return Status(INVALID_ARGUMENT, + StrCat("Invalid type URL, type URLs must be of the form '", + url_prefix_, "/<typename>', got: ", type_url)); + } + *type_name = type_url.substr(url_prefix_.size() + 1); + return Status(); + } + string DefaultValueAsString(const FieldDescriptor* descriptor) { switch (descriptor->cpp_type()) { case FieldDescriptor::CPPTYPE_INT32: diff --git a/src/google/protobuf/wire_format.cc b/src/google/protobuf/wire_format.cc index 147478be..88a1a234 100644 --- a/src/google/protobuf/wire_format.cc +++ b/src/google/protobuf/wire_format.cc @@ -792,7 +792,7 @@ void WireFormat::SerializeWithCachedSizes( const Reflection* message_reflection = message.GetReflection(); int expected_endpoint = output->ByteCount() + size; - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; message_reflection->ListFields(message, &fields); for (int i = 0; i < fields.size(); i++) { SerializeFieldWithCachedSizes(fields[i], message, output); @@ -970,7 +970,7 @@ size_t WireFormat::ByteSize(const Message& message) { size_t our_size = 0; - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; message_reflection->ListFields(message, &fields); for (int i = 0; i < fields.size(); i++) { our_size += FieldByteSize(fields[i], message); diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc index 5bed7af4..5a8857ed 100644 --- a/src/google/protobuf/wire_format_lite.cc +++ b/src/google/protobuf/wire_format_lite.cc @@ -467,7 +467,7 @@ void WireFormatLite::WriteGroupMaybeToArray(int field_number, uint8* target = output->GetDirectBufferForNBytesAndAdvance(size); if (target != NULL) { uint8* end = value.InternalSerializeWithCachedSizesToArray( - output->IsSerializationDeterminstic(), target); + output->IsSerializationDeterministic(), target); GOOGLE_DCHECK_EQ(end - target, size); } else { value.SerializeWithCachedSizes(output); @@ -484,7 +484,7 @@ void WireFormatLite::WriteMessageMaybeToArray(int field_number, uint8* target = output->GetDirectBufferForNBytesAndAdvance(size); if (target != NULL) { uint8* end = value.InternalSerializeWithCachedSizesToArray( - output->IsSerializationDeterminstic(), target); + output->IsSerializationDeterministic(), target); GOOGLE_DCHECK_EQ(end - target, size); } else { value.SerializeWithCachedSizes(output); diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index eeb3650f..cfd1688c 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -243,7 +243,15 @@ class LIBPROTOBUF_EXPORT WireFormatLite { #define input io::CodedInputStream* input_arg #define output io::CodedOutputStream* output_arg #define field_number int field_number_arg +#ifdef NDEBUG #define INL GOOGLE_ATTRIBUTE_ALWAYS_INLINE +#else +// Avoid excessive inlining in non-optimized builds. Without other optimizations +// the inlining is not going to provide benefits anyway and the huge resulting +// functions, especially in the proto-generated serialization functions, produce +// stack frames so large that many tests run into stack overflows (b/32192897). +#define INL +#endif // Read fields, not including tags. The assumption is that you already // read the tag to determine what field to read. diff --git a/src/google/protobuf/wire_format_lite_inl.h b/src/google/protobuf/wire_format_lite_inl.h index 1963fac8..0e46e994 100644 --- a/src/google/protobuf/wire_format_lite_inl.h +++ b/src/google/protobuf/wire_format_lite_inl.h @@ -274,8 +274,9 @@ inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive( // The number of bytes each type occupies on the wire. const int per_value_size = tag_size + sizeof(value); + // parentheses around (std::min) prevents macro expansion of min(...) int elements_available = - std::min(values->Capacity() - values->size(), size / per_value_size); + (std::min)(values->Capacity() - values->size(), size / per_value_size); int num_read = 0; while (num_read < elements_available && (buffer = io::CodedInputStream::ExpectTagFromArray( @@ -366,8 +367,9 @@ inline bool WireFormatLite::ReadPackedFixedSizePrimitive( if (bytes_limit == -1) { bytes_limit = input->BytesUntilLimit(); } else { + // parentheses around (std::min) prevents macro expansion of min(...) bytes_limit = - std::min(bytes_limit, static_cast<int64>(input->BytesUntilLimit())); + (std::min)(bytes_limit, static_cast<int64>(input->BytesUntilLimit())); } if (bytes_limit >= new_bytes) { // Fast-path that pre-allocates *values to the final size. @@ -862,7 +864,12 @@ inline size_t WireFormatLite::MessageSizeNoVirtual( } inline size_t WireFormatLite::LengthDelimitedSize(size_t length) { - return io::CodedOutputStream::VarintSize32(length) + length; + // The static_cast here prevents an error in certain compiler configurations + // but is not technically correct--if length is too large to fit in a uint32 + // then it will be silently truncated. We will need to fix this if we ever + // decide to start supporting serialized messages greater than 2 GiB in size. + return length + io::CodedOutputStream::VarintSize32( + static_cast<uint32>(length)); } } // namespace internal diff --git a/src/google/protobuf/wire_format_unittest.cc b/src/google/protobuf/wire_format_unittest.cc index 4e4add66..faf27b62 100644 --- a/src/google/protobuf/wire_format_unittest.cc +++ b/src/google/protobuf/wire_format_unittest.cc @@ -1138,7 +1138,7 @@ class Utf8ValidationTest : public ::testing::Test { TEST_F(Utf8ValidationTest, WriteInvalidUTF8String) { string wire_buffer; protobuf_unittest::OneString input; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; WriteMessage(kInvalidUTF8String, &input, &wire_buffer); @@ -1162,7 +1162,7 @@ TEST_F(Utf8ValidationTest, ReadInvalidUTF8String) { protobuf_unittest::OneString input; WriteMessage(kInvalidUTF8String, &input, &wire_buffer); protobuf_unittest::OneString output; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; ReadMessage(wire_buffer, &output); @@ -1185,7 +1185,7 @@ TEST_F(Utf8ValidationTest, ReadInvalidUTF8String) { TEST_F(Utf8ValidationTest, WriteValidUTF8String) { string wire_buffer; protobuf_unittest::OneString input; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; WriteMessage(kValidUTF8String, &input, &wire_buffer); @@ -1199,7 +1199,7 @@ TEST_F(Utf8ValidationTest, ReadValidUTF8String) { protobuf_unittest::OneString input; WriteMessage(kValidUTF8String, &input, &wire_buffer); protobuf_unittest::OneString output; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; ReadMessage(wire_buffer, &output); @@ -1213,7 +1213,7 @@ TEST_F(Utf8ValidationTest, ReadValidUTF8String) { TEST_F(Utf8ValidationTest, WriteArbitraryBytes) { string wire_buffer; protobuf_unittest::OneBytes input; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; WriteMessage(kInvalidUTF8String, &input, &wire_buffer); @@ -1227,7 +1227,7 @@ TEST_F(Utf8ValidationTest, ReadArbitraryBytes) { protobuf_unittest::OneBytes input; WriteMessage(kInvalidUTF8String, &input, &wire_buffer); protobuf_unittest::OneBytes output; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; ReadMessage(wire_buffer, &output); @@ -1245,7 +1245,7 @@ TEST_F(Utf8ValidationTest, ParseRepeatedString) { string wire_buffer = input.SerializeAsString(); protobuf_unittest::MoreString output; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; ReadMessage(wire_buffer, &output); @@ -1264,7 +1264,7 @@ TEST_F(Utf8ValidationTest, ParseRepeatedString) { TEST_F(Utf8ValidationTest, OldVerifyUTF8String) { string data(kInvalidUTF8String); - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; WireFormat::VerifyUTF8String(data.data(), data.size(), diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index 35364066..82a8d9e2 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -19,276 +19,189 @@ namespace google { namespace protobuf { +class DoubleValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> {}; +DoubleValueDefaultTypeInternal _DoubleValue_default_instance_; +class FloatValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FloatValue> {}; +FloatValueDefaultTypeInternal _FloatValue_default_instance_; +class Int64ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Int64Value> {}; +Int64ValueDefaultTypeInternal _Int64Value_default_instance_; +class UInt64ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> {}; +UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_; +class Int32ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Int32Value> {}; +Int32ValueDefaultTypeInternal _Int32Value_default_instance_; +class UInt32ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> {}; +UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_; +class BoolValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<BoolValue> {}; +BoolValueDefaultTypeInternal _BoolValue_default_instance_; +class StringValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<StringValue> {}; +StringValueDefaultTypeInternal _StringValue_default_instance_; +class BytesValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> {}; +BytesValueDefaultTypeInternal _BytesValue_default_instance_; namespace { -const ::google::protobuf::Descriptor* DoubleValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - DoubleValue_reflection_ = NULL; -const ::google::protobuf::Descriptor* FloatValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FloatValue_reflection_ = NULL; -const ::google::protobuf::Descriptor* Int64Value_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Int64Value_reflection_ = NULL; -const ::google::protobuf::Descriptor* UInt64Value_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - UInt64Value_reflection_ = NULL; -const ::google::protobuf::Descriptor* Int32Value_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Int32Value_reflection_ = NULL; -const ::google::protobuf::Descriptor* UInt32Value_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - UInt32Value_reflection_ = NULL; -const ::google::protobuf::Descriptor* BoolValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - BoolValue_reflection_ = NULL; -const ::google::protobuf::Descriptor* StringValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - StringValue_reflection_ = NULL; -const ::google::protobuf::Descriptor* BytesValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - BytesValue_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[9]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/wrappers.proto"); - GOOGLE_CHECK(file != NULL); - DoubleValue_descriptor_ = file->message_type(0); - static const int DoubleValue_offsets_[1] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, value_), - }; - DoubleValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - DoubleValue_descriptor_, - DoubleValue::internal_default_instance(), - DoubleValue_offsets_, - -1, - -1, - -1, - sizeof(DoubleValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, _internal_metadata_)); - FloatValue_descriptor_ = file->message_type(1); - static const int FloatValue_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, value_), - }; - FloatValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FloatValue_descriptor_, - FloatValue::internal_default_instance(), - FloatValue_offsets_, - -1, - -1, - -1, - sizeof(FloatValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, _internal_metadata_)); - Int64Value_descriptor_ = file->message_type(2); - static const int Int64Value_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, value_), - }; - Int64Value_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Int64Value_descriptor_, - Int64Value::internal_default_instance(), - Int64Value_offsets_, - -1, - -1, - -1, - sizeof(Int64Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, _internal_metadata_)); - UInt64Value_descriptor_ = file->message_type(3); - static const int UInt64Value_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, value_), - }; - UInt64Value_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - UInt64Value_descriptor_, - UInt64Value::internal_default_instance(), - UInt64Value_offsets_, - -1, - -1, - -1, - sizeof(UInt64Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, _internal_metadata_)); - Int32Value_descriptor_ = file->message_type(4); - static const int Int32Value_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, value_), - }; - Int32Value_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Int32Value_descriptor_, - Int32Value::internal_default_instance(), - Int32Value_offsets_, - -1, - -1, - -1, - sizeof(Int32Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, _internal_metadata_)); - UInt32Value_descriptor_ = file->message_type(5); - static const int UInt32Value_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, value_), - }; - UInt32Value_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - UInt32Value_descriptor_, - UInt32Value::internal_default_instance(), - UInt32Value_offsets_, - -1, - -1, - -1, - sizeof(UInt32Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, _internal_metadata_)); - BoolValue_descriptor_ = file->message_type(6); - static const int BoolValue_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, value_), - }; - BoolValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - BoolValue_descriptor_, - BoolValue::internal_default_instance(), - BoolValue_offsets_, - -1, - -1, - -1, - sizeof(BoolValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, _internal_metadata_)); - StringValue_descriptor_ = file->message_type(7); - static const int StringValue_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, value_), - }; - StringValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - StringValue_descriptor_, - StringValue::internal_default_instance(), - StringValue_offsets_, - -1, - -1, - -1, - sizeof(StringValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, _internal_metadata_)); - BytesValue_descriptor_ = file->message_type(8); - static const int BytesValue_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, value_), }; - BytesValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - BytesValue_descriptor_, - BytesValue::internal_default_instance(), - BytesValue_offsets_, - -1, - -1, - -1, - sizeof(BytesValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, _internal_metadata_)); -} + return offsets; +} + +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(DoubleValue)}, + { 5, -1, sizeof(FloatValue)}, + { 10, -1, sizeof(Int64Value)}, + { 15, -1, sizeof(UInt64Value)}, + { 20, -1, sizeof(Int32Value)}, + { 25, -1, sizeof(UInt32Value)}, + { 30, -1, sizeof(BoolValue)}, + { 35, -1, sizeof(StringValue)}, + { 40, -1, sizeof(BytesValue)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_DoubleValue_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_FloatValue_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Int64Value_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_UInt64Value_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Int32Value_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_UInt32Value_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_BoolValue_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_StringValue_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_BytesValue_default_instance_), NULL}, +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/wrappers.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DoubleValue_descriptor_, DoubleValue::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FloatValue_descriptor_, FloatValue::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Int64Value_descriptor_, Int64Value::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UInt64Value_descriptor_, UInt64Value::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Int32Value_descriptor_, Int32Value::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UInt32Value_descriptor_, UInt32Value::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - BoolValue_descriptor_, BoolValue::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - StringValue_descriptor_, StringValue::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - BytesValue_descriptor_, BytesValue::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 9); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto() { - DoubleValue_default_instance_.Shutdown(); - delete DoubleValue_reflection_; - FloatValue_default_instance_.Shutdown(); - delete FloatValue_reflection_; - Int64Value_default_instance_.Shutdown(); - delete Int64Value_reflection_; - UInt64Value_default_instance_.Shutdown(); - delete UInt64Value_reflection_; - Int32Value_default_instance_.Shutdown(); - delete Int32Value_reflection_; - UInt32Value_default_instance_.Shutdown(); - delete UInt32Value_reflection_; - BoolValue_default_instance_.Shutdown(); - delete BoolValue_reflection_; - StringValue_default_instance_.Shutdown(); - delete StringValue_reflection_; - BytesValue_default_instance_.Shutdown(); - delete BytesValue_reflection_; + _DoubleValue_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; + _FloatValue_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; + _Int64Value_default_instance_.Shutdown(); + delete file_level_metadata[2].reflection; + _UInt64Value_default_instance_.Shutdown(); + delete file_level_metadata[3].reflection; + _Int32Value_default_instance_.Shutdown(); + delete file_level_metadata[4].reflection; + _UInt32Value_default_instance_.Shutdown(); + delete file_level_metadata[5].reflection; + _BoolValue_default_instance_.Shutdown(); + delete file_level_metadata[6].reflection; + _StringValue_default_instance_.Shutdown(); + delete file_level_metadata[7].reflection; + _BytesValue_default_instance_.Shutdown(); + delete file_level_metadata[8].reflection; } 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_); + ::google::protobuf::internal::InitProtobufDefaults(); + _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(); + _StringValue_default_instance_.DefaultConstruct(); + _BytesValue_default_instance_.DefaultConstruct(); +} + void protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&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(); + static const char descriptor[] = { + "\n\036google/protobuf/wrappers.proto\022\017google" + ".protobuf\"\034\n\013DoubleValue\022\r\n\005value\030\001 \001(\001\"" + "\033\n\nFloatValue\022\r\n\005value\030\001 \001(\002\"\033\n\nInt64Val" + "ue\022\r\n\005value\030\001 \001(\003\"\034\n\013UInt64Value\022\r\n\005valu" + "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|\n\023com" + ".google.protobufB\rWrappersProtoP\001Z*githu" + "b.com/golang/protobuf/ptypes/wrappers\370\001\001" + "\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb" + "\006proto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\036google/protobuf/wrappers.proto\022\017google" - ".protobuf\"\034\n\013DoubleValue\022\r\n\005value\030\001 \001(\001\"" - "\033\n\nFloatValue\022\r\n\005value\030\001 \001(\002\"\033\n\nInt64Val" - "ue\022\r\n\005value\030\001 \001(\003\"\034\n\013UInt64Value\022\r\n\005valu" - "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|\n\023com" - ".google.protobufB\rWrappersProtoP\001Z*githu" - "b.com/golang/protobuf/ptypes/wrappers\370\001\001" - "\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb" - "\006proto3", 447); + descriptor, 447); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/wrappers.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto); @@ -306,16 +219,6 @@ 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 @@ -324,7 +227,9 @@ const int DoubleValue::kValueFieldNumber; DoubleValue::DoubleValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DoubleValue) } @@ -338,15 +243,12 @@ DoubleValue::DoubleValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.DoubleValue) } - -void DoubleValue::InitAsDefaultInstance() { -} - DoubleValue::DoubleValue(const DoubleValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.DoubleValue) } @@ -381,7 +283,7 @@ void DoubleValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* DoubleValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return DoubleValue_descriptor_; + return file_level_metadata[0].descriptor; } const DoubleValue& DoubleValue::default_instance() { @@ -389,8 +291,6 @@ const DoubleValue& DoubleValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> DoubleValue_default_instance_; - DoubleValue* DoubleValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<DoubleValue>(arena); } @@ -406,13 +306,13 @@ bool DoubleValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.DoubleValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional double value = 1; + // double value = 1; case 1: { - if (tag == 9) { + if (tag == 9u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -420,7 +320,6 @@ bool DoubleValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -448,7 +347,7 @@ failure: void DoubleValue::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.DoubleValue) - // optional double value = 1; + // double value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->value(), output); } @@ -460,7 +359,7 @@ void DoubleValue::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DoubleValue) - // optional double value = 1; + // double value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->value(), target); } @@ -473,7 +372,7 @@ size_t DoubleValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DoubleValue) size_t total_size = 0; - // optional double value = 1; + // double value = 1; if (this->value() != 0) { total_size += 1 + 8; } @@ -487,7 +386,7 @@ size_t DoubleValue::ByteSizeLong() const { void DoubleValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DoubleValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const DoubleValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const DoubleValue>( &from); @@ -496,21 +395,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void DoubleValue::MergeFrom(const DoubleValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DoubleValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void DoubleValue::UnsafeMergeFrom(const DoubleValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -527,11 +419,10 @@ void DoubleValue::CopyFrom(const DoubleValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DoubleValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool DoubleValue::IsInitialized() const { - return true; } @@ -540,10 +431,13 @@ void DoubleValue::Swap(DoubleValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - DoubleValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + DoubleValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void DoubleValue::UnsafeArenaSwap(DoubleValue* other) { @@ -553,22 +447,18 @@ void DoubleValue::UnsafeArenaSwap(DoubleValue* other) { } void DoubleValue::InternalSwap(DoubleValue* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata DoubleValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DoubleValue_descriptor_; - metadata.reflection = DoubleValue_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // DoubleValue -// optional double value = 1; +// double value = 1; void DoubleValue::clear_value() { value_ = 0; } @@ -582,9 +472,6 @@ void DoubleValue::set_value(double value) { // @@protoc_insertion_point(field_set:google.protobuf.DoubleValue.value) } -inline const DoubleValue* DoubleValue::internal_default_instance() { - return &DoubleValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -595,7 +482,9 @@ const int FloatValue::kValueFieldNumber; FloatValue::FloatValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FloatValue) } @@ -609,15 +498,12 @@ FloatValue::FloatValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.FloatValue) } - -void FloatValue::InitAsDefaultInstance() { -} - FloatValue::FloatValue(const FloatValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.FloatValue) } @@ -652,7 +538,7 @@ void FloatValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FloatValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return FloatValue_descriptor_; + return file_level_metadata[1].descriptor; } const FloatValue& FloatValue::default_instance() { @@ -660,8 +546,6 @@ const FloatValue& FloatValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FloatValue> FloatValue_default_instance_; - FloatValue* FloatValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<FloatValue>(arena); } @@ -677,13 +561,13 @@ bool FloatValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FloatValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional float value = 1; + // float value = 1; case 1: { - if (tag == 13) { + if (tag == 13u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( @@ -691,7 +575,6 @@ bool FloatValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -719,7 +602,7 @@ failure: void FloatValue::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.FloatValue) - // optional float value = 1; + // float value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->value(), output); } @@ -731,7 +614,7 @@ void FloatValue::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FloatValue) - // optional float value = 1; + // float value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->value(), target); } @@ -744,7 +627,7 @@ size_t FloatValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FloatValue) size_t total_size = 0; - // optional float value = 1; + // float value = 1; if (this->value() != 0) { total_size += 1 + 4; } @@ -758,7 +641,7 @@ size_t FloatValue::ByteSizeLong() const { void FloatValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FloatValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FloatValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const FloatValue>( &from); @@ -767,21 +650,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FloatValue::MergeFrom(const FloatValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FloatValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void FloatValue::UnsafeMergeFrom(const FloatValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -798,11 +674,10 @@ void FloatValue::CopyFrom(const FloatValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FloatValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FloatValue::IsInitialized() const { - return true; } @@ -811,10 +686,13 @@ void FloatValue::Swap(FloatValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - FloatValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + FloatValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void FloatValue::UnsafeArenaSwap(FloatValue* other) { @@ -824,22 +702,18 @@ void FloatValue::UnsafeArenaSwap(FloatValue* other) { } void FloatValue::InternalSwap(FloatValue* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata FloatValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FloatValue_descriptor_; - metadata.reflection = FloatValue_reflection_; - return metadata; + return file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // FloatValue -// optional float value = 1; +// float value = 1; void FloatValue::clear_value() { value_ = 0; } @@ -853,9 +727,6 @@ void FloatValue::set_value(float value) { // @@protoc_insertion_point(field_set:google.protobuf.FloatValue.value) } -inline const FloatValue* FloatValue::internal_default_instance() { - return &FloatValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -866,7 +737,9 @@ const int Int64Value::kValueFieldNumber; Int64Value::Int64Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Int64Value) } @@ -880,15 +753,12 @@ Int64Value::Int64Value(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Int64Value) } - -void Int64Value::InitAsDefaultInstance() { -} - Int64Value::Int64Value(const Int64Value& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Int64Value) } @@ -923,7 +793,7 @@ void Int64Value::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Int64Value::descriptor() { protobuf_AssignDescriptorsOnce(); - return Int64Value_descriptor_; + return file_level_metadata[2].descriptor; } const Int64Value& Int64Value::default_instance() { @@ -931,8 +801,6 @@ const Int64Value& Int64Value::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Int64Value> Int64Value_default_instance_; - Int64Value* Int64Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Int64Value>(arena); } @@ -948,13 +816,13 @@ bool Int64Value::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Int64Value) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional int64 value = 1; + // int64 value = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -962,7 +830,6 @@ bool Int64Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -990,7 +857,7 @@ failure: void Int64Value::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Int64Value) - // optional int64 value = 1; + // int64 value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->value(), output); } @@ -1002,7 +869,7 @@ void Int64Value::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int64Value) - // optional int64 value = 1; + // int64 value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->value(), target); } @@ -1015,7 +882,7 @@ size_t Int64Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int64Value) size_t total_size = 0; - // optional int64 value = 1; + // int64 value = 1; if (this->value() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int64Size( @@ -1031,7 +898,7 @@ size_t Int64Value::ByteSizeLong() const { void Int64Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Int64Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Int64Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const Int64Value>( &from); @@ -1040,21 +907,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Int64Value::MergeFrom(const Int64Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int64Value) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Int64Value::UnsafeMergeFrom(const Int64Value& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -1071,11 +931,10 @@ void Int64Value::CopyFrom(const Int64Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Int64Value) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Int64Value::IsInitialized() const { - return true; } @@ -1084,10 +943,13 @@ void Int64Value::Swap(Int64Value* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Int64Value temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Int64Value* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Int64Value::UnsafeArenaSwap(Int64Value* other) { @@ -1097,22 +959,18 @@ void Int64Value::UnsafeArenaSwap(Int64Value* other) { } void Int64Value::InternalSwap(Int64Value* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Int64Value::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Int64Value_descriptor_; - metadata.reflection = Int64Value_reflection_; - return metadata; + return file_level_metadata[2]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Int64Value -// optional int64 value = 1; +// int64 value = 1; void Int64Value::clear_value() { value_ = GOOGLE_LONGLONG(0); } @@ -1126,9 +984,6 @@ void Int64Value::set_value(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:google.protobuf.Int64Value.value) } -inline const Int64Value* Int64Value::internal_default_instance() { - return &Int64Value_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1139,7 +994,9 @@ const int UInt64Value::kValueFieldNumber; UInt64Value::UInt64Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UInt64Value) } @@ -1153,15 +1010,12 @@ UInt64Value::UInt64Value(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt64Value) } - -void UInt64Value::InitAsDefaultInstance() { -} - UInt64Value::UInt64Value(const UInt64Value& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UInt64Value) } @@ -1196,7 +1050,7 @@ void UInt64Value::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* UInt64Value::descriptor() { protobuf_AssignDescriptorsOnce(); - return UInt64Value_descriptor_; + return file_level_metadata[3].descriptor; } const UInt64Value& UInt64Value::default_instance() { @@ -1204,8 +1058,6 @@ const UInt64Value& UInt64Value::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> UInt64Value_default_instance_; - UInt64Value* UInt64Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<UInt64Value>(arena); } @@ -1221,13 +1073,13 @@ bool UInt64Value::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.UInt64Value) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional uint64 value = 1; + // uint64 value = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( @@ -1235,7 +1087,6 @@ bool UInt64Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1263,7 +1114,7 @@ failure: void UInt64Value::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.UInt64Value) - // optional uint64 value = 1; + // uint64 value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->value(), output); } @@ -1275,7 +1126,7 @@ void UInt64Value::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt64Value) - // optional uint64 value = 1; + // uint64 value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(1, this->value(), target); } @@ -1288,7 +1139,7 @@ size_t UInt64Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt64Value) size_t total_size = 0; - // optional uint64 value = 1; + // uint64 value = 1; if (this->value() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt64Size( @@ -1304,7 +1155,7 @@ size_t UInt64Value::ByteSizeLong() const { void UInt64Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UInt64Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const UInt64Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const UInt64Value>( &from); @@ -1313,21 +1164,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void UInt64Value::MergeFrom(const UInt64Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt64Value) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void UInt64Value::UnsafeMergeFrom(const UInt64Value& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -1344,11 +1188,10 @@ void UInt64Value::CopyFrom(const UInt64Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UInt64Value) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool UInt64Value::IsInitialized() const { - return true; } @@ -1357,10 +1200,13 @@ void UInt64Value::Swap(UInt64Value* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - UInt64Value temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + UInt64Value* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void UInt64Value::UnsafeArenaSwap(UInt64Value* other) { @@ -1370,22 +1216,18 @@ void UInt64Value::UnsafeArenaSwap(UInt64Value* other) { } void UInt64Value::InternalSwap(UInt64Value* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata UInt64Value::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = UInt64Value_descriptor_; - metadata.reflection = UInt64Value_reflection_; - return metadata; + return file_level_metadata[3]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // UInt64Value -// optional uint64 value = 1; +// uint64 value = 1; void UInt64Value::clear_value() { value_ = GOOGLE_ULONGLONG(0); } @@ -1399,9 +1241,6 @@ void UInt64Value::set_value(::google::protobuf::uint64 value) { // @@protoc_insertion_point(field_set:google.protobuf.UInt64Value.value) } -inline const UInt64Value* UInt64Value::internal_default_instance() { - return &UInt64Value_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1412,7 +1251,9 @@ const int Int32Value::kValueFieldNumber; Int32Value::Int32Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Int32Value) } @@ -1426,15 +1267,12 @@ Int32Value::Int32Value(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Int32Value) } - -void Int32Value::InitAsDefaultInstance() { -} - Int32Value::Int32Value(const Int32Value& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Int32Value) } @@ -1469,7 +1307,7 @@ void Int32Value::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Int32Value::descriptor() { protobuf_AssignDescriptorsOnce(); - return Int32Value_descriptor_; + return file_level_metadata[4].descriptor; } const Int32Value& Int32Value::default_instance() { @@ -1477,8 +1315,6 @@ const Int32Value& Int32Value::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Int32Value> Int32Value_default_instance_; - Int32Value* Int32Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Int32Value>(arena); } @@ -1494,13 +1330,13 @@ bool Int32Value::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Int32Value) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional int32 value = 1; + // int32 value = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1508,7 +1344,6 @@ bool Int32Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1536,7 +1371,7 @@ failure: void Int32Value::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Int32Value) - // optional int32 value = 1; + // int32 value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->value(), output); } @@ -1548,7 +1383,7 @@ void Int32Value::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int32Value) - // optional int32 value = 1; + // int32 value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->value(), target); } @@ -1561,7 +1396,7 @@ size_t Int32Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int32Value) size_t total_size = 0; - // optional int32 value = 1; + // int32 value = 1; if (this->value() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( @@ -1577,7 +1412,7 @@ size_t Int32Value::ByteSizeLong() const { void Int32Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Int32Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Int32Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const Int32Value>( &from); @@ -1586,21 +1421,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Int32Value::MergeFrom(const Int32Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int32Value) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Int32Value::UnsafeMergeFrom(const Int32Value& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -1617,11 +1445,10 @@ void Int32Value::CopyFrom(const Int32Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Int32Value) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Int32Value::IsInitialized() const { - return true; } @@ -1630,10 +1457,13 @@ void Int32Value::Swap(Int32Value* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Int32Value temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Int32Value* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Int32Value::UnsafeArenaSwap(Int32Value* other) { @@ -1643,22 +1473,18 @@ void Int32Value::UnsafeArenaSwap(Int32Value* other) { } void Int32Value::InternalSwap(Int32Value* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Int32Value::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Int32Value_descriptor_; - metadata.reflection = Int32Value_reflection_; - return metadata; + return file_level_metadata[4]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Int32Value -// optional int32 value = 1; +// int32 value = 1; void Int32Value::clear_value() { value_ = 0; } @@ -1672,9 +1498,6 @@ void Int32Value::set_value(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Int32Value.value) } -inline const Int32Value* Int32Value::internal_default_instance() { - return &Int32Value_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1685,7 +1508,9 @@ const int UInt32Value::kValueFieldNumber; UInt32Value::UInt32Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UInt32Value) } @@ -1699,15 +1524,12 @@ UInt32Value::UInt32Value(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt32Value) } - -void UInt32Value::InitAsDefaultInstance() { -} - UInt32Value::UInt32Value(const UInt32Value& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UInt32Value) } @@ -1742,7 +1564,7 @@ void UInt32Value::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* UInt32Value::descriptor() { protobuf_AssignDescriptorsOnce(); - return UInt32Value_descriptor_; + return file_level_metadata[5].descriptor; } const UInt32Value& UInt32Value::default_instance() { @@ -1750,8 +1572,6 @@ const UInt32Value& UInt32Value::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> UInt32Value_default_instance_; - UInt32Value* UInt32Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<UInt32Value>(arena); } @@ -1767,13 +1587,13 @@ bool UInt32Value::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.UInt32Value) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional uint32 value = 1; + // uint32 value = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( @@ -1781,7 +1601,6 @@ bool UInt32Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1809,7 +1628,7 @@ failure: void UInt32Value::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.UInt32Value) - // optional uint32 value = 1; + // uint32 value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->value(), output); } @@ -1821,7 +1640,7 @@ void UInt32Value::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt32Value) - // optional uint32 value = 1; + // uint32 value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->value(), target); } @@ -1834,7 +1653,7 @@ size_t UInt32Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt32Value) size_t total_size = 0; - // optional uint32 value = 1; + // uint32 value = 1; if (this->value() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( @@ -1850,7 +1669,7 @@ size_t UInt32Value::ByteSizeLong() const { void UInt32Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UInt32Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const UInt32Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const UInt32Value>( &from); @@ -1859,21 +1678,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void UInt32Value::MergeFrom(const UInt32Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt32Value) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void UInt32Value::UnsafeMergeFrom(const UInt32Value& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -1890,11 +1702,10 @@ void UInt32Value::CopyFrom(const UInt32Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UInt32Value) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool UInt32Value::IsInitialized() const { - return true; } @@ -1903,10 +1714,13 @@ void UInt32Value::Swap(UInt32Value* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - UInt32Value temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + UInt32Value* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void UInt32Value::UnsafeArenaSwap(UInt32Value* other) { @@ -1916,22 +1730,18 @@ void UInt32Value::UnsafeArenaSwap(UInt32Value* other) { } void UInt32Value::InternalSwap(UInt32Value* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata UInt32Value::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = UInt32Value_descriptor_; - metadata.reflection = UInt32Value_reflection_; - return metadata; + return file_level_metadata[5]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // UInt32Value -// optional uint32 value = 1; +// uint32 value = 1; void UInt32Value::clear_value() { value_ = 0u; } @@ -1945,9 +1755,6 @@ void UInt32Value::set_value(::google::protobuf::uint32 value) { // @@protoc_insertion_point(field_set:google.protobuf.UInt32Value.value) } -inline const UInt32Value* UInt32Value::internal_default_instance() { - return &UInt32Value_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1958,7 +1765,9 @@ const int BoolValue::kValueFieldNumber; BoolValue::BoolValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.BoolValue) } @@ -1972,15 +1781,12 @@ BoolValue::BoolValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.BoolValue) } - -void BoolValue::InitAsDefaultInstance() { -} - BoolValue::BoolValue(const BoolValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.BoolValue) } @@ -2015,7 +1821,7 @@ void BoolValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* BoolValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return BoolValue_descriptor_; + return file_level_metadata[6].descriptor; } const BoolValue& BoolValue::default_instance() { @@ -2023,8 +1829,6 @@ const BoolValue& BoolValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<BoolValue> BoolValue_default_instance_; - BoolValue* BoolValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<BoolValue>(arena); } @@ -2040,13 +1844,13 @@ bool BoolValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.BoolValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional bool value = 1; + // bool value = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -2054,7 +1858,6 @@ bool BoolValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2082,7 +1885,7 @@ failure: void BoolValue::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.BoolValue) - // optional bool value = 1; + // bool value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->value(), output); } @@ -2094,7 +1897,7 @@ void BoolValue::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BoolValue) - // optional bool value = 1; + // bool value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->value(), target); } @@ -2107,7 +1910,7 @@ size_t BoolValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.BoolValue) size_t total_size = 0; - // optional bool value = 1; + // bool value = 1; if (this->value() != 0) { total_size += 1 + 1; } @@ -2121,7 +1924,7 @@ size_t BoolValue::ByteSizeLong() const { void BoolValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.BoolValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const BoolValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const BoolValue>( &from); @@ -2130,21 +1933,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void BoolValue::MergeFrom(const BoolValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BoolValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void BoolValue::UnsafeMergeFrom(const BoolValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -2161,11 +1957,10 @@ void BoolValue::CopyFrom(const BoolValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.BoolValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool BoolValue::IsInitialized() const { - return true; } @@ -2174,10 +1969,13 @@ void BoolValue::Swap(BoolValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - BoolValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + BoolValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void BoolValue::UnsafeArenaSwap(BoolValue* other) { @@ -2187,22 +1985,18 @@ void BoolValue::UnsafeArenaSwap(BoolValue* other) { } void BoolValue::InternalSwap(BoolValue* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata BoolValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = BoolValue_descriptor_; - metadata.reflection = BoolValue_reflection_; - return metadata; + return file_level_metadata[6]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // BoolValue -// optional bool value = 1; +// bool value = 1; void BoolValue::clear_value() { value_ = false; } @@ -2216,9 +2010,6 @@ void BoolValue::set_value(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.BoolValue.value) } -inline const BoolValue* BoolValue::internal_default_instance() { - return &BoolValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -2229,7 +2020,9 @@ const int StringValue::kValueFieldNumber; StringValue::StringValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.StringValue) } @@ -2243,15 +2036,16 @@ StringValue::StringValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.StringValue) } - -void StringValue::InitAsDefaultInstance() { -} - StringValue::StringValue(const StringValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.value().size() > 0) { + value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value(), + GetArenaNoVirtual()); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue) } @@ -2287,7 +2081,7 @@ void StringValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* StringValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return StringValue_descriptor_; + return file_level_metadata[7].descriptor; } const StringValue& StringValue::default_instance() { @@ -2295,8 +2089,6 @@ const StringValue& StringValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<StringValue> StringValue_default_instance_; - StringValue* StringValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<StringValue>(arena); } @@ -2312,13 +2104,13 @@ bool StringValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.StringValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string value = 1; + // string value = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -2328,7 +2120,6 @@ bool StringValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2356,7 +2147,7 @@ failure: void StringValue::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.StringValue) - // optional string value = 1; + // string value = 1; if (this->value().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->value().data(), this->value().length(), @@ -2373,7 +2164,7 @@ void StringValue::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.StringValue) - // optional string value = 1; + // string value = 1; if (this->value().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->value().data(), this->value().length(), @@ -2392,7 +2183,7 @@ size_t StringValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.StringValue) size_t total_size = 0; - // optional string value = 1; + // string value = 1; if (this->value().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( @@ -2408,7 +2199,7 @@ size_t StringValue::ByteSizeLong() const { void StringValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.StringValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const StringValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const StringValue>( &from); @@ -2417,21 +2208,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void StringValue::MergeFrom(const StringValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.StringValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void StringValue::UnsafeMergeFrom(const StringValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value().size() > 0) { set_value(from.value()); } @@ -2448,11 +2232,10 @@ void StringValue::CopyFrom(const StringValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.StringValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool StringValue::IsInitialized() const { - return true; } @@ -2461,10 +2244,13 @@ void StringValue::Swap(StringValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - StringValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + StringValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void StringValue::UnsafeArenaSwap(StringValue* other) { @@ -2474,28 +2260,24 @@ void StringValue::UnsafeArenaSwap(StringValue* other) { } void StringValue::InternalSwap(StringValue* other) { value_.Swap(&other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata StringValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = StringValue_descriptor_; - metadata.reflection = StringValue_reflection_; - return metadata; + return file_level_metadata[7]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // StringValue -// optional string value = 1; +// string value = 1; void StringValue::clear_value() { value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& StringValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.StringValue.value) - return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return value_.Get(); } void StringValue::set_value(const ::std::string& value) { @@ -2555,9 +2337,6 @@ void StringValue::unsafe_arena_set_allocated_value( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.StringValue.value) } -inline const StringValue* StringValue::internal_default_instance() { - return &StringValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -2568,7 +2347,9 @@ const int BytesValue::kValueFieldNumber; BytesValue::BytesValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.BytesValue) } @@ -2582,15 +2363,16 @@ BytesValue::BytesValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.BytesValue) } - -void BytesValue::InitAsDefaultInstance() { -} - BytesValue::BytesValue(const BytesValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.value().size() > 0) { + value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value(), + GetArenaNoVirtual()); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue) } @@ -2626,7 +2408,7 @@ void BytesValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* BytesValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return BytesValue_descriptor_; + return file_level_metadata[8].descriptor; } const BytesValue& BytesValue::default_instance() { @@ -2634,8 +2416,6 @@ const BytesValue& BytesValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<BytesValue> BytesValue_default_instance_; - BytesValue* BytesValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<BytesValue>(arena); } @@ -2651,19 +2431,18 @@ bool BytesValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.BytesValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional bytes value = 1; + // bytes value = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_value())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2691,7 +2470,7 @@ failure: void BytesValue::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.BytesValue) - // optional bytes value = 1; + // bytes value = 1; if (this->value().size() > 0) { ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased( 1, this->value(), output); @@ -2704,7 +2483,7 @@ void BytesValue::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BytesValue) - // optional bytes value = 1; + // bytes value = 1; if (this->value().size() > 0) { target = ::google::protobuf::internal::WireFormatLite::WriteBytesToArray( @@ -2719,7 +2498,7 @@ size_t BytesValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.BytesValue) size_t total_size = 0; - // optional bytes value = 1; + // bytes value = 1; if (this->value().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::BytesSize( @@ -2735,7 +2514,7 @@ size_t BytesValue::ByteSizeLong() const { void BytesValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.BytesValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const BytesValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const BytesValue>( &from); @@ -2744,21 +2523,14 @@ 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) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void BytesValue::MergeFrom(const BytesValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BytesValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void BytesValue::UnsafeMergeFrom(const BytesValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value().size() > 0) { set_value(from.value()); } @@ -2775,11 +2547,10 @@ void BytesValue::CopyFrom(const BytesValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.BytesValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool BytesValue::IsInitialized() const { - return true; } @@ -2788,10 +2559,13 @@ void BytesValue::Swap(BytesValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - BytesValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + BytesValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void BytesValue::UnsafeArenaSwap(BytesValue* other) { @@ -2801,28 +2575,24 @@ void BytesValue::UnsafeArenaSwap(BytesValue* other) { } void BytesValue::InternalSwap(BytesValue* other) { value_.Swap(&other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata BytesValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = BytesValue_descriptor_; - metadata.reflection = BytesValue_reflection_; - return metadata; + return file_level_metadata[8]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // BytesValue -// optional bytes value = 1; +// bytes value = 1; void BytesValue::clear_value() { value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& BytesValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value) - return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return value_.Get(); } void BytesValue::set_value(const ::std::string& value) { @@ -2882,9 +2652,6 @@ void BytesValue::unsafe_arena_set_allocated_value( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.BytesValue.value) } -inline const BytesValue* BytesValue::internal_default_instance() { - return &BytesValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index 568f8669..0197b6c5 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -24,29 +24,48 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) - namespace google { 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(); - class BoolValue; +class BoolValueDefaultTypeInternal; +extern BoolValueDefaultTypeInternal _BoolValue_default_instance_; class BytesValue; +class BytesValueDefaultTypeInternal; +extern BytesValueDefaultTypeInternal _BytesValue_default_instance_; class DoubleValue; +class DoubleValueDefaultTypeInternal; +extern DoubleValueDefaultTypeInternal _DoubleValue_default_instance_; class FloatValue; +class FloatValueDefaultTypeInternal; +extern FloatValueDefaultTypeInternal _FloatValue_default_instance_; class Int32Value; +class Int32ValueDefaultTypeInternal; +extern Int32ValueDefaultTypeInternal _Int32Value_default_instance_; class Int64Value; +class Int64ValueDefaultTypeInternal; +extern Int64ValueDefaultTypeInternal _Int64Value_default_instance_; class StringValue; +class StringValueDefaultTypeInternal; +extern StringValueDefaultTypeInternal _StringValue_default_instance_; class UInt32Value; +class UInt32ValueDefaultTypeInternal; +extern UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_; class UInt64Value; +class UInt64ValueDefaultTypeInternal; +extern UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_; +} // namespace protobuf +} // namespace google + +namespace google { +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(); // =================================================================== @@ -62,47 +81,52 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const DoubleValue& default_instance(); - static const DoubleValue* internal_default_instance(); + static inline const DoubleValue* internal_default_instance() { + return reinterpret_cast<const DoubleValue*>( + &_DoubleValue_default_instance_); + } void UnsafeArenaSwap(DoubleValue* other); void Swap(DoubleValue* other); // implements Message ---------------------------------------------- - inline DoubleValue* New() const { return New(NULL); } + inline DoubleValue* New() const PROTOBUF_FINAL { return New(NULL); } - DoubleValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + DoubleValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const DoubleValue& from); void MergeFrom(const DoubleValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(DoubleValue* other); - void UnsafeMergeFrom(const DoubleValue& from); protected: explicit DoubleValue(::google::protobuf::Arena* arena); private: @@ -117,13 +141,13 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional double value = 1; + // double value = 1; void clear_value(); static const int kValueFieldNumber = 1; double value() const; @@ -140,13 +164,10 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> DoubleValue_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FloatValue) */ { @@ -161,47 +182,52 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const FloatValue& default_instance(); - static const FloatValue* internal_default_instance(); + static inline const FloatValue* internal_default_instance() { + return reinterpret_cast<const FloatValue*>( + &_FloatValue_default_instance_); + } void UnsafeArenaSwap(FloatValue* other); void Swap(FloatValue* other); // implements Message ---------------------------------------------- - inline FloatValue* New() const { return New(NULL); } + inline FloatValue* New() const PROTOBUF_FINAL { return New(NULL); } - FloatValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FloatValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FloatValue& from); void MergeFrom(const FloatValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FloatValue* other); - void UnsafeMergeFrom(const FloatValue& from); protected: explicit FloatValue(::google::protobuf::Arena* arena); private: @@ -216,13 +242,13 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional float value = 1; + // float value = 1; void clear_value(); static const int kValueFieldNumber = 1; float value() const; @@ -239,13 +265,10 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FloatValue> FloatValue_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int64Value) */ { @@ -260,47 +283,52 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Int64Value& default_instance(); - static const Int64Value* internal_default_instance(); + static inline const Int64Value* internal_default_instance() { + return reinterpret_cast<const Int64Value*>( + &_Int64Value_default_instance_); + } void UnsafeArenaSwap(Int64Value* other); void Swap(Int64Value* other); // implements Message ---------------------------------------------- - inline Int64Value* New() const { return New(NULL); } + inline Int64Value* New() const PROTOBUF_FINAL { return New(NULL); } - Int64Value* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Int64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Int64Value& from); void MergeFrom(const Int64Value& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Int64Value* other); - void UnsafeMergeFrom(const Int64Value& from); protected: explicit Int64Value(::google::protobuf::Arena* arena); private: @@ -315,13 +343,13 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional int64 value = 1; + // int64 value = 1; void clear_value(); static const int kValueFieldNumber = 1; ::google::protobuf::int64 value() const; @@ -338,13 +366,10 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Int64Value> Int64Value_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt64Value) */ { @@ -359,47 +384,52 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const UInt64Value& default_instance(); - static const UInt64Value* internal_default_instance(); + static inline const UInt64Value* internal_default_instance() { + return reinterpret_cast<const UInt64Value*>( + &_UInt64Value_default_instance_); + } void UnsafeArenaSwap(UInt64Value* other); void Swap(UInt64Value* other); // implements Message ---------------------------------------------- - inline UInt64Value* New() const { return New(NULL); } + inline UInt64Value* New() const PROTOBUF_FINAL { return New(NULL); } - UInt64Value* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + UInt64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const UInt64Value& from); void MergeFrom(const UInt64Value& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(UInt64Value* other); - void UnsafeMergeFrom(const UInt64Value& from); protected: explicit UInt64Value(::google::protobuf::Arena* arena); private: @@ -414,13 +444,13 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional uint64 value = 1; + // uint64 value = 1; void clear_value(); static const int kValueFieldNumber = 1; ::google::protobuf::uint64 value() const; @@ -437,13 +467,10 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> UInt64Value_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int32Value) */ { @@ -458,47 +485,52 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Int32Value& default_instance(); - static const Int32Value* internal_default_instance(); + static inline const Int32Value* internal_default_instance() { + return reinterpret_cast<const Int32Value*>( + &_Int32Value_default_instance_); + } void UnsafeArenaSwap(Int32Value* other); void Swap(Int32Value* other); // implements Message ---------------------------------------------- - inline Int32Value* New() const { return New(NULL); } + inline Int32Value* New() const PROTOBUF_FINAL { return New(NULL); } - Int32Value* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Int32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Int32Value& from); void MergeFrom(const Int32Value& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Int32Value* other); - void UnsafeMergeFrom(const Int32Value& from); protected: explicit Int32Value(::google::protobuf::Arena* arena); private: @@ -513,13 +545,13 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional int32 value = 1; + // int32 value = 1; void clear_value(); static const int kValueFieldNumber = 1; ::google::protobuf::int32 value() const; @@ -536,13 +568,10 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Int32Value> Int32Value_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt32Value) */ { @@ -557,47 +586,52 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const UInt32Value& default_instance(); - static const UInt32Value* internal_default_instance(); + static inline const UInt32Value* internal_default_instance() { + return reinterpret_cast<const UInt32Value*>( + &_UInt32Value_default_instance_); + } void UnsafeArenaSwap(UInt32Value* other); void Swap(UInt32Value* other); // implements Message ---------------------------------------------- - inline UInt32Value* New() const { return New(NULL); } + inline UInt32Value* New() const PROTOBUF_FINAL { return New(NULL); } - UInt32Value* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + UInt32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const UInt32Value& from); void MergeFrom(const UInt32Value& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(UInt32Value* other); - void UnsafeMergeFrom(const UInt32Value& from); protected: explicit UInt32Value(::google::protobuf::Arena* arena); private: @@ -612,13 +646,13 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional uint32 value = 1; + // uint32 value = 1; void clear_value(); static const int kValueFieldNumber = 1; ::google::protobuf::uint32 value() const; @@ -635,13 +669,10 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> UInt32Value_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BoolValue) */ { @@ -656,47 +687,52 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const BoolValue& default_instance(); - static const BoolValue* internal_default_instance(); + static inline const BoolValue* internal_default_instance() { + return reinterpret_cast<const BoolValue*>( + &_BoolValue_default_instance_); + } void UnsafeArenaSwap(BoolValue* other); void Swap(BoolValue* other); // implements Message ---------------------------------------------- - inline BoolValue* New() const { return New(NULL); } + inline BoolValue* New() const PROTOBUF_FINAL { return New(NULL); } - BoolValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + BoolValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const BoolValue& from); void MergeFrom(const BoolValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(BoolValue* other); - void UnsafeMergeFrom(const BoolValue& from); protected: explicit BoolValue(::google::protobuf::Arena* arena); private: @@ -711,13 +747,13 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional bool value = 1; + // bool value = 1; void clear_value(); static const int kValueFieldNumber = 1; bool value() const; @@ -734,13 +770,10 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<BoolValue> BoolValue_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.StringValue) */ { @@ -755,47 +788,52 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const StringValue& default_instance(); - static const StringValue* internal_default_instance(); + static inline const StringValue* internal_default_instance() { + return reinterpret_cast<const StringValue*>( + &_StringValue_default_instance_); + } void UnsafeArenaSwap(StringValue* other); void Swap(StringValue* other); // implements Message ---------------------------------------------- - inline StringValue* New() const { return New(NULL); } + inline StringValue* New() const PROTOBUF_FINAL { return New(NULL); } - StringValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + StringValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const StringValue& from); void MergeFrom(const StringValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(StringValue* other); - void UnsafeMergeFrom(const StringValue& from); protected: explicit StringValue(::google::protobuf::Arena* arena); private: @@ -810,13 +848,13 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string value = 1; + // string value = 1; void clear_value(); static const int kValueFieldNumber = 1; const ::std::string& value() const; @@ -841,13 +879,10 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<StringValue> StringValue_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BytesValue) */ { @@ -862,47 +897,52 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const BytesValue& default_instance(); - static const BytesValue* internal_default_instance(); + static inline const BytesValue* internal_default_instance() { + return reinterpret_cast<const BytesValue*>( + &_BytesValue_default_instance_); + } void UnsafeArenaSwap(BytesValue* other); void Swap(BytesValue* other); // implements Message ---------------------------------------------- - inline BytesValue* New() const { return New(NULL); } + inline BytesValue* New() const PROTOBUF_FINAL { return New(NULL); } - BytesValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + BytesValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const BytesValue& from); void MergeFrom(const BytesValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(BytesValue* other); - void UnsafeMergeFrom(const BytesValue& from); protected: explicit BytesValue(::google::protobuf::Arena* arena); private: @@ -917,13 +957,13 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional bytes value = 1; + // bytes value = 1; void clear_value(); static const int kValueFieldNumber = 1; const ::std::string& value() const; @@ -948,13 +988,10 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr mutable int _cached_size_; 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 const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> BytesValue_default_instance_; - // =================================================================== @@ -963,7 +1000,7 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> BytesValu #if !PROTOBUF_INLINE_NOT_IN_HEADERS // DoubleValue -// optional double value = 1; +// double value = 1; inline void DoubleValue::clear_value() { value_ = 0; } @@ -977,14 +1014,11 @@ inline void DoubleValue::set_value(double value) { // @@protoc_insertion_point(field_set:google.protobuf.DoubleValue.value) } -inline const DoubleValue* DoubleValue::internal_default_instance() { - return &DoubleValue_default_instance_.get(); -} // ------------------------------------------------------------------- // FloatValue -// optional float value = 1; +// float value = 1; inline void FloatValue::clear_value() { value_ = 0; } @@ -998,14 +1032,11 @@ inline void FloatValue::set_value(float value) { // @@protoc_insertion_point(field_set:google.protobuf.FloatValue.value) } -inline const FloatValue* FloatValue::internal_default_instance() { - return &FloatValue_default_instance_.get(); -} // ------------------------------------------------------------------- // Int64Value -// optional int64 value = 1; +// int64 value = 1; inline void Int64Value::clear_value() { value_ = GOOGLE_LONGLONG(0); } @@ -1019,14 +1050,11 @@ inline void Int64Value::set_value(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:google.protobuf.Int64Value.value) } -inline const Int64Value* Int64Value::internal_default_instance() { - return &Int64Value_default_instance_.get(); -} // ------------------------------------------------------------------- // UInt64Value -// optional uint64 value = 1; +// uint64 value = 1; inline void UInt64Value::clear_value() { value_ = GOOGLE_ULONGLONG(0); } @@ -1040,14 +1068,11 @@ inline void UInt64Value::set_value(::google::protobuf::uint64 value) { // @@protoc_insertion_point(field_set:google.protobuf.UInt64Value.value) } -inline const UInt64Value* UInt64Value::internal_default_instance() { - return &UInt64Value_default_instance_.get(); -} // ------------------------------------------------------------------- // Int32Value -// optional int32 value = 1; +// int32 value = 1; inline void Int32Value::clear_value() { value_ = 0; } @@ -1061,14 +1086,11 @@ inline void Int32Value::set_value(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Int32Value.value) } -inline const Int32Value* Int32Value::internal_default_instance() { - return &Int32Value_default_instance_.get(); -} // ------------------------------------------------------------------- // UInt32Value -// optional uint32 value = 1; +// uint32 value = 1; inline void UInt32Value::clear_value() { value_ = 0u; } @@ -1082,14 +1104,11 @@ inline void UInt32Value::set_value(::google::protobuf::uint32 value) { // @@protoc_insertion_point(field_set:google.protobuf.UInt32Value.value) } -inline const UInt32Value* UInt32Value::internal_default_instance() { - return &UInt32Value_default_instance_.get(); -} // ------------------------------------------------------------------- // BoolValue -// optional bool value = 1; +// bool value = 1; inline void BoolValue::clear_value() { value_ = false; } @@ -1103,20 +1122,17 @@ inline void BoolValue::set_value(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.BoolValue.value) } -inline const BoolValue* BoolValue::internal_default_instance() { - return &BoolValue_default_instance_.get(); -} // ------------------------------------------------------------------- // StringValue -// optional string value = 1; +// string value = 1; inline void StringValue::clear_value() { value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& StringValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.StringValue.value) - return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return value_.Get(); } inline void StringValue::set_value(const ::std::string& value) { @@ -1176,20 +1192,17 @@ inline void StringValue::unsafe_arena_set_allocated_value( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.StringValue.value) } -inline const StringValue* StringValue::internal_default_instance() { - return &StringValue_default_instance_.get(); -} // ------------------------------------------------------------------- // BytesValue -// optional bytes value = 1; +// bytes value = 1; inline void BytesValue::clear_value() { value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& BytesValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value) - return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return value_.Get(); } inline void BytesValue::set_value(const ::std::string& value) { @@ -1249,9 +1262,6 @@ inline void BytesValue::unsafe_arena_set_allocated_value( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.BytesValue.value) } -inline const BytesValue* BytesValue::internal_default_instance() { - return &BytesValue_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- @@ -1272,6 +1282,7 @@ inline const BytesValue* BytesValue::internal_default_instance() { // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google |