diff options
Diffstat (limited to 'src/google/protobuf')
268 files changed, 19009 insertions, 15390 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..407dc0ad 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -19,111 +19,103 @@ namespace google { namespace protobuf { +class AnyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Any> { +} _Any_default_instance_; + +namespace protobuf_google_2fprotobuf_2fany_2eproto { + namespace { -const ::google::protobuf::Descriptor* Any_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Any_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace +const ::google::protobuf::uint32 TableStruct::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_), +}; -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] = { - 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_)); -} +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Any)}, +}; + +static ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_Any_default_instance_), +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/any.proto", schemas, file_default_instances, TableStruct::offsets, 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_; +void TableStruct::Shutdown() { + _Any_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } -void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl() { +void TableStruct::InitDefaultsImpl() { 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); +void InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); } -void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); +void AddDescriptorsImpl() { + InitDefaults(); + 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); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_); -void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_, - &protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl); +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); } -} static_descriptor_initializer_google_2fprotobuf_2fany_2eproto_; +} static_descriptor_initializer; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace +} // namespace protobuf_google_2fprotobuf_2fany_2eproto // =================================================================== @@ -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_google_2fprotobuf_2fany_2eproto::InitDefaults(); + } 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) } @@ -187,17 +185,15 @@ void Any::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Any::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Any_descriptor_; + protobuf_google_2fprotobuf_2fany_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fany_2eproto::file_level_metadata[0].descriptor; } const Any& Any::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); + protobuf_google_2fprotobuf_2fany_2eproto::InitDefaults(); 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,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -234,20 +231,18 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_value())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -275,7 +270,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 +280,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); @@ -296,9 +291,9 @@ void Any::SerializeWithCachedSizes( ::google::protobuf::uint8* Any::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +304,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 +319,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 +342,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 +351,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 +380,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,34 +394,38 @@ 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; + protobuf_google_2fprotobuf_2fany_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fany_2eproto::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) { type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url) } +#if LANG_CXX11 +void Any::set_type_url(::std::string&& value) { + + type_url_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.type_url) +} +#endif void Any::set_type_url(const char* value) { type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -466,19 +457,27 @@ 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) { value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Any.value) } +#if LANG_CXX11 +void Any::set_value(::std::string&& value) { + + value_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.value) +} +#endif void Any::set_value(const char* value) { value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -510,9 +509,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..1a61d5af 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -8,38 +8,49 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3001000 +#if GOOGLE_PROTOBUF_VERSION < 3002000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #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; +LIBPROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { +namespace protobuf_google_2fprotobuf_2fany_2eproto { // 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; +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::uint32 offsets[]; + static void InitDefaultsImpl(); + static void Shutdown(); +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaults(); +} // namespace protobuf_google_2fprotobuf_2fany_2eproto // =================================================================== @@ -58,7 +69,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,64 +88,71 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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; void set_type_url(const ::std::string& value); + #if LANG_CXX11 + void set_type_url(::std::string&& value); + #endif void set_type_url(const char* value); void set_type_url(const char* value, size_t size); ::std::string* mutable_type_url(); ::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; void set_value(const ::std::string& value); + #if LANG_CXX11 + void set_value(::std::string&& value); + #endif void set_value(const char* value); void set_value(const void* value, size_t size); ::std::string* mutable_value(); @@ -146,15 +167,8 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in ::google::protobuf::internal::ArenaStringPtr value_; mutable int _cached_size_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fany_2eproto::TableStruct; }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Any> Any_default_instance_; - // =================================================================== @@ -163,19 +177,27 @@ 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) { type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url) } +#if LANG_CXX11 +inline void Any::set_type_url(::std::string&& value) { + + type_url_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.type_url) +} +#endif inline void Any::set_type_url(const char* value) { type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -207,19 +229,27 @@ 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) { value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Any.value) } +#if LANG_CXX11 +inline void Any::set_value(::std::string&& value) { + + value_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.value) +} +#endif inline void Any::set_value(const char* value) { value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -251,13 +281,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..7965d1ce 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -19,187 +19,158 @@ namespace google { namespace protobuf { +class ApiDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Api> { +} _Api_default_instance_; +class MethodDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Method> { +} _Method_default_instance_; +class MixinDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Mixin> { +} _Mixin_default_instance_; + +namespace protobuf_google_2fprotobuf_2fapi_2eproto { + 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] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, methods_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, options_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, version_), - 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] = { - 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_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_type_url_), - 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] = { - 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_)); -} +const ::google::protobuf::uint32 TableStruct::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_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, version_), + 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_), + ~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_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_type_url_), + 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_), + ~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_), +}; + +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Api)}, + { 11, -1, sizeof(Method)}, + { 22, -1, sizeof(Mixin)}, +}; + +static ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_Api_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_Method_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_Mixin_default_instance_), +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/api.proto", schemas, file_default_instances, TableStruct::offsets, 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_; +void TableStruct::Shutdown() { + _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() { +void TableStruct::InitDefaultsImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); - ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); - ::google::protobuf::internal::GetEmptyString(); - Api_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - Method_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - Mixin_default_instance_.DefaultConstruct(); - Api_default_instance_.get_mutable()->InitAsDefaultInstance(); - Method_default_instance_.get_mutable()->InitAsDefaultInstance(); - Mixin_default_instance_.get_mutable()->InitAsDefaultInstance(); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_once_); -void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl); -} -void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; + ::google::protobuf::internal::InitProtobufDefaults(); + ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults(); + ::google::protobuf::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + _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()); +} - protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); +void InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); +} +void AddDescriptorsImpl() { + InitDefaults(); + 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(); - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto); + ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::AddDescriptors(); + ::google::protobuf::protobuf_google_2fprotobuf_2ftype_2eproto::AddDescriptors(); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_once_); -void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_once_, - &protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl); +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); } -} static_descriptor_initializer_google_2fprotobuf_2fapi_2eproto_; +} static_descriptor_initializer; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace +} // namespace protobuf_google_2fprotobuf_2fapi_2eproto // =================================================================== @@ -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_google_2fprotobuf_2fapi_2eproto::InitDefaults(); + } 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_; } } @@ -261,17 +245,15 @@ void Api::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Api::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Api_descriptor_; + protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[0].descriptor; } const Api& Api::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults(); 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,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -314,47 +299,41 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(34u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_version())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -364,44 +343,39 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(56u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -410,7 +384,6 @@ bool Api::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -438,7 +411,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 +433,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 +443,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 +455,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); @@ -493,9 +466,9 @@ void Api::SerializeWithCachedSizes( ::google::protobuf::uint8* Api::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +493,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 +504,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 +518,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 +532,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 +565,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 +601,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 +610,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 +648,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,41 +660,45 @@ 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; + protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fapi_2eproto::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) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Api.name) } +#if LANG_CXX11 +void Api::set_name(::std::string&& value) { + + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.name) +} +#endif void Api::set_name(const char* value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -821,19 +790,27 @@ 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) { version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Api.version) } +#if LANG_CXX11 +void Api::set_version(::std::string&& value) { + + version_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.version) +} +#endif void Api::set_version(const char* value) { version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -865,7 +842,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 +911,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 +925,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 +941,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_google_2fprotobuf_2fapi_2eproto::InitDefaults(); + } 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) } @@ -1009,17 +997,15 @@ void Method::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Method::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Method_descriptor_; + protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[1].descriptor; } const Method& Method::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults(); 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 +1016,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 +1030,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1079,14 +1047,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_request_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1096,14 +1063,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(24u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1111,14 +1077,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(34u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_response_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1128,14 +1093,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(40u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1143,31 +1107,27 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(56u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1176,7 +1136,6 @@ bool Method::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1204,7 +1163,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 +1173,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 +1183,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 +1198,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 +1209,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); @@ -1261,9 +1220,9 @@ void Method::SerializeWithCachedSizes( ::google::protobuf::uint8* Method::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +1233,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 +1244,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 +1260,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 +1272,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 +1286,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 +1343,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 +1352,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 +1369,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 +1395,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,41 +1407,45 @@ 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; + protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fapi_2eproto::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) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Method.name) } +#if LANG_CXX11 +void Method::set_name(::std::string&& value) { + + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.name) +} +#endif void Method::set_name(const char* value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -1522,19 +1477,27 @@ 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) { request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url) } +#if LANG_CXX11 +void Method::set_request_type_url(::std::string&& value) { + + request_type_url_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.request_type_url) +} +#endif void Method::set_request_type_url(const char* value) { request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -1566,7 +1529,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,19 +1543,27 @@ 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) { response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url) } +#if LANG_CXX11 +void Method::set_response_type_url(::std::string&& value) { + + response_type_url_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.response_type_url) +} +#endif void Method::set_response_type_url(const char* value) { response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -1624,7 +1595,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 +1639,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 +1653,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 +1664,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_google_2fprotobuf_2fapi_2eproto::InitDefaults(); + } 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) } @@ -1734,17 +1708,15 @@ void Mixin::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Mixin::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Mixin_descriptor_; + protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[2].descriptor; } const Mixin& Mixin::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults(); 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 +1737,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1781,14 +1754,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_root())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1798,7 +1770,6 @@ bool Mixin::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1826,7 +1797,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 +1807,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(), @@ -1851,9 +1822,9 @@ void Mixin::SerializeWithCachedSizes( ::google::protobuf::uint8* Mixin::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +1835,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 +1854,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 +1877,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 +1886,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 +1915,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,34 +1929,38 @@ 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; + protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fapi_2eproto::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) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name) } +#if LANG_CXX11 +void Mixin::set_name(::std::string&& value) { + + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.name) +} +#endif void Mixin::set_name(const char* value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -2025,19 +1992,27 @@ 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) { root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root) } +#if LANG_CXX11 +void Mixin::set_root(::std::string&& value) { + + root_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.root) +} +#endif void Mixin::set_root(const char* value) { root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -2069,9 +2044,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..2eb571e6 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -8,41 +8,74 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3001000 +#if GOOGLE_PROTOBUF_VERSION < 3002000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #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 { - -// 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 ApiDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern ApiDefaultTypeInternal _Api_default_instance_; +class Enum; +class EnumDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern EnumDefaultTypeInternal _Enum_default_instance_; +class EnumValue; +class EnumValueDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern EnumValueDefaultTypeInternal _EnumValue_default_instance_; +class Field; +class FieldDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern FieldDefaultTypeInternal _Field_default_instance_; class Method; +class MethodDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern MethodDefaultTypeInternal _Method_default_instance_; class Mixin; +class MixinDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern MixinDefaultTypeInternal _Mixin_default_instance_; +class Option; +class OptionDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern OptionDefaultTypeInternal _Option_default_instance_; +class SourceContext; +class SourceContextDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; +class Type; +class TypeDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern TypeDefaultTypeInternal _Type_default_instance_; +} // namespace protobuf +} // namespace google + +namespace google { +namespace protobuf { + +namespace protobuf_google_2fprotobuf_2fapi_2eproto { +// Internal implementation detail -- do not call these. +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::uint32 offsets[]; + static void InitDefaultsImpl(); + static void Shutdown(); +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaults(); +} // namespace protobuf_google_2fprotobuf_2fapi_2eproto // =================================================================== @@ -61,65 +94,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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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; - void clear_name(); - static const int kNameFieldNumber = 1; - const ::std::string& name() const; - void set_name(const ::std::string& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); - ::std::string* mutable_name(); - ::std::string* release_name(); - void set_allocated_name(::std::string* name); - // repeated .google.protobuf.Method methods = 2; int methods_size() const; void clear_methods(); @@ -144,18 +170,47 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; - // optional string version = 4; + // repeated .google.protobuf.Mixin mixins = 6; + int mixins_size() const; + void clear_mixins(); + static const int kMixinsFieldNumber = 6; + const ::google::protobuf::Mixin& mixins(int index) const; + ::google::protobuf::Mixin* mutable_mixins(int index); + ::google::protobuf::Mixin* add_mixins(); + ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >* + mutable_mixins(); + const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >& + mixins() const; + + // string name = 1; + void clear_name(); + static const int kNameFieldNumber = 1; + const ::std::string& name() const; + void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); + + // string version = 4; void clear_version(); static const int kVersionFieldNumber = 4; const ::std::string& version() const; void set_version(const ::std::string& value); + #if LANG_CXX11 + void set_version(::std::string&& value); + #endif void set_version(const char* value); void set_version(const char* value, size_t size); ::std::string* mutable_version(); ::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; @@ -164,19 +219,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in ::google::protobuf::SourceContext* release_source_context(); void set_allocated_source_context(::google::protobuf::SourceContext* source_context); - // repeated .google.protobuf.Mixin mixins = 6; - int mixins_size() const; - void clear_mixins(); - static const int kMixinsFieldNumber = 6; - const ::google::protobuf::Mixin& mixins(int index) const; - ::google::protobuf::Mixin* mutable_mixins(int index); - ::google::protobuf::Mixin* add_mixins(); - ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >* - mutable_mixins(); - 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; @@ -194,15 +237,8 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in ::google::protobuf::SourceContext* source_context_; int syntax_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct; }; -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,112 +256,125 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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; + // repeated .google.protobuf.Option options = 6; + int options_size() const; + void clear_options(); + static const int kOptionsFieldNumber = 6; + const ::google::protobuf::Option& options(int index) const; + ::google::protobuf::Option* mutable_options(int index); + ::google::protobuf::Option* add_options(); + ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* + mutable_options(); + const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& + options() const; + + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); ::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; void set_request_type_url(const ::std::string& value); + #if LANG_CXX11 + void set_request_type_url(::std::string&& value); + #endif void set_request_type_url(const char* value); void set_request_type_url(const char* value, size_t size); ::std::string* mutable_request_type_url(); ::std::string* release_request_type_url(); void set_allocated_request_type_url(::std::string* request_type_url); - // optional 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; void set_response_type_url(const ::std::string& value); + #if LANG_CXX11 + void set_response_type_url(::std::string&& value); + #endif void set_response_type_url(const char* value); void set_response_type_url(const char* value, size_t size); ::std::string* mutable_response_type_url(); ::std::string* release_response_type_url(); void set_allocated_response_type_url(::std::string* response_type_url); - // optional bool response_streaming = 5; + // bool request_streaming = 3; + void clear_request_streaming(); + static const int kRequestStreamingFieldNumber = 3; + bool request_streaming() const; + void set_request_streaming(bool value); + + // bool response_streaming = 5; void clear_response_streaming(); static const int kResponseStreamingFieldNumber = 5; bool response_streaming() const; void set_response_streaming(bool value); - // repeated .google.protobuf.Option options = 6; - int options_size() const; - void clear_options(); - static const int kOptionsFieldNumber = 6; - const ::google::protobuf::Option& options(int index) const; - ::google::protobuf::Option* mutable_options(int index); - ::google::protobuf::Option* add_options(); - ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* - mutable_options(); - 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; @@ -343,15 +392,8 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc bool response_streaming_; int syntax_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct; }; -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,70 +411,80 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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; void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); ::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; void set_root(const ::std::string& value); + #if LANG_CXX11 + void set_root(::std::string&& value); + #endif void set_root(const char* value); void set_root(const char* value, size_t size); ::std::string* mutable_root(); @@ -446,15 +498,8 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr root_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct; }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Mixin> Mixin_default_instance_; - // =================================================================== @@ -463,19 +508,27 @@ 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) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Api.name) } +#if LANG_CXX11 +inline void Api::set_name(::std::string&& value) { + + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.name) +} +#endif inline void Api::set_name(const char* value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -567,19 +620,27 @@ 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) { version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Api.version) } +#if LANG_CXX11 +inline void Api::set_version(::std::string&& value) { + + version_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.version) +} +#endif inline void Api::set_version(const char* value) { version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -611,7 +672,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 +741,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,26 +755,31 @@ 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) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Method.name) } +#if LANG_CXX11 +inline void Method::set_name(::std::string&& value) { + + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.name) +} +#endif inline void Method::set_name(const char* value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -745,19 +811,27 @@ 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) { request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url) } +#if LANG_CXX11 +inline void Method::set_request_type_url(::std::string&& value) { + + request_type_url_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.request_type_url) +} +#endif inline void Method::set_request_type_url(const char* value) { request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -789,7 +863,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,19 +877,27 @@ 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) { response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url) } +#if LANG_CXX11 +inline void Method::set_response_type_url(::std::string&& value) { + + response_type_url_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.response_type_url) +} +#endif inline void Method::set_response_type_url(const char* value) { response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -847,7 +929,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 +973,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,26 +987,31 @@ 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) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name) } +#if LANG_CXX11 +inline void Mixin::set_name(::std::string&& value) { + + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.name) +} +#endif inline void Mixin::set_name(const char* value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -956,19 +1043,27 @@ 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) { root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root) } +#if LANG_CXX11 +inline void Mixin::set_root(::std::string&& value) { + + root_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.root) +} +#endif inline void Mixin::set_root(const char* value) { root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -1000,9 +1095,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 +1103,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..16cf8951 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 { @@ -62,6 +62,7 @@ void Arena::Init() { lifecycle_id_ = lifecycle_id_generator_.GetNext(); blocks_ = 0; hint_ = 0; + space_allocated_ = 0; owns_first_block_ = true; cleanup_list_ = 0; @@ -141,7 +142,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; } @@ -157,6 +158,7 @@ void Arena::AddBlockInternal(Block* b) { // Direct future allocations to this block. google::protobuf::internal::Release_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(b)); } + space_allocated_ += b->size; } void Arena::AddListNode(void* elem, void (*cleanup)(void*)) { @@ -205,7 +207,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; } @@ -225,13 +227,8 @@ void* Arena::SlowAlloc(size_t n) { } uint64 Arena::SpaceAllocated() const { - uint64 space_allocated = 0; - Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_)); - while (b != NULL) { - space_allocated += (b->size); - b = b->next; - } - return space_allocated; + MutexLock l(&blocks_lock_); + return space_allocated_; } uint64 Arena::SpaceUsed() const { @@ -244,17 +241,8 @@ uint64 Arena::SpaceUsed() const { return space_used; } -pair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const { - uint64 allocated = 0; - uint64 used = 0; - - Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_)); - while (b != NULL) { - allocated += b->size; - used += (b->pos - kHeaderSize); - b = b->next; - } - return std::make_pair(allocated, used); +std::pair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const { + return std::make_pair(SpaceAllocated(), SpaceUsed()); } uint64 Arena::FreeBlocks() { @@ -265,9 +253,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. @@ -278,6 +276,7 @@ uint64 Arena::FreeBlocks() { } blocks_ = 0; hint_ = 0; + space_allocated_ = 0; if (!owns_first_block_) { // Make the first block that was passed in through ArenaOptions // available for reuse. diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 87066507..05e05ebc 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -322,6 +322,17 @@ class LIBPROTOBUF_EXPORT Arena { arg); } } +#if LANG_CXX11 + template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + static T* Create(::google::protobuf::Arena* arena, Arg&& arg) { + if (arena == NULL) { + return new T(std::move(arg)); + } else { + return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value, + std::move(arg)); + } + } +#endif // Version of the above with two constructor arguments for the created object. template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE @@ -449,14 +460,17 @@ class LIBPROTOBUF_EXPORT Arena { } } - // Returns the total space used by the arena, which is the sums of the sizes - // of the underlying blocks. The total space used may not include the new - // blocks that are allocated by this arena from other threads concurrently - // with the call to this method. - GOOGLE_ATTRIBUTE_NOINLINE uint64 SpaceAllocated() const; - // As above, but does not include any free space in underlying blocks. + // Returns the total space allocated by the arena, which is the sum of the + // sizes of the underlying blocks. This method is relatively fast; a counter + // is kept as blocks are allocated. + uint64 SpaceAllocated() const; + // Returns the total space used by the arena. Similar to SpaceAllocated but + // does not include free space and block overhead. The total space returned + // may not include space used by other threads executing concurrently with + // the call to this method. GOOGLE_ATTRIBUTE_NOINLINE uint64 SpaceUsed() const; - + // DEPRECATED. Please use SpaceAllocated() and SpaceUsed(). + // // Combines SpaceAllocated and SpaceUsed. Returns a pair of // <space_allocated, space_used>. GOOGLE_ATTRIBUTE_NOINLINE std::pair<uint64, uint64> SpaceAllocatedAndUsed() const; @@ -659,6 +673,18 @@ class LIBPROTOBUF_EXPORT Arena { return t; } +#if LANG_CXX11 + template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + T* CreateInternal(bool skip_explicit_ownership, Arg&& arg) { + T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) T( + std::move(arg)); + if (!skip_explicit_ownership) { + AddListNode(t, &internal::arena_destruct_object<T>); + } + return t; + } +#endif + template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal( bool skip_explicit_ownership, const Arg1& arg1, const Arg2& arg2) { @@ -884,8 +910,9 @@ class LIBPROTOBUF_EXPORT Arena { int64 lifecycle_id_; // Unique for each arena. Changes on Reset(). - google::protobuf::internal::AtomicWord blocks_; // Head of linked list of all allocated blocks - google::protobuf::internal::AtomicWord hint_; // Fast thread-local block access + google::protobuf::internal::AtomicWord blocks_; // Head of linked list of all allocated blocks + google::protobuf::internal::AtomicWord hint_; // Fast thread-local block access + uint64 space_allocated_; // Sum of sizes of all allocated blocks. // Node contains the ptr of the object to be cleaned up and the associated // cleanup function ptr. @@ -899,7 +926,7 @@ class LIBPROTOBUF_EXPORT Arena { // ptrs and cleanup methods. bool owns_first_block_; // Indicates that arena owns the first block - Mutex blocks_lock_; + mutable Mutex blocks_lock_; void AddBlock(Block* b); // Access must be synchronized, either by blocks_lock_ or by being called from diff --git a/src/google/protobuf/arena_nc_test.py b/src/google/protobuf/arena_nc_test.py deleted file mode 100644 index 56a7dd05..00000000 --- a/src/google/protobuf/arena_nc_test.py +++ /dev/null @@ -1,61 +0,0 @@ -#! /usr/bin/env python -# -# 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. - -"""Negative compilation unit tests for arena API.""" - -import unittest - -from google3.testing.pybase import fake_target_util -from google3.testing.pybase import unittest - - -class ArenaNcTest(unittest.TestCase): - - def testCompilerErrors(self): - """Runs a list of tests to verify compiler error messages.""" - - # Defines a list of test specs, where each element is a tuple - # (test name, list of regexes for matching the compiler errors). - test_specs = [ - ('ARENA_PRIVATE_CONSTRUCTOR', - [r'calling a protected constructor']), - ('SANITY', None)] - - fake_target_util.AssertCcCompilerErrors( - self, # The current test case. - 'google3/google/protobuf/arena_nc', # The fake target file. - 'arena_nc.o', # The sub-target to build. - test_specs # List of test specifications. - ) - -if __name__ == '__main__': - unittest.main() 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..a7efb752 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 @@ -214,11 +210,19 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { } } +#if LANG_CXX11 + void SetNoArena(const ::std::string* default_value, ::std::string&& value) { + if (IsDefault(default_value)) { + ptr_ = new ::std::string(std::move(value)); + } else { + *ptr_ = std::move(value); + } + } +#endif + 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 +257,6 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { if (ptr_ != default_value) { delete ptr_; } - ptr_ = NULL; } inline void ClearToEmptyNoArena(const ::std::string* default_value) { @@ -281,27 +284,24 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { return &ptr_; } + inline bool IsDefault(const ::std::string* default_value) const { + return ptr_ == default_value; + } + private: ::std::string* ptr_; GOOGLE_ATTRIBUTE_NOINLINE void CreateInstance(::google::protobuf::Arena* arena, const ::std::string* initial_value) { - // Assumes ptr_ is not NULL. - if (initial_value != NULL) { - ptr_ = new ::std::string(*initial_value); - } else { - ptr_ = new ::std::string(); - } + GOOGLE_DCHECK(initial_value != NULL); + ptr_ = new ::std::string(*initial_value); if (arena != NULL) { arena->Own(ptr_); } } GOOGLE_ATTRIBUTE_NOINLINE void CreateInstanceNoArena(const ::std::string* initial_value) { - if (initial_value != NULL) { - ptr_ = new ::std::string(*initial_value); - } else { - ptr_ = new ::std::string(); - } + GOOGLE_DCHECK(initial_value != NULL); + ptr_ = new ::std::string(*initial_value); } }; 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..11d0f334 100644 --- a/src/google/protobuf/compiler/code_generator.cc +++ b/src/google/protobuf/compiler/code_generator.cc @@ -34,6 +34,7 @@ #include <google/protobuf/compiler/code_generator.h> +#include <google/protobuf/compiler/plugin.pb.h> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/descriptor.h> @@ -46,7 +47,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 +86,25 @@ 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"; } +void GeneratorContext::GetCompilerVersion(Version* version) const { + version->set_major(GOOGLE_PROTOBUF_VERSION / 1000000); + version->set_minor(GOOGLE_PROTOBUF_VERSION / 1000 % 1000); + version->set_patch(GOOGLE_PROTOBUF_VERSION % 1000); + version->set_suffix(GOOGLE_PROTOBUF_VERSION_SUFFIX); +} + // 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..e2b2a661 100644 --- a/src/google/protobuf/compiler/code_generator.h +++ b/src/google/protobuf/compiler/code_generator.h @@ -50,6 +50,7 @@ namespace io { class ZeroCopyOutputStream; } class FileDescriptor; namespace compiler { +class Version; // Defined in this file. class CodeGenerator; @@ -90,7 +91,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 +142,11 @@ 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); + + // Retrieves the version number of the protocol compiler associated with + // this GeneratorContext. + virtual void GetCompilerVersion(Version* version) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext); @@ -157,8 +162,8 @@ typedef GeneratorContext OutputDirectory; // "foo=bar,baz,qux=corge" // parses to the pairs: // ("foo", "bar"), ("baz", ""), ("qux", "corge") -extern void ParseGeneratorParameter(const string&, - vector<pair<string, string> >*); +extern void LIBPROTOC_EXPORT ParseGeneratorParameter(const 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..0c9b1fb5 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -116,6 +116,9 @@ static const char* kPathSeparator = ";"; static const char* kPathSeparator = ":"; #endif +static const char* kDefaultDirectDependenciesViolationMsg = + "File is imported but not declared in --direct_dependencies: %s"; + // Returns true if the text looks like a Windows-style absolute path, starting // with a drive letter. Example: "C:\foo". TODO(kenton): Share this with // copy in importer.cc? @@ -173,7 +176,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]; @@ -275,12 +279,13 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector, public io::ErrorCollector { public: ErrorPrinter(ErrorFormat format, DiskSourceTree *tree = NULL) - : format_(format), tree_(tree) {} + : format_(format), tree_(tree), found_errors_(false) {} ~ErrorPrinter() {} // implements MultiFileErrorCollector ------------------------------ void AddError(const string& filename, int line, int column, const string& message) { + found_errors_ = true; AddErrorOrWarning(filename, line, column, message, "error", std::cerr); } @@ -298,10 +303,12 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector, AddErrorOrWarning("input", line, column, message, "warning", std::clog); } + bool FoundErrors() const { return found_errors_; } + private: - void AddErrorOrWarning( - const string& filename, int line, int column, - const string& message, const string& type, ostream& out) { + void AddErrorOrWarning(const string& filename, int line, int column, + const string& message, const string& type, + std::ostream& out) { // Print full path when running under MSVS string dfile; if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS && @@ -336,6 +343,7 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector, const ErrorFormat format_; DiskSourceTree *tree_; + bool found_errors_; }; // ------------------------------------------------------------------- @@ -344,7 +352,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 +368,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 +384,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 +422,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 +441,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 +529,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 +558,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); } @@ -707,14 +715,17 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { // =================================================================== CommandLineInterface::CommandLineInterface() - : mode_(MODE_COMPILE), - print_mode_(PRINT_NONE), - error_format_(ERROR_FORMAT_GCC), - direct_dependencies_explicitly_set_(false), - imports_in_descriptor_set_(false), - source_info_in_descriptor_set_(false), - disallow_services_(false), - inputs_are_proto_path_relative_(false) {} + : mode_(MODE_COMPILE), + print_mode_(PRINT_NONE), + error_format_(ERROR_FORMAT_GCC), + direct_dependencies_explicitly_set_(false), + direct_dependencies_violation_msg_( + kDefaultDirectDependenciesViolationMsg), + imports_in_descriptor_set_(false), + source_info_in_descriptor_set_(false), + disallow_services_(false), + inputs_are_proto_path_relative_(false) { +} CommandLineInterface::~CommandLineInterface() {} void CommandLineInterface::RegisterGenerator(const string& flag_name, @@ -774,7 +785,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++) { @@ -799,10 +810,11 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { if (direct_dependencies_.find(parsed_file->dependency(i)->name()) == direct_dependencies_.end()) { indirect_imports = true; - cerr << parsed_file->name() - << ": File is imported but not declared in " - << "--direct_dependencies: " - << parsed_file->dependency(i)->name() << std::endl; + cerr << parsed_file->name() << ": " + << StringReplace(direct_dependencies_violation_msg_, "%s", + parsed_file->dependency(i)->name(), + true /* replace_all */) + << std::endl; } } if (indirect_imports) { @@ -894,6 +906,10 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { } } + if (error_collector.FoundErrors()) { + return 1; + } + if (mode_ == MODE_PRINT) { switch (print_mode_) { case PRINT_FREE_FIELDS: @@ -923,6 +939,7 @@ void CommandLineInterface::Clear() { proto_path_.clear(); input_files_.clear(); direct_dependencies_.clear(); + direct_dependencies_violation_msg_ = kDefaultDirectDependenciesViolationMsg; output_directives_.clear(); codec_type_.clear(); descriptor_set_name_.clear(); @@ -984,7 +1001,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]); } @@ -1014,23 +1031,41 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { } // Make sure each plugin option has a matching plugin output. + bool foundUnknownPluginOption = false; for (map<string, string>::const_iterator i = plugin_parameters_.begin(); i != plugin_parameters_.end(); ++i) { - if (plugins_.find(i->first) == plugins_.end()) { + if (plugins_.find(i->first) != plugins_.end()) { + continue; + } + bool foundImplicitPlugin = false; + for (std::vector<OutputDirective>::const_iterator j = output_directives_.cbegin(); + j != output_directives_.cend(); ++j) { + if (j->generator == NULL) { + string plugin_name = PluginName(plugin_prefix_ , j->name); + if (plugin_name == i->first) { + foundImplicitPlugin = true; + break; + } + } + } + if (!foundImplicitPlugin) { std::cerr << "Unknown flag: " // strip prefix + "gen-" and add back "_opt" << "--" + i->first.substr(plugin_prefix_.size() + 4) + "_opt" << std::endl; - return PARSE_ARGUMENT_FAIL; + foundUnknownPluginOption = true; } } + if (foundUnknownPluginOption) { + return PARSE_ARGUMENT_FAIL; + } // If no --proto_path was given, use the current working directory. if (proto_path_.empty()) { // 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 +1188,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,22 +1225,27 @@ 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()); + } else if (name == "--direct_dependencies_violation_msg") { + direct_dependencies_violation_msg_ = value; + } else if (name == "-o" || name == "--descriptor_set_out") { if (!descriptor_set_name_.empty()) { std::cerr << name << " may only be passed once." << std::endl; @@ -1476,7 +1516,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 +1562,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 +1576,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 +1634,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 +1647,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], @@ -1616,6 +1656,13 @@ bool CommandLineInterface::GeneratePluginOutput( &already_seen, request.mutable_proto_file()); } + google::protobuf::compiler::Version* version = + request.mutable_compiler_version(); + version->set_major(GOOGLE_PROTOBUF_VERSION / 1000000); + version->set_minor(GOOGLE_PROTOBUF_VERSION / 1000 % 1000); + version->set_patch(GOOGLE_PROTOBUF_VERSION % 1000); + version->set_suffix(GOOGLE_PROTOBUF_VERSION_SUFFIX); + // Invoke the plugin. Subprocess subprocess; @@ -1737,11 +1784,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 +1796,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 +1841,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 +1900,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 +1936,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 +1967,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..8f8c2682 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,14 +356,19 @@ 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_; + // If there's a violation of depend-on-what-you-import, this string will be + // presented to the user. "%s" will be replaced with the violating import. + string direct_dependencies_violation_msg_; + // output_directives_ lists all the files we are supposed to output and what // generator to use for each. struct OutputDirective { @@ -374,7 +377,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..cce1018a 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -57,6 +57,7 @@ #include <google/protobuf/io/printer.h> #include <google/protobuf/unittest.pb.h> #include <google/protobuf/testing/file.h> +#include <google/protobuf/stubs/stringprintf.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/substitute.h> @@ -100,6 +101,7 @@ class CommandLineInterfaceTest : public testing::Test { // command is automatically split on spaces, and the string "$tmpdir" // is replaced with TestTempDir(). void Run(const string& command); + void RunWithArgs(vector<string> args); // ----------------------------------------------------------------- // Methods to set up the test (called before Run()). @@ -217,7 +219,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,8 +293,10 @@ void CommandLineInterfaceTest::TearDown() { } void CommandLineInterfaceTest::Run(const string& command) { - vector<string> args = Split(command, " ", true); + RunWithArgs(Split(command, " ", true)); +} +void CommandLineInterfaceTest::RunWithArgs(vector<string> args) { if (!disallow_plugins_) { cli_.AllowPlugins("prefix-"); #ifndef GOOGLE_THIRD_PARTY_PROTOBUF @@ -685,10 +689,36 @@ TEST_F(CommandLineInterfaceTest, UnrecognizedExtraParameters) { "message Foo {}\n"); Run("protocol_compiler --plug_out=TestParameter:$tmpdir " + "--unknown_plug_a_opt=Foo " + "--unknown_plug_b_opt=Bar " + "--proto_path=$tmpdir foo.proto"); + + ExpectErrorSubstring("Unknown flag: --unknown_plug_a_opt"); + ExpectErrorSubstring("Unknown flag: --unknown_plug_b_opt"); +} + +TEST_F(CommandLineInterfaceTest, ExtraPluginParametersForOutParameters) { + // This doesn't rely on the plugin having been registred and instead that + // the existence of --[name]_out is enough to make the --[name]_opt valid. + // However, running out of process plugins found via the search path (i.e. - + // not pre registered with --plugin) isn't support in this test suite, so we + // list the options pre/post the _out directive, and then include _opt that + // will be unknown, and confirm the failure output is about the expected + // unknown directive, which means the other were accepted. + // NOTE: UnrecognizedExtraParameters confirms that if two unknown _opt + // directives appear, they both are reported. + + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "message Foo {}\n"); + + Run("protocol_compiler --plug_out=TestParameter:$tmpdir " + "--xyz_opt=foo=bar --xyz_out=$tmpdir " + "--abc_out=$tmpdir --abc_opt=foo=bar " "--unknown_plug_opt=Foo " "--proto_path=$tmpdir foo.proto"); - ExpectErrorSubstring("Unknown flag: --unknown_plug_opt"); + ExpectErrorText("Unknown flag: --unknown_plug_opt\n"); } TEST_F(CommandLineInterfaceTest, Insert) { @@ -759,7 +789,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__) @@ -995,6 +1025,27 @@ TEST_F(CommandLineInterfaceTest, DirectDependencies_ProvidedMultipleTimes) { "':'.\n"); } +TEST_F(CommandLineInterfaceTest, DirectDependencies_CustomErrorMessage) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"bar.proto\";\n" + "message Foo { optional Bar bar = 1; }"); + CreateTempFile("bar.proto", + "syntax = \"proto2\";\n" + "message Bar { optional string text = 1; }"); + + vector<string> commands; + commands.push_back("protocol_compiler"); + commands.push_back("--test_out=$tmpdir"); + commands.push_back("--proto_path=$tmpdir"); + commands.push_back("--direct_dependencies="); + commands.push_back("--direct_dependencies_violation_msg=Bla \"%s\" Bla"); + commands.push_back("foo.proto"); + RunWithArgs(commands); + + ExpectErrorText("foo.proto: Bla \"bar.proto\" Bla\n"); +} + TEST_F(CommandLineInterfaceTest, CwdRelativeInputs) { // Test that we can accept working-directory-relative input files. @@ -1282,6 +1333,19 @@ TEST_F(CommandLineInterfaceTest, ParseErrorsMultipleFiles) { "foo.proto: Import \"baz.proto\" was not found or had errors.\n"); } +TEST_F(CommandLineInterfaceTest, RecursiveImportFails) { + // Create a proto file that imports itself. + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"foo.proto\";\n"); + + Run("protocol_compiler --test_out=$tmpdir " + "--proto_path=$tmpdir foo.proto"); + + ExpectErrorSubstring( + "foo.proto: File recursively imports itself: foo.proto -> foo.proto\n"); +} + TEST_F(CommandLineInterfaceTest, InputNotFoundError) { // Test what happens if the input file is not found. @@ -1582,6 +1646,21 @@ TEST_F(CommandLineInterfaceTest, PluginReceivesJsonName) { ExpectErrorSubstring("Saw json_name: 1"); } +TEST_F(CommandLineInterfaceTest, PluginReceivesCompilerVersion) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "message MockCodeGenerator_ShowVersionNumber {\n" + " optional int32 value = 1;\n" + "}\n"); + + Run("protocol_compiler --plug_out=$tmpdir --proto_path=$tmpdir foo.proto"); + + ExpectErrorSubstring( + StringPrintf("Saw compiler_version: %d %s", + GOOGLE_PROTOBUF_VERSION, + GOOGLE_PROTOBUF_VERSION_SUFFIX)); +} + TEST_F(CommandLineInterfaceTest, GeneratorPluginNotFound) { // Test what happens if the plugin isn't found. @@ -1856,7 +1935,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..6a8a83d1 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,38 @@ 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 " : ""; + vars["file_namespace"] = FileLevelNamespace(descriptor_->file()->name()); 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" + " $file_namespace$::protobuf_AssignDescriptorsOnce();\n" + " return " + "$file_namespace$::file_level_enum_descriptors[$index_in_metadata$];\n" + "}\n"); } printer->Print(vars, @@ -266,13 +271,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..e4b17a98 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_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"); } @@ -435,7 +436,7 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { "}\n"); } printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"); if (descriptor_->is_packed()) { printer->Print(variables_, " ::google::protobuf::internal::WireFormatLite::WriteEnumNoTag(\n" @@ -463,7 +464,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { "}\n"); } printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"); if (descriptor_->is_packed()) { printer->Print(variables_, " target = ::google::protobuf::internal::WireFormatLite::WriteEnumNoTagToArray(\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 369497ce..0e5e2f18 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,26 +280,59 @@ 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", message_generators_[i]->classname_); + printer->Indent(); + message_generators_[i]->GenerateExtraDefaultFields(printer); + printer->Outdent(); + printer->Print( + "} _$classname$_default_instance_;\n", + "classname", message_generators_[i]->classname_); + } + + for (int i = 0; i < message_generators_.size(); i++) { + message_generators_[i]->index_in_metadata_ = i; + } + 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 < service_generators_.size(); i++) { + service_generators_[i]->index_in_metadata_ = i; + } + } + + printer->Print( + "\n" + "namespace $file_namespace$ {\n" + "\n", + "file_namespace", FileLevelNamespace(file_->name())); + 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_)) { - for (int i = 0; i < file_->service_count(); i++) { - printer->Print( - "const ::google::protobuf::ServiceDescriptor* $name$_descriptor_ = NULL;\n", - "name", file_->service(i)->name()); - } + 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())); } printer->Print( @@ -329,27 +345,19 @@ void FileGenerator::GenerateSource(io::Printer* printer) { // library, all this does is initialize default instances.) GenerateBuildDescriptors(printer); + printer->Print( + "\n" + "} // namespace $file_namespace$\n" + "\n", + "file_namespace", FileLevelNamespace(file_->name())); + // 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 +372,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 +381,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 +399,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 +416,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 + void Print(io::Printer* printer, const Options& options) const { + for (std::map<string, const EnumDescriptor *>::const_iterator it = enums_.begin(), end = enums_.end(); it != end; ++it) { @@ -420,19 +429,30 @@ 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" + "$dllexport_decl$" + "extern $classname$DefaultTypeInternal " + "_$classname$_default_instance_;\n", // NOLINT + "dllexport_decl", + options.dllexport_decl.empty() ? "" : options.dllexport_decl + " ", + "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) { printer->Print("namespace $nsname$ {\n", "nsname", it->first); - it->second->Print(printer); + it->second->Print(printer, options); printer->Print("} // namespace $nsname$\n", "nsname", it->first); } @@ -440,9 +460,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 +485,112 @@ 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())); - - // 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()); + if (!message_generators_.empty()) { + printer->Print("const ::google::protobuf::uint32 TableStruct::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->Print( + "};\n" + "\n" + "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" + "\nstatic " + "::google::protobuf::Message const * const 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; - // 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( + "reinterpret_cast<const " + "::google::protobuf::Message*>(&_$classname$_default_instance_),\n", + "classname", ClassName(descriptor, false)); } + printer->Outdent(); + printer->Print( + "};\n" + "\n"); + } else { + // we still need these symbols to exist + printer->Print( + // MSVC doesn't like empty arrays, so we add a dummy. + "const ::google::protobuf::uint32 TableStruct::offsets[] = { ~0u };\n" + "static const ::google::protobuf::internal::MigrationSchema* schemas = NULL;\n" + "static const ::google::protobuf::Message* const* " + "file_default_instances = NULL;\n"); } - 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. + " AddDescriptors();\n" + " ::google::protobuf::MessageFactory* factory = $factory$;\n" + " AssignDescriptors(\n" + " \"$filename$\", schemas, file_default_instances, " + "TableStruct::offsets, 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. + "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); } @@ -549,11 +606,10 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // ShutdownFile(): Deletes descriptors, default instances, etc. on shutdown. printer->Print( "\n" - "void $shutdownfilename$() {\n", - "shutdownfilename", GlobalShutdownFileName(file_->name())); + "void TableStruct::Shutdown() {\n"); 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); } @@ -563,13 +619,12 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // ----------------------------------------------------------------- - // Now generate the InitDefaults() function. + // Now generate the InitDefaultsImpl() function. printer->Print( - "void $initdefaultsname$_impl() {\n" - " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" - "\n", - // Vars. - "initdefaultsname", GlobalInitDefaultsName(file_->name())); + "void TableStruct::InitDefaultsImpl() {\n" + " GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n" + // Force initialization of primitive values we depend on. + " ::google::protobuf::internal::InitProtobufDefaults();\n"); printer->Indent(); @@ -578,48 +633,40 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { for (int i = 0; i < file_->dependency_count(); i++) { const FileDescriptor* dependency = file_->dependency(i); // Print the namespace prefix for the dependency. - string add_desc_name = QualifiedFileLevelSymbol( - dependency->package(), GlobalInitDefaultsName(dependency->name())); + string file_namespace = QualifiedFileLevelSymbol( + dependency->package(), FileLevelNamespace(dependency->name())); // Call its AddDescriptors function. - printer->Print( - "$name$();\n", - "name", add_desc_name); + printer->Print("$file_namespace$::InitDefaults();\n", "file_namespace", + file_namespace); } // 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" - "}\n", - "initdefaultsname", GlobalInitDefaultsName(file_->name())); + "void InitDefaults() {\n" + " static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n" + " ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);\n" + "}\n"); // ----------------------------------------------------------------- // Now generate the AddDescriptors() function. printer->Print( - "void $adddescriptorsname$_impl() {\n" - " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" - "\n" - " $initdefaultsname$();\n", - // Vars. - "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), - "initdefaultsname", GlobalInitDefaultsName(file_->name())); + "void AddDescriptorsImpl() {\n" + " InitDefaults();\n"); printer->Indent(); if (HasDescriptorMethods(file_, options_)) { @@ -632,60 +679,37 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { string file_data; file_proto.SerializeToString(&file_data); -#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(); + printer->Print("static const char descriptor[] = {\n"); + printer->Indent(); - // Only write 25 bytes per line. + if (file_data.size() > 66535) { + // 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( @@ -699,27 +723,24 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { for (int i = 0; i < file_->dependency_count(); i++) { const FileDescriptor* dependency = file_->dependency(i); // Print the namespace prefix for the dependency. - string add_desc_name = QualifiedFileLevelSymbol( - dependency->package(), GlobalAddDescriptorsName(dependency->name())); + string file_namespace = QualifiedFileLevelSymbol( + dependency->package(), FileLevelNamespace(dependency->name())); // Call its AddDescriptors function. - printer->Print("$adddescriptorsname$();\n", "adddescriptorsname", - add_desc_name); + printer->Print("$file_namespace$::AddDescriptors();\n", "file_namespace", + file_namespace); } printer->Print( - "::google::protobuf::internal::OnShutdown(&$shutdownfilename$);\n", - "shutdownfilename", GlobalShutdownFileName(file_->name())); + "::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);\n"); printer->Outdent(); printer->Print( "}\n" "\n" - "GOOGLE_PROTOBUF_DECLARE_ONCE($adddescriptorsname$_once_);\n" - "void $adddescriptorsname$() {\n" - " ::google::protobuf::GoogleOnceInit(&$adddescriptorsname$_once_,\n" - " &$adddescriptorsname$_impl);\n" - "}\n", - "adddescriptorsname", GlobalAddDescriptorsName(file_->name())); + "void AddDescriptors() {\n" + " static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n" + " ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);\n" + "}\n"); if (!StaticInitializersForced(file_, options_)) { printer->Print("#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); @@ -727,14 +748,11 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { printer->Print( // With static initializers. "// Force AddDescriptors() to be called at static initialization time.\n" - "struct StaticDescriptorInitializer_$filename$ {\n" - " StaticDescriptorInitializer_$filename$() {\n" - " $adddescriptorsname$();\n" + "struct StaticDescriptorInitializer {\n" + " StaticDescriptorInitializer() {\n" + " AddDescriptors();\n" " }\n" - "} static_descriptor_initializer_$filename$_;\n", - // Vars. - "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), "filename", - FilenameIdentifier(file_->name())); + "} static_descriptor_initializer;\n"); if (!StaticInitializersForced(file_, options_)) { printer->Print("#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); } @@ -765,7 +783,7 @@ void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) { dependency.FillForwardDeclarations(&decls); } FillForwardDeclarations(&decls); - decls.Print(printer); + decls.Print(printer, options_); } void FileGenerator::FillForwardDeclarations(ForwardDeclarations* decls) { @@ -777,14 +795,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()); } @@ -838,14 +853,13 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { // OK, it's now safe to #include other files. 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/io/coded_stream.h>\n" + "#include <google/protobuf/arena.h>\n" + "#include <google/protobuf/arenastring.h>\n" + "#include <google/protobuf/generated_message_util.h>\n" "#include <google/protobuf/metadata.h>\n"); - } - if (file_->message_type_count() > 0) { + + if (!message_generators_.empty()) { if (HasDescriptorMethods(file_, options_)) { printer->Print( "#include <google/protobuf/message.h>\n"); @@ -855,8 +869,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 +900,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 +926,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()); } @@ -936,40 +952,27 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations( // functions, so that we can declare them to be friends of each class. printer->Print( "\n" + "namespace $file_namespace$ {\n" "// Internal implementation detail -- do not call these.\n" - "void $dllexport_decl$$adddescriptorsname$();\n" - "void $dllexport_decl$$initdefaultsname$();\n", - "initdefaultsname", GlobalInitDefaultsName(file_->name()), - "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), - "dllexport_decl", + "struct $dllexport_decl$TableStruct {\n" + " static const ::google::protobuf::uint32 offsets[];\n" + // The following function(s) need to be able to access private members of + // the messages defined in the file. So we make them static members. + // This is the internal implementation of InitDefaults. It should only + // be called by InitDefaults which makes sure it will be called only once. + " static void InitDefaultsImpl();\n" + " static void Shutdown();\n" + "};\n" + "void $dllexport_decl$AddDescriptors();\n" + "void $dllexport_decl$InitDefaults();\n" + "} // namespace $file_namespace$\n", + "file_namespace", FileLevelNamespace(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 +984,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 +992,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 +1008,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 +1052,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 +1062,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 +1085,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..3c4dddc5 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())"; @@ -440,23 +440,8 @@ string FilenameIdentifier(const string& filename) { return result; } -// Return the name of the AddDescriptors() function for a given file. -string GlobalAddDescriptorsName(const string& filename) { - return "protobuf_AddDesc_" + FilenameIdentifier(filename); -} - -string GlobalInitDefaultsName(const string& filename) { - return "protobuf_InitDefaults_" + FilenameIdentifier(filename); -} - -// Return the name of the AssignDescriptors() function for a given file. -string GlobalAssignDescriptorsName(const string& filename) { - return "protobuf_AssignDesc_" + FilenameIdentifier(filename); -} - -// Return the name of the ShutdownFile() function for a given file. -string GlobalShutdownFileName(const string& filename) { - return "protobuf_ShutdownFile_" + FilenameIdentifier(filename); +string FileLevelNamespace(const string& filename) { + return "protobuf_" + FilenameIdentifier(filename); } // Return the qualified C++ name for a file level symbol. @@ -602,7 +587,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 +637,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 +647,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..0f297ec8 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -144,21 +144,13 @@ string DefaultValue(const FieldDescriptor* field); // Convert a file name into a valid identifier. string FilenameIdentifier(const string& filename); -// Return the name of the AddDescriptors() function for a given file. -string GlobalAddDescriptorsName(const string& filename); - -// Return the name of the InitDefaults() function for a given file. -string GlobalInitDefaultsName(const string& filename); - -// Return the name of the AssignDescriptors() function for a given file. -string GlobalAssignDescriptorsName(const string& filename); +// For each .proto file generates a unique namespace. In this namespace global +// definitions are put to prevent collisions. +string FileLevelNamespace(const string& filename); // Return the qualified C++ name for a file level symbol. string QualifiedFileLevelSymbol(const string& package, const string& name); -// Return the name of the ShutdownFile() function for a given file. -string GlobalShutdownFileName(const string& filename); - // Escape C++ trigraphs by escaping question marks to \? string EscapeTrigraphs(const string& to_escape); @@ -269,13 +261,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..b4eaf485 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc @@ -45,10 +45,12 @@ 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)["file_namespace"] = + FileLevelNamespace(descriptor->file()->name()); (*variables)["stream_writer"] = (*variables)["declared_type"] + (HasFastArraySerialization(descriptor->message_type()->file(), options) @@ -137,7 +139,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 +156,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 +175,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" + " $file_namespace$::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 +232,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 +260,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 +299,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 +320,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..b4f1adfd 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 // =================================================================== @@ -485,6 +505,7 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, classname_(ClassName(descriptor, false)), options_(options), field_generators_(descriptor, options), + max_has_bit_index_(0), nested_generators_(new google::protobuf::scoped_ptr< MessageGenerator>[descriptor->nested_type_count()]), enum_generators_( @@ -500,7 +521,21 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, optimized_order_.push_back(descriptor_->field(i)); } } - OptimizePadding(&optimized_order_); + OptimizePadding(&optimized_order_, options_); + + if (HasFieldPresence(descriptor_->file())) { + // We use -1 as a sentinel. + 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()] = max_has_bit_index_++; + } + } for (int i = 0; i < descriptor->nested_type_count(); i++) { nested_generators_[i].reset( @@ -534,48 +569,41 @@ 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 { + size_t sizeof_has_bits = (max_has_bit_index_ + 31) / 32 * 4; + if (sizeof_has_bits == 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 +613,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)) { @@ -602,12 +630,32 @@ GenerateDependentFieldAccessorDeclarations(io::Printer* printer) { void MessageGenerator:: GenerateFieldAccessorDeclarations(io::Printer* printer) { + // optimized_fields_ does not contain fields where + // field->containing_oneof() != NULL + // so we need to iterate over those as well. + // + // We place the non-oneof fields in optimized_order_, as that controls the + // order of the _has_bits_ entries and we want GDB's pretty printers to be + // able to infer these indices from the k[FIELDNAME]FieldNumber order. + std::vector<const FieldDescriptor*> ordered_fields; + ordered_fields.reserve(descriptor_->field_count()); + + ordered_fields.insert( + ordered_fields.begin(), optimized_order_.begin(), optimized_order_.end()); for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); + if (field->containing_oneof() == NULL) { + continue; + } + ordered_fields.push_back(field); + } + + for (int i = 0; i < ordered_fields.size(); i++) { + const FieldDescriptor* field = ordered_fields[i]; PrintFieldComment(printer, field); - map<string, string> vars; + std::map<string, string> vars; SetCommonFieldVariables(field, &vars, options_); vars["constant_name"] = FieldConstantName(field); @@ -679,6 +727,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 +738,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 +775,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 +824,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 +846,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 +868,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 +916,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 +978,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 +1004,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 +1050,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 +1072,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 +1121,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 +1147,78 @@ 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" - " 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; - } + "::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\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(\n" + " ::google::protobuf::io::CodedOutputStream::" + "IsDefaultSerializationDeterministic(), output);\n" + "}\n"); } } 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 +1229,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 +1237,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 +1317,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 +1355,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 +1379,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 +1405,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 @@ -1477,79 +1457,41 @@ GenerateClassDefinition(io::Printer* printer) { "::google::protobuf::internal::AnyMetadata _any_metadata_;\n"); } - // Declare AddDescriptors(), BuildDescriptors(), and ShutdownFile() as - // friends so that they can access private static variables like - // default_instance_ and reflection_. - printer->Print("friend void $dllexport_decl$ $initdefaultsname$_impl();\n", - // Vars. - "dllexport_decl", options_.dllexport_decl, "initdefaultsname", - GlobalInitDefaultsName(descriptor_->file()->name())); - printer->Print("friend void $dllexport_decl$ $adddescriptorsname$_impl();\n", - // Vars. - "dllexport_decl", options_.dllexport_decl, - "adddescriptorsname", - GlobalAddDescriptorsName(descriptor_->file()->name())); - + // The TableStruct struct needs access to the private parts, in order to + // construct the offsets of all members. + // Some InitDefault and Shutdown are defined as static member functions of + // TableStruct such that they are also allowed to access private members. 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 struct $dllexport_decl$ $file_namespace$::TableStruct;\n", + // Vars. + "dllexport_decl", options_.dllexport_decl, "file_namespace", + FileLevelNamespace(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,36 +1507,16 @@ 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_); - } - +GenerateExtraDefaultFields(io::Printer* printer) { // Generate oneof default instance for reflection usage. if (descriptor_->oneof_decl_count() > 0) { - printer->Print("struct $name$OneofInstance {\n", - "name", classname_); + printer->Print("public:\n"); for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); - printer->Print(" "); if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING && EffectiveStringCType(field) != FieldOptions::STRING)) { @@ -1603,143 +1525,33 @@ GenerateDescriptorDeclarations(io::Printer* printer) { field_generators_.get(field).GeneratePrivateMembers(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)); } } -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); - - 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"); - } + std::map<string, string> vars; - 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_; + vars["file_namespace"] = FileLevelNamespace(descriptor_->file()->name()); const FieldDescriptor* val = descriptor_->FindFieldByName("value"); if (descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO2 && @@ -1750,31 +1562,28 @@ 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_namespace$::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 +1592,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_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,28 +1653,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) { - // mutable_unknown_fields wrapper function for LazyStringOutputStream - // callback. - if (PreserveUnknownFields(descriptor_) && - !UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "static ::std::string* MutableUnknownFieldsFor$classname$(\n" - " $classname$* ptr) {\n" - " return ptr->mutable_unknown_fields();\n" - "}\n" - "\n", - "classname", classname_); - } + if (IsMapEntryMessage(descriptor_)) return; + if (IsAnyMessage(descriptor_)) { printer->Print( "void $classname$::PackFrom(const ::google::protobuf::Message& message) {\n" @@ -1888,21 +1677,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 +1696,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 +1730,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 +1737,13 @@ 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" + " $file_namespace$::protobuf_AssignDescriptorsOnce();\n" + " return $file_namespace$::file_level_metadata[$index$];\n" + "}\n" + "\n", + "classname", classname_, "index", SimpleItoa(index_in_metadata_), + "file_namespace", FileLevelNamespace(descriptor_->file()->name())); } else { printer->Print( "::std::string $classname$::GetTypeName() const {\n" @@ -1995,22 +1756,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_instance_), $name$_),\n", + "classname", classname_, "name", FieldName(field)); } else { printer->Print( "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, " @@ -2028,8 +1816,16 @@ 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++) { + const string index = has_bit_indices_[i] >= 0 ? + SimpleItoa(has_bit_indices_[i]) : "~0u"; + printer->Print("$index$,\n", "index", index); + } + } + + return std::make_pair(entries, offsets); } void MessageGenerator:: @@ -2043,66 +1839,27 @@ 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_namespace$::file_level_metadata[$index$].descriptor;\n", + "type", ClassName(descriptor_->nested_type(i), false), "index", + SimpleItoa(nested_generators_[i]->index_in_metadata_), + "file_namespace", FileLevelNamespace(descriptor_->file()->name())); } } + 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 +1890,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 +1906,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 +1932,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 +1977,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 +2061,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 +2079,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,13 +2087,15 @@ 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" + " $file_namespace$::InitDefaults();\n" + " }\n" " SharedCtor();\n" " // @@protoc_insertion_point(constructor:$full_name$)\n" "}\n", "classname", classname_, "superclass", superclass, "full_name", descriptor_->full_name(), "initializer", initializer_null, - "initdefaultsname", GlobalInitDefaultsName(descriptor_->file()->name())); + "file_namespace", FileLevelNamespace(descriptor_->file()->name())); if (SupportsArenas(descriptor_)) { printer->Print( @@ -2306,7 +2104,7 @@ GenerateStructors(io::Printer* printer) { // When arenas are used it's safe to assume we have finished // static init time (protos with arenas are unsafe during static init) "#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n" - " $initdefaultsname$();\n" + " $file_namespace$::InitDefaults();\n" "#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n" " SharedCtor();\n" " RegisterArenaDtor(arena);\n" @@ -2314,47 +2112,8 @@ GenerateStructors(io::Printer* printer) { "}\n", "initializer", initializer_with_arena, "classname", classname_, "superclass", superclass, "full_name", descriptor_->full_name(), - "initdefaultsname", - 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); - } + "file_namespace", FileLevelNamespace(descriptor_->file()->name())); } - printer->Print( - "}\n" - "\n"); // Generate the copy constructor. printer->Print( @@ -2363,24 +2122,114 @@ 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_namespace$::file_level_metadata[$index$].descriptor;\n", + "type", ClassName(descriptor_->nested_type(i), false), "index", + SimpleItoa(nested_generators_[i]->index_in_metadata_), + "file_namespace", FileLevelNamespace(descriptor_->file()->name())); + } + } + + 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. @@ -2418,28 +2267,21 @@ GenerateStructors(io::Printer* printer) { !descriptor_->options().no_standard_descriptor_accessor()) { printer->Print( "const ::google::protobuf::Descriptor* $classname$::descriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" + " $file_namespace$::protobuf_AssignDescriptorsOnce();\n" + " return $file_namespace$::file_level_metadata[$index$].descriptor;\n" "}\n" "\n", - "classname", classname_, "initdefaultsname", - GlobalInitDefaultsName(descriptor_->file()->name())); + "index", SimpleItoa(index_in_metadata_), "classname", classname_, + "file_namespace", FileLevelNamespace(descriptor_->file()->name())); } printer->Print( "const $classname$& $classname$::default_instance() {\n" - " $initdefaultsname$();\n" + " $file_namespace$::InitDefaults();\n" " return *internal_default_instance();\n" - "}\n", - "classname", classname_, "initdefaultsname", - GlobalInitDefaultsName(descriptor_->file()->name())); - - printer->Print( - "\n" - "::google::protobuf::internal::ExplicitlyConstructed<$classname$> " - "$classname$_default_instance_;\n" - "\n", - "classname", classname_); + "}\n\n", + "classname", classname_, "file_namespace", + FileLevelNamespace(descriptor_->file()->name())); if (SupportsArenas(descriptor_)) { printer->Print( @@ -2484,154 +2326,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 +2510,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 +2521,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 +2587,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 +2617,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); } @@ -2783,19 +2633,14 @@ GenerateSwap(io::Printer* printer) { } if (HasFieldPresence(descriptor_->file())) { - for (int i = 0; i < (descriptor_->field_count() + 31) / 32; ++i) { + for (int i = 0; i < HasBitsSize() / 4; ++i) { printer->Print("std::swap(_has_bits_[$i$], other->_has_bits_[$i$]);\n", "i", SimpleItoa(i)); } } - // 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 +2664,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 +2683,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 +2705,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 +2850,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 +2886,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,8 +2927,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) { // on the CodedOutputStream. printer->Print( " ::google::protobuf::io::LazyStringOutputStream unknown_fields_string(\n" - " ::google::protobuf::NewPermanentCallback(\n" - " &MutableUnknownFieldsFor$classname$, this));\n" + " ::google::protobuf::NewPermanentCallback(&_internal_metadata_,\n" + " &::google::protobuf::internal::InternalMetadataWithArenaLite::mutable_unknown_fields));\n" " ::google::protobuf::io::CodedOutputStream unknown_fields_stream(\n" " &unknown_fields_string, false);\n", "classname", classname_); @@ -3082,13 +2948,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 +2992,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 +3015,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 +3028,12 @@ 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 (static_cast<::google::protobuf::uint8>(tag) ==\n" + " static_cast<::google::protobuf::uint8>($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 +3048,8 @@ 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 (static_cast<::google::protobuf::uint8>(tag) ==\n" + " static_cast<::google::protobuf::uint8>($uncommontag$u)) {\n", "uncommontag", SimpleItoa( internal::WireFormatLite::MakeTag( field->number(), wiretype))); @@ -3175,7 +3059,8 @@ 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 (static_cast<::google::protobuf::uint8>(tag) ==\n" + " static_cast<::google::protobuf::uint8>($uncommontag$u)) {\n", "uncommontag", SimpleItoa( internal::WireFormatLite::MakeTag( field->number(), wiretype))); @@ -3189,87 +3074,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 +3190,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 +3258,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, @@ -3458,7 +3266,7 @@ void MessageGenerator::GenerateSerializeOneExtensionRange( if (to_array) { printer->Print(vars, "target = _extensions_.InternalSerializeWithCachedSizesToArray(\n" - " $start$, $end$, false, target);\n\n"); + " $start$, $end$, deterministic, target);\n\n"); } else { printer->Print(vars, "_extensions_.SerializeWithCachedSizes(\n" @@ -3533,7 +3341,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) { "classname", classname_); printer->Indent(); - printer->Print("(void)deterministic; // Unused\n"); + printer->Print("(void)deterministic; // Unused\n"); printer->Print( "// @@protoc_insertion_point(serialize_to_array_start:$full_name$)\n", "full_name", descriptor_->full_name()); @@ -3600,7 +3408,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 +3471,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 +3542,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 +3570,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 +3616,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 +3629,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 +3783,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 +3806,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 +3847,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 +3913,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..1a804a16 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); @@ -95,13 +91,8 @@ class MessageGenerator { // Source file stuff. - // Generate code which declares all the global descriptor pointers which - // 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 extra fields + void GenerateExtraDefaultFields(io::Printer* printer); // Generate code that calls MessageFactory::InternalRegisterGeneratedMessage() // for all types. @@ -130,8 +121,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 +161,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 +170,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 +198,18 @@ 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_; + int max_has_bit_index_; 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..c3d1745c 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,23 @@ GenerateClearingCode(io::Printer* printer) const { } void MessageFieldGenerator:: +GenerateMessageClearingCode(io::Printer* printer) const { + 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 +514,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 +638,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 +658,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 +672,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 +850,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 +864,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 +951,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 +982,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 +1005,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_) { @@ -966,7 +1032,6 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, "}\n"); } - if (!dependent_field_) { printer->Print(variables, "$inline$" @@ -989,7 +1054,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..4a0a23f6 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_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:: @@ -368,6 +373,7 @@ GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const { void RepeatedPrimitiveFieldGenerator:: GenerateSerializeWithCachedSizes(io::Printer* printer) const { + bool array_written = false; if (descriptor_->is_packed()) { // Write the tag and the size. printer->Print(variables_, @@ -376,21 +382,30 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { "$number$, " "::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, " "output);\n" - " output->WriteVarint32(_$name$_cached_byte_size_);\n" - "}\n"); + " output->WriteVarint32(_$name$_cached_byte_size_);\n"); + + if (FixedSize(descriptor_->type()) > 0) { + printer->Print(variables_, + " ::google::protobuf::internal::WireFormatLite::Write$declared_type$Array(\n" + " this->$name$().data(), this->$name$_size(), output);\n"); + array_written = true; // Wrote array all at once + } + printer->Print(variables_, "}\n"); } - printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); - if (descriptor_->is_packed()) { - printer->Print(variables_, - " ::google::protobuf::internal::WireFormatLite::Write$declared_type$NoTag(\n" - " this->$name$(i), output);\n"); - } else { + if (!array_written) { printer->Print(variables_, - " ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\n" - " $number$, this->$name$(i), output);\n"); + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"); + if (descriptor_->is_packed()) { + printer->Print(variables_, + " ::google::protobuf::internal::WireFormatLite::Write$declared_type$NoTag(\n" + " this->$name$(i), output);\n"); + } else { + printer->Print(variables_, + " ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\n" + " $number$, this->$name$(i), output);\n"); + } + printer->Print("}\n"); } - printer->Print("}\n"); } void RepeatedPrimitiveFieldGenerator:: @@ -408,7 +423,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { "}\n"); } printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"); if (descriptor_->is_packed()) { printer->Print(variables_, " target = ::google::protobuf::internal::WireFormatLite::\n" @@ -423,21 +438,17 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { void RepeatedPrimitiveFieldGenerator:: GenerateByteSize(io::Printer* printer) const { - printer->Print(variables_, - "{\n" - " size_t data_size = 0;\n" - " unsigned int count = this->$name$_size();\n"); + printer->Print(variables_, "{\n"); printer->Indent(); int fixed_size = FixedSize(descriptor_->type()); if (fixed_size == -1) { printer->Print(variables_, - "for (unsigned int i = 0; i < count; i++) {\n" - " data_size += ::google::protobuf::internal::WireFormatLite::\n" - " $declared_type$Size(this->$name$(i));\n" - "}\n"); + "size_t data_size = ::google::protobuf::internal::WireFormatLite::\n" + " $declared_type$Size(this->$name$_);\n"); } else { printer->Print(variables_, - "data_size = $fixed_size$UL * count;\n"); + "unsigned int count = this->$name$_size();\n" + "size_t data_size = $fixed_size$UL * count;\n"); } if (descriptor_->is_packed()) { 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..95357d9f 100644 --- a/src/google/protobuf/compiler/cpp/cpp_service.cc +++ b/src/google/protobuf/compiler/cpp/cpp_service.cc @@ -46,6 +46,7 @@ ServiceGenerator::ServiceGenerator(const ServiceDescriptor* descriptor, const Options& options) : descriptor_(descriptor) { vars_["classname"] = descriptor_->name(); + vars_["file_namespace"] = FileLevelNamespace(descriptor_->file()->name()); vars_["full_name"] = descriptor_->full_name(); if (options.dllexport_decl.empty()) { vars_["dllexport"] = ""; @@ -143,7 +144,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 +162,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 +173,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" + " $file_namespace$::protobuf_AssignDescriptorsOnce();\n" + " return $file_namespace$::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 +214,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 +234,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_namespace$::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 +293,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 +316,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..664a2779 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"); } } @@ -140,7 +141,16 @@ GenerateAccessorDeclarations(io::Printer* printer) const { printer->Print(variables_, "$deprecated_attr$const ::std::string& $name$() const;\n" - "$deprecated_attr$void set_$name$(const ::std::string& value);\n" + "$deprecated_attr$void set_$name$(const ::std::string& value);\n"); + + if (!SupportsArenas(descriptor_)) { + printer->Print(variables_, + "#if LANG_CXX11\n" + "$deprecated_attr$void set_$name$(::std::string&& value);\n" + "#endif\n"); + } + + printer->Print(variables_, "$deprecated_attr$void set_$name$(const char* value);\n" "$deprecated_attr$void set_$name$(const $pointer_type$* value, size_t size)" ";\n" @@ -165,117 +175,129 @@ 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" + "#if LANG_CXX11\n" + "$inline$void $classname$::set_$name$(::std::string&& value) {\n" + " $set_hasbit$\n" + " $name$_.SetNoArena(\n" + " $default_variable$, ::std::move(value));\n" + " // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n" + "}\n" + "#endif\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 +306,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 +337,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 +406,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 +450,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 +460,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 +525,203 @@ 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" + "#if LANG_CXX11\n" + "$inline$void $classname$::set_$name$(::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(\n" + " $default_variable$, ::std::move(value));\n" + " // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n" + "}\n" + "#endif\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 +730,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 +749,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_instance_.$name$_.UnsafeSetDefault(\n" + " $default_variable$);\n"); } void StringOneofFieldGenerator:: @@ -707,17 +830,21 @@ GenerateAccessorDeclarations(io::Printer* printer) const { "$deprecated_attr$const ::std::string& $name$(int index) const;\n" "$deprecated_attr$::std::string* mutable_$name$(int index);\n" "$deprecated_attr$void set_$name$(int index, const ::std::string& value);\n" + "#if LANG_CXX11\n" + "$deprecated_attr$void set_$name$(int index, ::std::string&& value);\n" + "#endif\n" "$deprecated_attr$void set_$name$(int index, const char* value);\n" "" "$deprecated_attr$void set_$name$(" "int index, const $pointer_type$* value, size_t size);\n" "$deprecated_attr$::std::string* add_$name$();\n" "$deprecated_attr$void add_$name$(const ::std::string& value);\n" + "#if LANG_CXX11\n" + "$deprecated_attr$void add_$name$(::std::string&& value);\n" + "#endif\n" "$deprecated_attr$void add_$name$(const char* value);\n" "$deprecated_attr$void add_$name$(const $pointer_type$* value, size_t size)" - ";\n"); - - printer->Print(variables_, + ";\n" "$deprecated_attr$const ::google::protobuf::RepeatedPtrField< ::std::string>& $name$() " "const;\n" "$deprecated_attr$::google::protobuf::RepeatedPtrField< ::std::string>* mutable_$name$()" @@ -733,7 +860,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" @@ -748,6 +875,12 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " // @@protoc_insertion_point(field_set:$full_name$)\n" " $name$_.Mutable(index)->assign(value);\n" "}\n" + "#if LANG_CXX11\n" + "$inline$void $classname$::set_$name$(int index, ::std::string&& value) {\n" + " // @@protoc_insertion_point(field_set:$full_name$)\n" + " $name$_.Mutable(index)->assign(std::move(value));\n" + "}\n" + "#endif\n" "$inline$void $classname$::set_$name$(int index, const char* value) {\n" " $name$_.Mutable(index)->assign(value);\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" @@ -767,6 +900,12 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " $name$_.Add()->assign(value);\n" " // @@protoc_insertion_point(field_add:$full_name$)\n" "}\n" + "#if LANG_CXX11\n" + "$inline$void $classname$::add_$name$(::std::string&& value) {\n" + " $name$_.Add()->assign(std::move(value));\n" + " // @@protoc_insertion_point(field_add:$full_name$)\n" + "}\n" + "#endif\n" "$inline$void $classname$::add_$name$(const char* value) {\n" " $name$_.Add()->assign(value);\n" " // @@protoc_insertion_point(field_add_char:$full_name$)\n" @@ -775,8 +914,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, "$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n" " $name$_.Add()->assign(reinterpret_cast<const char*>(value), size);\n" " // @@protoc_insertion_point(field_add_pointer:$full_name$)\n" - "}\n"); - printer->Print(variables, + "}\n" "$inline$const ::google::protobuf::RepeatedPtrField< ::std::string>&\n" "$classname$::$name$() const {\n" " // @@protoc_insertion_point(field_list:$full_name$)\n" @@ -800,11 +938,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 +948,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" @@ -831,7 +969,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { void RepeatedStringFieldGenerator:: GenerateSerializeWithCachedSizes(io::Printer* printer) const { printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"); printer->Indent(); if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( @@ -848,7 +986,7 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { void RepeatedStringFieldGenerator:: GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"); printer->Indent(); if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( @@ -867,7 +1005,7 @@ GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, "total_size += $tag_size$ *\n" " ::google::protobuf::internal::FromIntSize(this->$name$_size());\n" - "for (int i = 0; i < this->$name$_size(); i++) {\n" + "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n" " total_size += ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n" " this->$name$(i));\n" "}\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..6d68ec35 100644 --- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc @@ -53,6 +53,7 @@ #include <vector> #include <google/protobuf/unittest.pb.h> +#include <google/protobuf/unittest_no_arena.pb.h> #include <google/protobuf/unittest_optimize_for.pb.h> #include <google/protobuf/unittest_embed_optimize_for.pb.h> #if !defined(GOOGLE_PROTOBUF_CMAKE_BUILD) && !defined(_MSC_VER) @@ -67,6 +68,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 +201,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()); } @@ -419,6 +421,71 @@ TEST(GeneratedMessageTest, StringCharStarLength) { EXPECT_EQ("wx", message.repeated_string(0)); } +#if LANG_CXX11 +TEST(GeneratedMessageTest, StringMove) { + // Verify that we trigger the move behavior on a scalar setter. + protobuf_unittest_no_arena::TestAllTypes message; + { + string tmp(32, 'a'); + + const char* old_data = tmp.data(); + message.set_optional_string(std::move(tmp)); + const char* new_data = message.optional_string().data(); + + EXPECT_EQ(old_data, new_data); + EXPECT_EQ(string(32, 'a'), message.optional_string()); + + string tmp2(32, 'b'); + old_data = tmp2.data(); + message.set_optional_string(std::move(tmp2)); + new_data = message.optional_string().data(); + + EXPECT_EQ(old_data, new_data); + EXPECT_EQ(string(32, 'b'), message.optional_string()); + } + + // Verify that we trigger the move behavior on a oneof setter. + { + string tmp(32, 'a'); + + const char* old_data = tmp.data(); + message.set_oneof_string(std::move(tmp)); + const char* new_data = message.oneof_string().data(); + + EXPECT_EQ(old_data, new_data); + EXPECT_EQ(string(32, 'a'), message.oneof_string()); + + string tmp2(32, 'b'); + old_data = tmp2.data(); + message.set_oneof_string(std::move(tmp2)); + new_data = message.oneof_string().data(); + + EXPECT_EQ(old_data, new_data); + EXPECT_EQ(string(32, 'b'), message.oneof_string()); + } + + // Verify that we trigger the move behavior on a repeated setter. + { + string tmp(32, 'a'); + + const char* old_data = tmp.data(); + message.add_repeated_string(std::move(tmp)); + const char* new_data = message.repeated_string(0).data(); + + EXPECT_EQ(old_data, new_data); + EXPECT_EQ(string(32, 'a'), message.repeated_string(0)); + + string tmp2(32, 'b'); + old_data = tmp2.data(); + message.set_repeated_string(0, std::move(tmp2)); + new_data = message.repeated_string(0).data(); + + EXPECT_EQ(old_data, new_data); + EXPECT_EQ(string(32, 'b'), message.repeated_string(0)); + } +} +#endif + TEST(GeneratedMessageTest, CopyFrom) { unittest::TestAllTypes message1, message2; @@ -518,6 +585,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 +687,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/csharp/csharp_doc_comment.cc b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc index 587e0222..636a76a0 100644 --- a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc +++ b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc @@ -74,7 +74,7 @@ void WriteDocCommentBodyImpl(io::Printer* printer, SourceLocation location) { printer->Print("///\n"); } last_was_empty = false; - printer->Print("/// $line$\n", "line", *it); + printer->Print("///$line$\n", "line", *it); } } printer->Print("/// </summary>\n"); diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index e2011b76..139cc753 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -122,8 +122,10 @@ void FieldGeneratorBase::GenerateCodecCode(io::Printer* printer) { } void FieldGeneratorBase::AddDeprecatedFlag(io::Printer* printer) { - if (descriptor_->options().deprecated()) - { + if (descriptor_->options().deprecated()) { + printer->Print("[global::System.ObsoleteAttribute]\n"); + } else if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE && + descriptor_->message_type()->options().deprecated()) { printer->Print("[global::System.ObsoleteAttribute]\n"); } } diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index 6c154c5a..5bca1ffa 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -38,6 +38,7 @@ #include <vector> #include <google/protobuf/compiler/csharp/csharp_helpers.h> +#include <google/protobuf/compiler/csharp/csharp_names.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/io/printer.h> #include <google/protobuf/wire_format.h> diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h index 1563ca7e..c317ad0e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.h +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h @@ -120,6 +120,22 @@ inline bool IsDescriptorProto(const FileDescriptor* descriptor) { return descriptor->name() == "google/protobuf/descriptor.proto"; } +// Determines whether the given message is an options message within descriptor.proto. +inline bool IsDescriptorOptionMessage(const Descriptor* descriptor) { + if (!IsDescriptorProto(descriptor->file())) { + return false; + } + const string name = descriptor->full_name(); + return name == "google.protobuf.FileOptions" || + name == "google.protobuf.MessageOptions" || + name == "google.protobuf.FieldOptions" || + name == "google.protobuf.OneofOptions" || + name == "google.protobuf.EnumOptions" || + name == "google.protobuf.EnumValueOptions" || + name == "google.protobuf.ServiceOptions" || + name == "google.protobuf.MethodOptions"; +} + inline bool IsWrapperType(const FieldDescriptor* descriptor) { return descriptor->type() == FieldDescriptor::TYPE_MESSAGE && descriptor->message_type()->file()->name() == "google/protobuf/wrappers.proto"; diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index ed744854..0f00a438 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -98,12 +98,20 @@ const std::vector<const FieldDescriptor*>& MessageGenerator::fields_by_number() return fields_by_number_; } +void MessageGenerator::AddDeprecatedFlag(io::Printer* printer) { + if (descriptor_->options().deprecated()) { + printer->Print("[global::System.ObsoleteAttribute]\n"); + } +} + void MessageGenerator::Generate(io::Printer* printer) { map<string, string> vars; vars["class_name"] = class_name(); vars["access_level"] = class_access_level(); WriteMessageDocComment(printer, descriptor_); + AddDeprecatedFlag(printer); + printer->Print( vars, "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$> {\n"); @@ -115,6 +123,7 @@ void MessageGenerator::Generate(io::Printer* printer) { "private static readonly pb::MessageParser<$class_name$> _parser = new pb::MessageParser<$class_name$>(() => new $class_name$());\n"); WriteGeneratedCodeAttributes(printer); + printer->Print( vars, "public static pb::MessageParser<$class_name$> Parser { get { return _parser; } }\n\n"); @@ -142,6 +151,12 @@ void MessageGenerator::Generate(io::Printer* printer) { " get { return Descriptor; }\n" "}\n" "\n"); + // CustomOptions property, only for options messages + if (IsDescriptorOptionMessage(descriptor_)) { + printer->Print( + "internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty;\n" + "\n"); + } // Parameterless constructor and partial OnConstruction method. WriteGeneratedCodeAttributes(printer); @@ -466,10 +481,18 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { " switch(tag) {\n"); printer->Indent(); printer->Indent(); - printer->Print( - "default:\n" - " input.SkipLastField();\n" // We're not storing the data, but we still need to consume it. - " break;\n"); + // Option messages need to store unknown fields so that options can be parsed later. + if (IsDescriptorOptionMessage(descriptor_)) { + printer->Print( + "default:\n" + " CustomOptions = CustomOptions.ReadOrSkipUnknownField(input);\n" + " break;\n"); + } else { + printer->Print( + "default:\n" + " input.SkipLastField();\n" // We're not storing the data, but we still need to consume it. + " break;\n"); + } for (int i = 0; i < fields_by_number().size(); i++) { const FieldDescriptor* field = fields_by_number()[i]; internal::WireFormatLite::WireType wt = diff --git a/src/google/protobuf/compiler/csharp/csharp_message.h b/src/google/protobuf/compiler/csharp/csharp_message.h index f794d68d..e7f3b4d0 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.h +++ b/src/google/protobuf/compiler/csharp/csharp_message.h @@ -69,6 +69,8 @@ class MessageGenerator : public SourceGeneratorBase { bool HasNestedGeneratedTypes(); + void AddDeprecatedFlag(io::Printer* printer); + std::string class_name(); std::string full_class_name(); diff --git a/src/google/protobuf/compiler/csharp/csharp_names.h b/src/google/protobuf/compiler/csharp/csharp_names.h index 30805187..21758f28 100644 --- a/src/google/protobuf/compiler/csharp/csharp_names.h +++ b/src/google/protobuf/compiler/csharp/csharp_names.h @@ -39,6 +39,7 @@ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__ #include <string> +#include <google/protobuf/stubs/port.h> namespace google { namespace protobuf { @@ -56,14 +57,14 @@ namespace csharp { // // Returns: // The namespace to use for given file descriptor. -string GetFileNamespace(const FileDescriptor* descriptor); +string LIBPROTOC_EXPORT GetFileNamespace(const FileDescriptor* descriptor); // Requires: // descriptor != NULL // // Returns: // The fully-qualified C# class name. -string GetClassName(const Descriptor* descriptor); +string LIBPROTOC_EXPORT GetClassName(const Descriptor* descriptor); // Requires: // descriptor != NULL @@ -72,7 +73,7 @@ string GetClassName(const Descriptor* descriptor); // The fully-qualified name of the C# class that provides // access to the file descriptor. Proto compiler generates // such class for each .proto file processed. -string GetReflectionClassName(const FileDescriptor* descriptor); +string LIBPROTOC_EXPORT GetReflectionClassName(const FileDescriptor* descriptor); // Generates output file name for given file descriptor. If generate_directories // is true, the output file will be put under directory corresponding to file's @@ -88,7 +89,7 @@ string GetReflectionClassName(const FileDescriptor* descriptor); // The file name to use as output file for given file descriptor. In case // of failure, this function will return empty string and error parameter // will contain the error message. -string GetOutputFile( +string LIBPROTOC_EXPORT GetOutputFile( const google::protobuf::FileDescriptor* descriptor, const string file_extension, const bool generate_directories, 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..50eed5da 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,13 +68,15 @@ 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 // by the proto compiler (*variables)["deprecation"] = descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; + (*variables)["required"] = descriptor->is_required() ? "true" : "false"; if (SupportFieldPresence(descriptor->file())) { // For singular messages and builders, one bit is used for the hasField bit. 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..86719f70 100644 --- a/src/google/protobuf/compiler/java/java_file.cc +++ b/src/google/protobuf/compiler/java/java_file.cc @@ -65,7 +65,7 @@ namespace java { namespace { struct FieldDescriptorCompare { - bool operator ()(const FieldDescriptor* f1, const FieldDescriptor* f2) { + bool operator ()(const FieldDescriptor* f1, const FieldDescriptor* f2) const { if(f1 == NULL) { return false; } @@ -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..0957676c 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"] = @@ -70,6 +70,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, // by the proto compiler (*variables)["deprecation"] = descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; + (*variables)["required"] = descriptor->is_required() ? "true" : "false"; if (SupportFieldPresence(descriptor->file())) { // For singular messages and builders, one bit is used for the hasField bit. 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..048d5892 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(); @@ -918,10 +928,10 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream( "com.google.protobuf.CodedInputStream input =\n" " (com.google.protobuf.CodedInputStream) arg0;\n" "com.google.protobuf.ExtensionRegistryLite extensionRegistry =\n" - " (com.google.protobuf.ExtensionRegistryLite) arg1;\n" + " (com.google.protobuf.ExtensionRegistryLite) arg1;\n"); + printer->Print( "try {\n"); printer->Indent(); - printer->Print( "boolean done = false;\n" "while (!done) {\n"); @@ -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..b04bf1c2 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,9 +70,11 @@ 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))); + (*variables)["required"] = descriptor->is_required() ? "true" : "false"; string capitalized_type = UnderscoresToCamelCase(PrimitiveTypeName(javaType), true /* cap_next_letter */); 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..7bd5ad7a 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,15 +179,13 @@ 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(); - string classname = FileJavaPackage(file_->dependency(i)) + "." + - name_resolver_->GetDescriptorClassName( - file_->dependency(i)); - dependencies.push_back(std::make_pair(filename, classname)); - } + string filename = file_->dependency(i)->name(); + string classname = FileJavaPackage(file_->dependency(i)) + "." + + name_resolver_->GetDescriptorClassName( + file_->dependency(i)); + dependencies.push_back(std::make_pair(filename, classname)); } // ----------------------------------------------------------------- @@ -209,11 +207,6 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) { " }, assigner);\n"); } -bool SharedCodeGenerator::ShouldIncludeDependency( - const FileDescriptor* descriptor) { - return true; -} - } // namespace java } // namespace compiler } // namespace protobuf 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..40502270 100644 --- a/src/google/protobuf/compiler/java/java_shared_code_generator.h +++ b/src/google/protobuf/compiler/java/java_shared_code_generator.h @@ -70,17 +70,13 @@ 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); private: - // Returns whether the dependency should be included in the output file. - // Always returns true for opensource, but used internally at Google to help - // improve compatibility with version 1 of protocol buffers. - bool ShouldIncludeDependency(const FileDescriptor* descriptor); - google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_; const FileDescriptor* file_; const Options options_; 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..138e59b6 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"] = @@ -84,6 +85,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, // by the proto compiler (*variables)["deprecation"] = descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; + (*variables)["required"] = descriptor->is_required() ? "true" : "false"; if (SupportFieldPresence(descriptor->file())) { // For singular messages and builders, one bit is used for the hasField bit. 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..57d38237 --- /dev/null +++ b/src/google/protobuf/compiler/js/embed.cc @@ -0,0 +1,112 @@ +// 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 <cassert> +#include <cstdlib> +#include <fstream> +#include <iostream> +#include <string> + +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 (size_t i = 0; i < str.size(); ++i) { + unsigned char ch = str[i]; + 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[]) { + std::cout << "#include " + "<google/protobuf/compiler/js/well_known_types_embed.h>\n"; + std::cout << "struct FileToc well_known_types_js[] = {\n"; + + for (int i = 1; i < argc; i++) { + AddFile(argv[i], &std::cout); + } + + std::cout << " {NULL, NULL} // Terminate the list.\n"; + std::cout << "};\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 58597b4c..727ed090 100755 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -28,7 +28,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "google/protobuf/compiler/js/js_generator.h" +#include <google/protobuf/compiler/js/js_generator.h> #include <assert.h> #include <algorithm> @@ -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,25 @@ 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); + } + + // Recurse on nested types. These must come *before* the extension-field + // info generation in GenerateClassRegistration so that extensions that + // reference nested types proceed the definitions of the nested types. + for (int i = 0; i < desc->enum_type_count(); i++) { + GenerateEnum(options, printer, desc->enum_type(i)); + } + for (int i = 0; i < desc->nested_type_count(); i++) { + GenerateClass(options, printer, desc->nested_type(i)); + } + + if (!NamespaceOnly(desc)) { GenerateClassRegistration(options, printer, desc); GenerateClassFields(options, printer, desc); if (IsExtendable(desc) && desc->full_name() != "google.protobuf.bridge.MessageSet") { @@ -1860,13 +1891,6 @@ void Generator::GenerateClass(const GeneratorOptions& options, } } - // Recurse on nested types. - for (int i = 0; i < desc->enum_type_count(); i++) { - GenerateEnum(options, printer, desc->enum_type(i)); - } - for (int i = 0; i < desc->nested_type_count(); i++) { - GenerateClass(options, printer, desc->nested_type(i)); - } } void Generator::GenerateClassConstructor(const GeneratorOptions& options, @@ -2143,8 +2167,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 +2253,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 +2407,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 +2760,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 +2820,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 +2922,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 +2976,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 +3144,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 +3182,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 +3236,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 +3249,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 +3280,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 +3337,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 +3354,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 +3364,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 +3373,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 +3405,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 +3434,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 +3505,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/arena_nc.cc b/src/google/protobuf/compiler/js/well_known_types_embed.h index f2f08427..174c665e 100644 --- a/src/google/protobuf/arena_nc.cc +++ b/src/google/protobuf/compiler/js/well_known_types_embed.h @@ -28,18 +28,16 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Negative compilation test for arena usage. +#ifndef GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__ +#define GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__ -#include <google/protobuf/arena.h> -#include <google/protobuf/unittest.pb.h> +#include <stddef.h> -#ifdef TEST_ARENA_PRIVATE_CONSTRUCTOR +struct FileToc { + const char* name; + const char* data; +}; -namespace google { -void ArenaPrivateConstructor() { - google::protobuf::Arena arena; - protobuf_unittest::TestAllTypes message(&arena); -} +extern struct FileToc well_known_types_js[]; -#endif -} // namespace google +#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..e82e6ae1 100644 --- a/src/google/protobuf/compiler/mock_code_generator.cc +++ b/src/google/protobuf/compiler/mock_code_generator.cc @@ -40,6 +40,7 @@ #endif #include <vector> +#include <google/protobuf/compiler/plugin.pb.h> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/testing/file.h> @@ -59,8 +60,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 +93,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 +103,7 @@ void MockCodeGenerator::ExpectGenerated( lines[i] += "\n"; } - vector<string> insertion_list; + std::vector<string> insertion_list; if (!insertions.empty()) { SplitStringUsing(insertions, ",", &insertion_list); } @@ -159,6 +161,15 @@ bool MockCodeGenerator::Generate( std::cerr << "Saw json_name: " << field_descriptor_proto.has_json_name() << std::endl; abort(); + } else if (command == "ShowVersionNumber") { + Version compiler_version; + context->GetCompilerVersion(&compiler_version); + std::cerr << "Saw compiler_version: " + << compiler_version.major() * 1000000 + + compiler_version.minor() * 1000 + + compiler_version.patch() + << " " << compiler_version.suffix() << std::endl; + abort(); } else { GOOGLE_LOG(FATAL) << "Unknown MockCodeGenerator command: " << command; } @@ -166,7 +177,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 +241,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/objectivec/objectivec_enum.cc b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc index 34e17823..02d60b3e 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc @@ -74,7 +74,7 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) { printer->Print("$comments$typedef$deprecated_attribute$ GPB_ENUM($name$) {\n", "comments", enum_comments, - "deprecated_attribute", GetOptionalDeprecatedAttribute(descriptor_), + "deprecated_attribute", GetOptionalDeprecatedAttribute(descriptor_, descriptor_->file()), "name", name_); printer->Indent(); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc index d0de1eca..7073173c 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc @@ -67,9 +67,12 @@ void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) { } else { vars["comments"] = ""; } + // Unlike normal message fields, check if the file for the extension was + // deprecated. + vars["deprecated_attribute"] = GetOptionalDeprecatedAttribute(descriptor_, descriptor_->file()); printer->Print(vars, "$comments$" - "+ (GPBExtensionDescriptor *)$method_name$;\n"); + "+ (GPBExtensionDescriptor *)$method_name$$deprecated_attribute$;\n"); } void ExtensionGenerator::GenerateStaticVariablesInitialization( diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h index 316069e1..c99262a1 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h @@ -53,66 +53,66 @@ struct Options { }; // Escape C++ trigraphs by escaping question marks to "\?". -string EscapeTrigraphs(const string& to_escape); +string LIBPROTOC_EXPORT EscapeTrigraphs(const string& to_escape); // Strips ".proto" or ".protodevel" from the end of a filename. -string StripProto(const string& filename); +string LIBPROTOC_EXPORT StripProto(const string& filename); // Remove white space from either end of a StringPiece. -void StringPieceTrimWhitespace(StringPiece* input); +void LIBPROTOC_EXPORT StringPieceTrimWhitespace(StringPiece* input); // Returns true if the name requires a ns_returns_not_retained attribute applied // to it. -bool IsRetainedName(const string& name); +bool LIBPROTOC_EXPORT IsRetainedName(const string& name); // Returns true if the name starts with "init" and will need to have special // handling under ARC. -bool IsInitName(const string& name); +bool LIBPROTOC_EXPORT IsInitName(const string& name); // Gets the objc_class_prefix. -string FileClassPrefix(const FileDescriptor* file); +string LIBPROTOC_EXPORT FileClassPrefix(const FileDescriptor* file); // Gets the path of the file we're going to generate (sans the .pb.h // extension). The path will be dependent on the objectivec package // declared in the proto package. -string FilePath(const FileDescriptor* file); +string LIBPROTOC_EXPORT FilePath(const FileDescriptor* file); // Just like FilePath(), but without the directory part. -string FilePathBasename(const FileDescriptor* file); +string LIBPROTOC_EXPORT FilePathBasename(const FileDescriptor* file); // Gets the name of the root class we'll generate in the file. This class // is not meant for external consumption, but instead contains helpers that // the rest of the classes need -string FileClassName(const FileDescriptor* file); +string LIBPROTOC_EXPORT FileClassName(const FileDescriptor* file); // These return the fully-qualified class name corresponding to the given // descriptor. -string ClassName(const Descriptor* descriptor); -string ClassName(const Descriptor* descriptor, string* out_suffix_added); -string EnumName(const EnumDescriptor* descriptor); +string LIBPROTOC_EXPORT ClassName(const Descriptor* descriptor); +string LIBPROTOC_EXPORT ClassName(const Descriptor* descriptor, string* out_suffix_added); +string LIBPROTOC_EXPORT EnumName(const EnumDescriptor* descriptor); // Returns the fully-qualified name of the enum value corresponding to the // the descriptor. -string EnumValueName(const EnumValueDescriptor* descriptor); +string LIBPROTOC_EXPORT EnumValueName(const EnumValueDescriptor* descriptor); // Returns the name of the enum value corresponding to the descriptor. -string EnumValueShortName(const EnumValueDescriptor* descriptor); +string LIBPROTOC_EXPORT EnumValueShortName(const EnumValueDescriptor* descriptor); // Reverse what an enum does. -string UnCamelCaseEnumShortName(const string& name); +string LIBPROTOC_EXPORT UnCamelCaseEnumShortName(const string& name); // Returns the name to use for the extension (used as the method off the file's // Root class). -string ExtensionMethodName(const FieldDescriptor* descriptor); +string LIBPROTOC_EXPORT ExtensionMethodName(const FieldDescriptor* descriptor); // Returns the transformed field name. -string FieldName(const FieldDescriptor* field); -string FieldNameCapitalized(const FieldDescriptor* field); +string LIBPROTOC_EXPORT FieldName(const FieldDescriptor* field); +string LIBPROTOC_EXPORT FieldNameCapitalized(const FieldDescriptor* field); // Returns the transformed oneof name. -string OneofEnumName(const OneofDescriptor* descriptor); -string OneofName(const OneofDescriptor* descriptor); -string OneofNameCapitalized(const OneofDescriptor* descriptor); +string LIBPROTOC_EXPORT OneofEnumName(const OneofDescriptor* descriptor); +string LIBPROTOC_EXPORT OneofName(const OneofDescriptor* descriptor); +string LIBPROTOC_EXPORT OneofNameCapitalized(const OneofDescriptor* descriptor); inline bool HasFieldPresence(const FileDescriptor* file) { return file->syntax() != FileDescriptor::SYNTAX_PROTO3; @@ -127,7 +127,7 @@ inline bool IsMapEntryMessage(const Descriptor* descriptor) { } // Reverse of the above. -string UnCamelCaseFieldName(const string& name, const FieldDescriptor* field); +string LIBPROTOC_EXPORT UnCamelCaseFieldName(const string& name, const FieldDescriptor* field); enum ObjectiveCType { OBJECTIVECTYPE_INT32, @@ -150,8 +150,18 @@ enum FlagType { }; template<class TDescriptor> -string GetOptionalDeprecatedAttribute(const TDescriptor* descriptor, bool preSpace = true, bool postNewline = false) { - if (descriptor->options().deprecated()) { +string GetOptionalDeprecatedAttribute( + const TDescriptor* descriptor, + const FileDescriptor* file = NULL, + bool preSpace = true, bool postNewline = false) { + bool isDeprecated = descriptor->options().deprecated(); + // The file is only passed when checking Messages & Enums, so those types + // get tagged. At the moment, it doesn't seem to make sense to tag every + // field or enum value with when the file is deprecated. + if (!isDeprecated && file) { + isDeprecated = file->options().deprecated(); + } + if (isDeprecated) { string result = "DEPRECATED_ATTRIBUTE"; if (preSpace) { result.insert(0, " "); @@ -165,42 +175,42 @@ string GetOptionalDeprecatedAttribute(const TDescriptor* descriptor, bool preSpa } } -string GetCapitalizedType(const FieldDescriptor* field); +string LIBPROTOC_EXPORT GetCapitalizedType(const FieldDescriptor* field); -ObjectiveCType GetObjectiveCType(FieldDescriptor::Type field_type); +ObjectiveCType LIBPROTOC_EXPORT GetObjectiveCType(FieldDescriptor::Type field_type); inline ObjectiveCType GetObjectiveCType(const FieldDescriptor* field) { return GetObjectiveCType(field->type()); } -bool IsPrimitiveType(const FieldDescriptor* field); -bool IsReferenceType(const FieldDescriptor* field); +bool LIBPROTOC_EXPORT IsPrimitiveType(const FieldDescriptor* field); +bool LIBPROTOC_EXPORT IsReferenceType(const FieldDescriptor* field); -string GPBGenericValueFieldName(const FieldDescriptor* field); -string DefaultValue(const FieldDescriptor* field); -bool HasNonZeroDefaultValue(const FieldDescriptor* field); +string LIBPROTOC_EXPORT GPBGenericValueFieldName(const FieldDescriptor* field); +string LIBPROTOC_EXPORT DefaultValue(const FieldDescriptor* field); +bool LIBPROTOC_EXPORT HasNonZeroDefaultValue(const FieldDescriptor* field); -string BuildFlagsString(const FlagType type, const vector<string>& strings); +string LIBPROTOC_EXPORT BuildFlagsString(const FlagType type, const vector<string>& strings); // Builds HeaderDoc/appledoc style comments out of the comments in the .proto // file. -string BuildCommentsString(const SourceLocation& location, +string LIBPROTOC_EXPORT BuildCommentsString(const SourceLocation& location, bool prefer_single_line); // The name the commonly used by the library when built as a framework. // This lines up to the name used in the CocoaPod. -extern const char* const ProtobufLibraryFrameworkName; +extern LIBPROTOC_EXPORT const char* const ProtobufLibraryFrameworkName; // Returns the CPP symbol name to use as the gate for framework style imports // for the given framework name to use. -string ProtobufFrameworkImportSymbol(const string& framework_name); +string LIBPROTOC_EXPORT ProtobufFrameworkImportSymbol(const string& framework_name); // Checks if the file is one of the proto's bundled with the library. -bool IsProtobufLibraryBundledProtoFile(const FileDescriptor* file); +bool LIBPROTOC_EXPORT IsProtobufLibraryBundledProtoFile(const FileDescriptor* file); // Checks the prefix for the given files and outputs any warnings as needed. If // there are flat out errors, then out_error is filled in with the first error // and the result is false. -bool ValidateObjCClassPrefixes(const vector<const FileDescriptor*>& files, +bool LIBPROTOC_EXPORT ValidateObjCClassPrefixes(const vector<const FileDescriptor*>& files, const Options& generation_options, string* out_error); @@ -234,7 +244,7 @@ class LIBPROTOC_EXPORT LineConsumer { virtual bool ConsumeLine(const StringPiece& line, string* out_error) = 0; }; -bool ParseSimpleFile( +bool LIBPROTOC_EXPORT ParseSimpleFile( const string& path, LineConsumer* line_consumer, string* out_error); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.cc b/src/google/protobuf/compiler/objectivec/objectivec_message.cc index 4c6e1b55..e0bd3dac 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.cc @@ -180,7 +180,10 @@ MessageGenerator::MessageGenerator(const string& root_classname, : root_classname_(root_classname), descriptor_(descriptor), field_generators_(descriptor, options), - class_name_(ClassName(descriptor_)) { + class_name_(ClassName(descriptor_)), + deprecated_attribute_( + GetOptionalDeprecatedAttribute(descriptor, descriptor->file(), false, true)) { + for (int i = 0; i < descriptor_->extension_count(); i++) { extension_generators_.push_back( new ExtensionGenerator(class_name_, descriptor_->extension(i))); @@ -339,7 +342,7 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { printer->Print( "$comments$$deprecated_attribute$@interface $classname$ : GPBMessage\n\n", "classname", class_name_, - "deprecated_attribute", GetOptionalDeprecatedAttribute(descriptor_, false, true), + "deprecated_attribute", deprecated_attribute_, "comments", message_comments); vector<char> seen_oneofs(descriptor_->oneof_decl_count(), 0); @@ -396,6 +399,14 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { "\n", "classname", class_name_); + if (!deprecated_attribute_.empty()) { + // No warnings when compiling the impl of this deprecated class. + printer->Print( + "#pragma clang diagnostic push\n" + "#pragma clang diagnostic ignored \"-Wdeprecated-implementations\"\n" + "\n"); + } + printer->Print("@implementation $classname$\n\n", "classname", class_name_); @@ -601,6 +612,12 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { "}\n\n" "@end\n\n"); + if (!deprecated_attribute_.empty()) { + printer->Print( + "#pragma clang diagnostic pop\n" + "\n"); + } + for (int i = 0; i < descriptor_->field_count(); i++) { field_generators_.get(descriptor_->field(i)) .GenerateCFunctionImplementations(printer); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.h b/src/google/protobuf/compiler/objectivec/objectivec_message.h index 910535ac..0fb78bc0 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.h @@ -85,6 +85,7 @@ class MessageGenerator { const Descriptor* descriptor_; FieldGeneratorMap field_generators_; const string class_name_; + const string deprecated_attribute_; vector<ExtensionGenerator*> extension_generators_; vector<EnumGenerator*> enum_generators_; vector<MessageGenerator*> nested_message_generators_; diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc index 09c7a2b6..7a03d42b 100644 --- a/src/google/protobuf/compiler/parser.cc +++ b/src/google/protobuf/compiler/parser.cc @@ -249,11 +249,11 @@ bool Parser::ConsumeNumber(double* output, const char* error) { input_->Next(); return true; } else if (LookingAt("inf")) { - *output = numeric_limits<double>::infinity(); + *output = std::numeric_limits<double>::infinity(); input_->Next(); return true; } else if (LookingAt("nan")) { - *output = numeric_limits<double>::quiet_NaN(); + *output = std::numeric_limits<double>::quiet_NaN(); input_->Next(); return true; } else { @@ -282,7 +282,7 @@ bool Parser::TryConsumeEndOfDeclaration( const char* text, const LocationRecorder* location) { if (LookingAt(text)) { string leading, trailing; - vector<string> detached; + std::vector<string> detached; input_->NextWithComments(&trailing, &detached, &leading); // Save the leading comments for next time, and recall the leading comments @@ -404,7 +404,7 @@ void Parser::LocationRecorder::RecordLegacyLocation(const Message* descriptor, void Parser::LocationRecorder::AttachComments( string* leading, string* trailing, - vector<string>* detached_comments) const { + std::vector<string>* detached_comments) const { GOOGLE_CHECK(!location_->has_leading_comments()); GOOGLE_CHECK(!location_->has_trailing_comments()); @@ -487,7 +487,7 @@ bool Parser::ValidateEnum(const EnumDescriptorProto* proto) { return false; } - set<int> used_values; + std::set<int> used_values; bool has_duplicates = false; for (int i = 0; i < proto->value_size(); ++i) { const EnumValueDescriptorProto enum_value = proto->value(i); @@ -2089,7 +2089,7 @@ bool SourceLocationTable::Find( const Message* descriptor, DescriptorPool::ErrorCollector::ErrorLocation location, int* line, int* column) const { - const pair<int, int>* result = + const std::pair<int, int>* result = FindOrNull(location_map_, std::make_pair(descriptor, location)); if (result == NULL) { *line = -1; 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/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 75ddb405..ec9a2365 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -43,6 +43,11 @@ using google::protobuf::internal::scoped_ptr; const std::string kDescriptorFile = "google/protobuf/descriptor.proto"; +const std::string kEmptyFile = "google/protobuf/empty.proto"; +const std::string kEmptyMetadataFile = "GPBMetadata/Google/Protobuf/GPBEmpty.php"; +const std::string kDescriptorMetadataFile = + "GPBMetadata/Google/Protobuf/Internal/Descriptor.php"; +const std::string kDescriptorDirName = "Google/Protobuf/Internal"; const std::string kDescriptorPackageName = "Google\\Protobuf\\Internal"; namespace google { @@ -52,38 +57,57 @@ namespace php { // Forward decls. std::string PhpName(const std::string& full_name, bool is_descriptor); -std::string DefaultForField(google::protobuf::FieldDescriptor* field); +std::string DefaultForField(FieldDescriptor* field); std::string IntToString(int32 value); -std::string GeneratedFileName(const std::string& proto_file, - bool is_descriptor); -std::string LabelForField(google::protobuf::FieldDescriptor* field); -std::string TypeName(google::protobuf::FieldDescriptor* field); +std::string FilenameToClassname(const string& filename); +std::string GeneratedMetadataFileName(const std::string& proto_file, + bool is_descriptor); +std::string LabelForField(FieldDescriptor* field); +std::string TypeName(FieldDescriptor* field); std::string UnderscoresToCamelCase(const string& name, bool cap_first_letter); std::string EscapeDollor(const string& to_escape); std::string BinaryToHex(const string& binary); -void GenerateMessage(const string& name_prefix, - const google::protobuf::Descriptor* message, - bool is_descriptor, - google::protobuf::io::Printer* printer); -void GenerateEnum(const google::protobuf::EnumDescriptor* en, - google::protobuf::io::Printer* printer); -void Indent(google::protobuf::io::Printer* printer); -void Outdent(google::protobuf::io::Printer* printer); - -std::string MessageName(const google::protobuf::Descriptor* message, - bool is_descriptor) { +void Indent(io::Printer* printer); +void Outdent(io::Printer* printer); +void GenerateMessageDocComment(io::Printer* printer, const Descriptor* message); +void GenerateFieldDocComment(io::Printer* printer, + const FieldDescriptor* field); +void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_); +void GenerateEnumValueDocComment(io::Printer* printer, + const EnumValueDescriptor* value); + +std::string RenameEmpty(const std::string& name) { + if (name == "Empty") { + return "GPBEmpty"; + } else { + return name; + } +} + +std::string MessagePrefix(const Descriptor* message) { + // Empty cannot be php class name. + if (message->name() == "Empty" && + message->file()->package() == "google.protobuf") { + return "GPB"; + } else { + return ""; + } +} + +std::string MessageName(const Descriptor* message, bool is_descriptor) { string message_name = message->name(); - const google::protobuf::Descriptor* descriptor = message->containing_type(); + const Descriptor* descriptor = message->containing_type(); while (descriptor != NULL) { message_name = descriptor->name() + '_' + message_name; descriptor = descriptor->containing_type(); } + message_name = MessagePrefix(message) + message_name; + return PhpName(message->file()->package(), is_descriptor) + '\\' + message_name; } -std::string MessageFullName(const google::protobuf::Descriptor* message, - bool is_descriptor) { +std::string MessageFullName(const Descriptor* message, bool is_descriptor) { if (is_descriptor) { return StringReplace(message->full_name(), "google.protobuf", @@ -93,8 +117,7 @@ std::string MessageFullName(const google::protobuf::Descriptor* message, } } -std::string EnumFullName(const google::protobuf::EnumDescriptor* envm, - bool is_descriptor) { +std::string EnumFullName(const EnumDescriptor* envm, bool is_descriptor) { if (is_descriptor) { return StringReplace(envm->full_name(), "google.protobuf", @@ -104,9 +127,9 @@ std::string EnumFullName(const google::protobuf::EnumDescriptor* envm, } } -std::string EnumClassName(const google::protobuf::EnumDescriptor* envm) { +std::string EnumClassName(const EnumDescriptor* envm) { string enum_class_name = envm->name(); - const google::protobuf::Descriptor* descriptor = envm->containing_type(); + const Descriptor* descriptor = envm->containing_type(); while (descriptor != NULL) { enum_class_name = descriptor->name() + '_' + enum_class_name; descriptor = descriptor->containing_type(); @@ -114,8 +137,7 @@ std::string EnumClassName(const google::protobuf::EnumDescriptor* envm) { return enum_class_name; } -std::string EnumName(const google::protobuf::EnumDescriptor* envm, - bool is_descriptor) { +std::string EnumName(const EnumDescriptor* envm, bool is_descriptor) { string enum_name = EnumClassName(envm); return PhpName(envm->file()->package(), is_descriptor) + '\\' + enum_name; } @@ -142,7 +164,7 @@ std::string PhpName(const std::string& full_name, bool is_descriptor) { return result; } -std::string DefaultForField(const google::protobuf::FieldDescriptor* field) { +std::string DefaultForField(const FieldDescriptor* field) { switch (field->type()) { case FieldDescriptor::TYPE_INT32: case FieldDescriptor::TYPE_INT64: @@ -166,14 +188,63 @@ std::string DefaultForField(const google::protobuf::FieldDescriptor* field) { } } -std::string GeneratedFileName(const std::string& proto_file, - bool is_descriptor) { +std::string GeneratedMetadataFileName(const std::string& proto_file, + bool is_descriptor) { + int start_index = 0; + int first_index = proto_file.find_first_of("/", start_index); + std::string result = "GPBMetadata/"; + + if (proto_file == kEmptyFile) { + return kEmptyMetadataFile; + } if (is_descriptor) { - return "descriptor_internal.pb.php"; + return kDescriptorMetadataFile; + } + + // Append directory name. + std::string file_no_suffix; + int lastindex = proto_file.find_last_of("."); + if (proto_file == kEmptyFile) { + return kEmptyMetadataFile; } else { - int lastindex = proto_file.find_last_of("."); - return proto_file.substr(0, lastindex) + ".pb.php"; + file_no_suffix = proto_file.substr(0, lastindex); + } + + while (first_index != string::npos) { + result += UnderscoresToCamelCase( + file_no_suffix.substr(start_index, first_index - start_index), true); + result += "/"; + start_index = first_index + 1; + first_index = file_no_suffix.find_first_of("/", start_index); + } + + // Append file name. + result += RenameEmpty(UnderscoresToCamelCase( + file_no_suffix.substr(start_index, first_index - start_index), true)); + + return result += ".php"; +} + +std::string GeneratedMessageFileName(const Descriptor* message, + bool is_descriptor) { + std::string result = MessageName(message, is_descriptor); + for (int i = 0; i < result.size(); i++) { + if (result[i] == '\\') { + result[i] = '/'; + } } + return result + ".php"; +} + +std::string GeneratedEnumFileName(const EnumDescriptor* en, + bool is_descriptor) { + std::string result = EnumName(en, is_descriptor); + for (int i = 0; i < result.size(); i++) { + if (result[i] == '\\') { + result[i] = '/'; + } + } + return result + ".php"; } std::string IntToString(int32 value) { @@ -182,7 +253,7 @@ std::string IntToString(int32 value) { return os.str(); } -std::string LabelForField(const google::protobuf::FieldDescriptor* field) { +std::string LabelForField(const FieldDescriptor* field) { switch (field->label()) { case FieldDescriptor::LABEL_OPTIONAL: return "optional"; case FieldDescriptor::LABEL_REQUIRED: return "required"; @@ -191,7 +262,7 @@ std::string LabelForField(const google::protobuf::FieldDescriptor* field) { } } -std::string TypeName(const google::protobuf::FieldDescriptor* field) { +std::string TypeName(const FieldDescriptor* field) { switch (field->type()) { case FieldDescriptor::TYPE_INT32: return "int32"; case FieldDescriptor::TYPE_INT64: return "int64"; @@ -216,7 +287,7 @@ std::string TypeName(const google::protobuf::FieldDescriptor* field) { } std::string EnumOrMessageSuffix( - const google::protobuf::FieldDescriptor* field, bool is_descriptor) { + const FieldDescriptor* field, bool is_descriptor) { if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { return ", '" + MessageFullName(field->message_type(), is_descriptor) + "'"; } @@ -287,74 +358,77 @@ std::string BinaryToHex(const string& src) { return dest; } -void Indent(google::protobuf::io::Printer* printer) { +void Indent(io::Printer* printer) { printer->Indent(); printer->Indent(); } -void Outdent(google::protobuf::io::Printer* printer) { +void Outdent(io::Printer* printer) { printer->Outdent(); printer->Outdent(); } -void GenerateField(const google::protobuf::FieldDescriptor* field, - google::protobuf::io::Printer* printer, bool is_descriptor) { +void GenerateField(const FieldDescriptor* field, io::Printer* printer, + bool is_descriptor) { if (field->is_repeated()) { + GenerateFieldDocComment(printer, field); printer->Print( - "private $@name@;\n", + "private $^name^;\n", "name", field->name()); } else if (field->containing_oneof()) { // Oneof fields are handled by GenerateOneofField. return; } else { + GenerateFieldDocComment(printer, field); printer->Print( - "private $@name@ = @default@;\n", + "private $^name^ = ^default^;\n", "name", field->name(), "default", DefaultForField(field)); } if (is_descriptor) { printer->Print( - "private $has_@name@ = false;\n", + "private $has_^name^ = false;\n", "name", field->name()); } } -void GenerateOneofField(const google::protobuf::OneofDescriptor* oneof, - google::protobuf::io::Printer* printer) { +void GenerateOneofField(const OneofDescriptor* oneof, io::Printer* printer) { // Oneof property needs to be protected in order to be accessed by parent // class in implementation. printer->Print( - "protected $@name@;\n", + "protected $^name^;\n", "name", oneof->name()); } -void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field, - bool is_descriptor, - google::protobuf::io::Printer* printer) { +void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, + io::Printer* printer) { const OneofDescriptor* oneof = field->containing_oneof(); // Generate getter. if (oneof != NULL) { + GenerateFieldDocComment(printer, field); printer->Print( - "public function get@camel_name@()\n" + "public function get^camel_name^()\n" "{\n" - " return $this->readOneof(@number@);\n" + " return $this->readOneof(^number^);\n" "}\n\n", "camel_name", UnderscoresToCamelCase(field->name(), true), "number", IntToString(field->number())); } else { + GenerateFieldDocComment(printer, field); printer->Print( - "public function get@camel_name@()\n" + "public function get^camel_name^()\n" "{\n" - " return $this->@name@;\n" + " return $this->^name^;\n" "}\n\n", "camel_name", UnderscoresToCamelCase(field->name(), true), "name", field->name()); } // Generate setter. + GenerateFieldDocComment(printer, field); printer->Print( - "public function set@camel_name@(@var@)\n" + "public function set^camel_name^(^var^)\n" "{\n", "camel_name", UnderscoresToCamelCase(field->name(), true), "var", (field->is_repeated() || @@ -367,16 +441,17 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field, if (field->is_map()) { } else if (field->is_repeated()) { printer->Print( - "GPBUtil::checkRepeatedField($var, GPBType::@type@", + "GPBUtil::checkRepeatedField($var, " + "\\Google\\Protobuf\\Internal\\GPBType::^type^", "type", ToUpper(field->type_name())); if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { printer->Print( - ", \\@class_name@);\n", + ", \\^class_name^);\n", "class_name", MessageName(field->message_type(), is_descriptor) + "::class"); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { printer->Print( - ", @class_name@);\n", + ", ^class_name^);\n", "class_name", EnumName(field->enum_type(), is_descriptor) + "::class"); } else { @@ -384,37 +459,37 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field, } } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { printer->Print( - "GPBUtil::checkMessage($var, \\@class_name@::class);\n", + "GPBUtil::checkMessage($var, \\^class_name^::class);\n", "class_name", MessageName(field->message_type(), is_descriptor)); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { printer->Print( - "GPBUtil::checkEnum($var, \\@class_name@::class);\n", + "GPBUtil::checkEnum($var, \\^class_name^::class);\n", "class_name", EnumName(field->enum_type(), is_descriptor)); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { printer->Print( - "GPBUtil::checkString($var, @utf8@);\n", + "GPBUtil::checkString($var, ^utf8^);\n", "utf8", field->type() == FieldDescriptor::TYPE_STRING ? "True": "False"); } else { printer->Print( - "GPBUtil::check@type@($var);\n", + "GPBUtil::check^type^($var);\n", "type", UnderscoresToCamelCase(field->cpp_type_name(), true)); } if (oneof != NULL) { printer->Print( - "$this->writeOneof(@number@, $var);\n", + "$this->writeOneof(^number^, $var);\n", "number", IntToString(field->number())); } else { printer->Print( - "$this->@name@ = $var;\n", + "$this->^name^ = $var;\n", "name", field->name()); } // Set has bit for proto2 only. if (is_descriptor) { printer->Print( - "$this->has_@field_name@ = true;\n", + "$this->has_^field_name^ = true;\n", "field_name", field->name()); } @@ -426,125 +501,27 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field, // Generate has method for proto2 only. if (is_descriptor) { printer->Print( - "public function has@camel_name@()\n" + "public function has^camel_name^()\n" "{\n" - " return $this->has_@field_name@;\n" + " return $this->has_^field_name^;\n" "}\n\n", "camel_name", UnderscoresToCamelCase(field->name(), true), "field_name", field->name()); } } -void GenerateRepeatedFieldDecode( - const google::protobuf::FieldDescriptor* field, - google::protobuf::io::Printer* printer) { - printer->Print( - "if ($input->read@cap_wire_type@($var)) return False;\n" - "$this->get@cap_field_name@() []= $var;\n", - "cap_field_name", UnderscoresToCamelCase(field->name(), true), - "cap_wire_type", UnderscoresToCamelCase(field->type_name(), true)); -} - -void GeneratePrimitiveFieldDecode( - const google::protobuf::FieldDescriptor* field, - google::protobuf::io::Printer* printer) { - printer->Print( - "if ($input->read@cap_wire_type@($var)) return False;\n" - "$this->set@cap_field_name@($var);\n", - "cap_field_name", UnderscoresToCamelCase(field->name(), true), - "cap_wire_type", UnderscoresToCamelCase(field->type_name(), true)); -} - -void GenerateFieldDecode(const google::protobuf::FieldDescriptor* field, - google::protobuf::io::Printer* printer) { - printer->Print( - "case @number@:\n", - "number", IntToString(field->number())); - Indent(printer); - - if (field->is_repeated()) { - GenerateRepeatedFieldDecode(field, printer); - } else { - GeneratePrimitiveFieldDecode(field, printer); - } - - printer->Print( - "break;\n"); - Outdent(printer); -} - -void GenerateMessage(const string& name_prefix, - const google::protobuf::Descriptor* message, - bool is_descriptor, - google::protobuf::io::Printer* printer) { - // Don't generate MapEntry messages -- we use the PHP extension's native - // support for map fields instead. - if (message->options().map_entry()) { - return; - } - - string message_name = name_prefix.empty()? - message->name() : name_prefix + "_" + message->name(); - +void GenerateEnumToPool(const EnumDescriptor* en, io::Printer* printer) { printer->Print( - "class @name@ extends \\Google\\Protobuf\\Internal\\Message\n" - "{\n", - "name", message_name); - Indent(printer); - - // Field and oneof definitions. - for (int i = 0; i < message->field_count(); i++) { - const FieldDescriptor* field = message->field(i); - GenerateField(field, printer, is_descriptor); - } - for (int i = 0; i < message->oneof_decl_count(); i++) { - const OneofDescriptor* oneof = message->oneof_decl(i); - GenerateOneofField(oneof, printer); - } - printer->Print("\n"); - - // Field and oneof accessors. - for (int i = 0; i < message->field_count(); i++) { - const FieldDescriptor* field = message->field(i); - GenerateFieldAccessor(field, is_descriptor, printer); - } - for (int i = 0; i < message->oneof_decl_count(); i++) { - const google::protobuf::OneofDescriptor* oneof = message->oneof_decl(i); - printer->Print( - "public function get@camel_name@()\n" - "{\n" - " return $this->@name@;\n" - "}\n\n", - "camel_name", UnderscoresToCamelCase(oneof->name(), true), "name", - oneof->name()); - } - - Outdent(printer); - printer->Print("}\n\n"); - - // Nested messages and enums. - for (int i = 0; i < message->nested_type_count(); i++) { - GenerateMessage(message_name, message->nested_type(i), is_descriptor, - printer); - } - for (int i = 0; i < message->enum_type_count(); i++) { - GenerateEnum(message->enum_type(i), printer); - } -} - -void GenerateEnumToPool(const google::protobuf::EnumDescriptor* en, - bool is_descriptor, - google::protobuf::io::Printer* printer) { - printer->Print( - "$pool->addEnum('@name@', @class_name@::class)\n", - "name", EnumFullName(en, is_descriptor), + "$pool->addEnum('^name^', " + "\\Google\\Protobuf\\Internal\\^class_name^::class)\n", + "name", EnumFullName(en, true), "class_name", en->name()); Indent(printer); for (int i = 0; i < en->value_count(); i++) { const EnumValueDescriptor* value = en->value(i); printer->Print( - "->value(\"@name@\", @number@)\n", + "->value(\"^name^\", ^number^)\n", "name", value->name(), "number", IntToString(value->number())); } @@ -552,10 +529,8 @@ void GenerateEnumToPool(const google::protobuf::EnumDescriptor* en, Outdent(printer); } -void GenerateMessageToPool(const string& name_prefix, - const google::protobuf::Descriptor* message, - bool is_descriptor, - google::protobuf::io::Printer* printer) { +void GenerateMessageToPool(const string& name_prefix, const Descriptor* message, + io::Printer* printer) { // Don't generate MapEntry messages -- we use the PHP extension's native // support for map fields instead. if (message->options().map_entry()) { @@ -565,8 +540,9 @@ void GenerateMessageToPool(const string& name_prefix, message->name() : name_prefix + "_" + message->name(); printer->Print( - "$pool->addMessage('@message@', @class_name@::class)\n", - "message", MessageFullName(message, is_descriptor), + "$pool->addMessage('^message^', " + "\\Google\\Protobuf\\Internal\\^class_name^::class)\n", + "message", MessageFullName(message, true), "class_name", class_name); Indent(printer); @@ -579,38 +555,40 @@ void GenerateMessageToPool(const string& name_prefix, const FieldDescriptor* val = field->message_type()->FindFieldByName("value"); printer->Print( - "->map('@field@', GPBType::@key@, " - "GPBType::@value@, @number@@other@)\n", + "->map('^field^', \\Google\\Protobuf\\Internal\\GPBType::^key^, " + "\\Google\\Protobuf\\Internal\\GPBType::^value^, ^number^^other^)\n", "field", field->name(), "key", ToUpper(key->type_name()), "value", ToUpper(val->type_name()), "number", SimpleItoa(field->number()), - "other", EnumOrMessageSuffix(val, is_descriptor)); + "other", EnumOrMessageSuffix(val, true)); } else if (!field->containing_oneof()) { printer->Print( - "->@label@('@field@', GPBType::@type@, @number@@other@)\n", + "->^label^('^field^', " + "\\Google\\Protobuf\\Internal\\GPBType::^type^, ^number^^other^)\n", "field", field->name(), "label", LabelForField(field), "type", ToUpper(field->type_name()), "number", SimpleItoa(field->number()), - "other", EnumOrMessageSuffix(field, is_descriptor)); + "other", EnumOrMessageSuffix(field, true)); } } // oneofs. for (int i = 0; i < message->oneof_decl_count(); i++) { const OneofDescriptor* oneof = message->oneof_decl(i); - printer->Print("->oneof(@name@)\n", + printer->Print("->oneof(^name^)\n", "name", oneof->name()); Indent(printer); for (int index = 0; index < oneof->field_count(); index++) { const FieldDescriptor* field = oneof->field(index); printer->Print( - "->value('@field@', GPBType::@type@, @number@@other@)\n", + "->value('^field^', " + "\\Google\\Protobuf\\Internal\\GPBType::^type^, ^number^^other^)\n", "field", field->name(), "type", ToUpper(field->type_name()), "number", SimpleItoa(field->number()), - "other", EnumOrMessageSuffix(field, is_descriptor)); + "other", EnumOrMessageSuffix(field, true)); } printer->Print("->finish()\n"); Outdent(printer); @@ -625,33 +603,48 @@ void GenerateMessageToPool(const string& name_prefix, "\n"); for (int i = 0; i < message->nested_type_count(); i++) { - GenerateMessageToPool(class_name, message->nested_type(i), is_descriptor, - printer); + GenerateMessageToPool(class_name, message->nested_type(i), printer); } for (int i = 0; i < message->enum_type_count(); i++) { - GenerateEnumToPool(message->enum_type(i), is_descriptor, printer); + GenerateEnumToPool(message->enum_type(i), printer); } } -void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file, - bool is_descriptor, - google::protobuf::io::Printer* printer) { - if (is_descriptor) { - printer->Print("$pool = DescriptorPool::getGeneratedPool();\n\n"); +void GenerateAddFileToPool(const FileDescriptor* file, bool is_descriptor, + io::Printer* printer) { + printer->Print( + "public static $is_initialized = false;\n\n" + "public static function initOnce() {\n"); + Indent(printer); + + printer->Print( + "$pool = \\Google\\Protobuf\\Internal\\" + "DescriptorPool::getGeneratedPool();\n\n" + "if (static::$is_initialized == true) {\n" + " return;\n" + "}\n"); + if (is_descriptor) { for (int i = 0; i < file->message_type_count(); i++) { - GenerateMessageToPool("", file->message_type(i), is_descriptor, printer); + GenerateMessageToPool("", file->message_type(i), printer); } for (int i = 0; i < file->enum_type_count(); i++) { - GenerateEnumToPool(file->enum_type(i), is_descriptor, printer); + GenerateEnumToPool(file->enum_type(i), printer); } printer->Print( "$pool->finish();\n"); } else { - // Add messages and enums to descriptor pool. - printer->Print("$pool = DescriptorPool::getGeneratedPool();\n\n"); + for (int i = 0; i < file->dependency_count(); i++) { + const std::string& name = file->dependency(i)->name(); + std::string dependency_filename = + GeneratedMetadataFileName(name, is_descriptor); + printer->Print( + "\\^name^::initOnce();\n", + "name", FilenameToClassname(dependency_filename)); + } + // Add messages and enums to descriptor pool. FileDescriptorSet files; FileDescriptorProto* file_proto = files.add_file(); file->CopyTo(file_proto); @@ -665,7 +658,7 @@ void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file, static const int kBytesPerLine = 30; for (int i = 0; i < files_data.size(); i += kBytesPerLine) { printer->Print( - "\"@data@\"@dot@\n", + "\"^data^\"^dot^\n", "data", BinaryToHex(files_data.substr(i, kBytesPerLine)), "dot", i + kBytesPerLine < files_data.size() ? " ." : ""); } @@ -674,38 +667,20 @@ void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file, printer->Print( "));\n\n"); } - -} - -void GenerateEnum(const google::protobuf::EnumDescriptor* en, - google::protobuf::io::Printer* printer) { printer->Print( - "class @name@\n" - "{\n", - "name", EnumClassName(en)); - Indent(printer); - - for (int i = 0; i < en->value_count(); i++) { - const EnumValueDescriptor* value = en->value(i); - printer->Print("const @name@ = @number@;\n", - "name", value->name(), - "number", IntToString(value->number())); - } + "static::$is_initialized = true;\n"); Outdent(printer); - printer->Print("}\n\n"); + printer->Print("}\n"); } -void GenerateUseDeclaration(bool is_descriptor, - google::protobuf::io::Printer* printer) { +void GenerateUseDeclaration(bool is_descriptor, io::Printer* printer) { if (!is_descriptor) { printer->Print( - "use Google\\Protobuf\\Internal\\DescriptorPool;\n" "use Google\\Protobuf\\Internal\\GPBType;\n" "use Google\\Protobuf\\Internal\\RepeatedField;\n" "use Google\\Protobuf\\Internal\\GPBUtil;\n\n"); } else { printer->Print( - "use Google\\Protobuf\\Internal\\DescriptorPool;\n" "use Google\\Protobuf\\Internal\\GPBType;\n" "use Google\\Protobuf\\Internal\\GPBWire;\n" "use Google\\Protobuf\\Internal\\RepeatedField;\n" @@ -714,42 +689,380 @@ void GenerateUseDeclaration(bool is_descriptor, } } -void GenerateFile(const google::protobuf::FileDescriptor* file, - bool is_descriptor, google::protobuf::io::Printer* printer) { +void GenerateHead(const FileDescriptor* file, io::Printer* printer) { printer->Print( "<?php\n" "# Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "# source: @filename@\n" + "# source: ^filename^\n" "\n", "filename", file->name()); +} + +std::string FilenameToClassname(const string& filename) { + int lastindex = filename.find_last_of("."); + std::string result = filename.substr(0, lastindex); + for (int i = 0; i < result.size(); i++) { + if (result[i] == '/') { + result[i] = '\\'; + } + } + return result; +} + +void GenerateMetadataFile(const FileDescriptor* file, + bool is_descriptor, + GeneratorContext* generator_context) { + std::string filename = GeneratedMetadataFileName(file->name(), is_descriptor); + scoped_ptr<io::ZeroCopyOutputStream> output( + generator_context->Open(filename)); + io::Printer printer(output.get(), '^'); + + GenerateHead(file, &printer); + + std::string fullname = FilenameToClassname(filename); + int lastindex = fullname.find_last_of("\\"); + + printer.Print( + "namespace ^name^;\n\n", + "name", fullname.substr(0, lastindex)); + + if (lastindex != string::npos) { + printer.Print( + "class ^name^\n" + "{\n", + "name", fullname.substr(lastindex + 1)); + } else { + printer.Print( + "class ^name^\n" + "{\n", + "name", fullname); + } + Indent(&printer); + + GenerateAddFileToPool(file, is_descriptor, &printer); + + Outdent(&printer); + printer.Print("}\n\n"); +} + +void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, + bool is_descriptor, GeneratorContext* generator_context) { + std::string filename = GeneratedEnumFileName(en, is_descriptor); + scoped_ptr<io::ZeroCopyOutputStream> output( + generator_context->Open(filename)); + io::Printer printer(output.get(), '^'); + + GenerateHead(file, &printer); + + std::string fullname = FilenameToClassname(filename); + int lastindex = fullname.find_last_of("\\"); + if (!file->package().empty()) { - printer->Print("namespace @name@;\n\n", - "name", PhpName(file->package(), is_descriptor)); + printer.Print( + "namespace ^name^;\n\n", + "name", fullname.substr(0, lastindex)); + } + + GenerateEnumDocComment(&printer, en); + + if (lastindex != string::npos) { + printer.Print( + "class ^name^\n" + "{\n", + "name", fullname.substr(lastindex + 1)); + } else { + printer.Print( + "class ^name^\n" + "{\n", + "name", fullname); + } + Indent(&printer); + + for (int i = 0; i < en->value_count(); i++) { + const EnumValueDescriptor* value = en->value(i); + GenerateEnumValueDocComment(&printer, value); + printer.Print("const ^name^ = ^number^;\n", + "name", value->name(), + "number", IntToString(value->number())); } - for (int i = 0; i < file->dependency_count(); i++) { - const std::string& name = file->dependency(i)->name(); - printer->Print("require_once('@name@');\n", "name", - GeneratedFileName(name, is_descriptor)); + Outdent(&printer); + printer.Print("}\n\n"); +} + +void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, + bool is_descriptor, + GeneratorContext* generator_context) { + // Don't generate MapEntry messages -- we use the PHP extension's native + // support for map fields instead. + if (message->options().map_entry()) { + return; + } + + std::string filename = GeneratedMessageFileName(message, is_descriptor); + scoped_ptr<io::ZeroCopyOutputStream> output( + generator_context->Open(filename)); + io::Printer printer(output.get(), '^'); + + GenerateHead(file, &printer); + + std::string fullname = FilenameToClassname(filename); + int lastindex = fullname.find_last_of("\\"); + + if (!file->package().empty()) { + printer.Print( + "namespace ^name^;\n\n", + "name", fullname.substr(0, lastindex)); + } + + GenerateUseDeclaration(is_descriptor, &printer); + + GenerateMessageDocComment(&printer, message); + if (lastindex != string::npos) { + printer.Print( + "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n" + "{\n", + "name", fullname.substr(lastindex + 1)); + } else { + printer.Print( + "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n" + "{\n", + "name", fullname); + } + Indent(&printer); + + // Field and oneof definitions. + for (int i = 0; i < message->field_count(); i++) { + const FieldDescriptor* field = message->field(i); + GenerateField(field, &printer, is_descriptor); + } + for (int i = 0; i < message->oneof_decl_count(); i++) { + const OneofDescriptor* oneof = message->oneof_decl(i); + GenerateOneofField(oneof, &printer); + } + printer.Print("\n"); + + printer.Print( + "public function __construct() {\n"); + Indent(&printer); + + std::string metadata_filename = + GeneratedMetadataFileName(file->name(), is_descriptor); + std::string metadata_fullname = FilenameToClassname(metadata_filename); + printer.Print( + "\\^fullname^::initOnce();\n" + "parent::__construct();\n", + "fullname", metadata_fullname); + + Outdent(&printer); + printer.Print("}\n\n"); + + // Field and oneof accessors. + for (int i = 0; i < message->field_count(); i++) { + const FieldDescriptor* field = message->field(i); + GenerateFieldAccessor(field, is_descriptor, &printer); + } + for (int i = 0; i < message->oneof_decl_count(); i++) { + const OneofDescriptor* oneof = message->oneof_decl(i); + printer.Print( + "public function get^camel_name^()\n" + "{\n" + " return $this->whichOneof(\"^name^\");\n" + "}\n\n", + "camel_name", UnderscoresToCamelCase(oneof->name(), true), "name", + oneof->name()); } - GenerateUseDeclaration(is_descriptor, printer); + Outdent(&printer); + printer.Print("}\n\n"); + + // Nested messages and enums. + for (int i = 0; i < message->nested_type_count(); i++) { + GenerateMessageFile(file, message->nested_type(i), is_descriptor, + generator_context); + } + for (int i = 0; i < message->enum_type_count(); i++) { + GenerateEnumFile(file, message->enum_type(i), is_descriptor, + generator_context); + } +} +void GenerateFile(const FileDescriptor* file, bool is_descriptor, + GeneratorContext* generator_context) { + GenerateMetadataFile(file, is_descriptor, generator_context); for (int i = 0; i < file->message_type_count(); i++) { - GenerateMessage("", file->message_type(i), is_descriptor, printer); + GenerateMessageFile(file, file->message_type(i), is_descriptor, + generator_context); } for (int i = 0; i < file->enum_type_count(); i++) { - GenerateEnum(file->enum_type(i), printer); + GenerateEnumFile(file, file->enum_type(i), is_descriptor, + generator_context); + } +} + +static string EscapePhpdoc(const string& input) { + string result; + result.reserve(input.size() * 2); + + char prev = '*'; + + for (string::size_type i = 0; i < input.size(); i++) { + char c = input[i]; + switch (c) { + case '*': + // Avoid "/*". + if (prev == '/') { + result.append("*"); + } else { + result.push_back(c); + } + break; + case '/': + // Avoid "*/". + if (prev == '*') { + result.append("/"); + } else { + result.push_back(c); + } + break; + case '@': + // '@' starts phpdoc tags including the @deprecated tag, which will + // cause a compile-time error if inserted before a declaration that + // does not have a corresponding @Deprecated annotation. + result.append("@"); + break; + case '<': + // Avoid interpretation as HTML. + result.append("<"); + break; + case '>': + // Avoid interpretation as HTML. + result.append(">"); + break; + case '&': + // Avoid interpretation as HTML. + result.append("&"); + break; + case '\\': + // Java interprets Unicode escape sequences anywhere! + result.append("\"); + break; + default: + result.push_back(c); + break; + } + + prev = c; } - GenerateAddFileToPool(file, is_descriptor, printer); + return result; } -bool Generator::Generate( - const FileDescriptor* file, - const string& parameter, - GeneratorContext* generator_context, - string* error) const { +static void GenerateDocCommentBodyForLocation( + io::Printer* printer, const SourceLocation& location) { + string comments = location.leading_comments.empty() ? + location.trailing_comments : location.leading_comments; + if (!comments.empty()) { + // TODO(teboring): Ideally we should parse the comment text as Markdown and + // write it back as HTML, but this requires a Markdown parser. For now + // we just use <pre> to get fixed-width text formatting. + + // If the comment itself contains block comment start or end markers, + // HTML-escape them so that they don't accidentally close the doc comment. + comments = EscapePhpdoc(comments); + + vector<string> lines = Split(comments, "\n"); + while (!lines.empty() && lines.back().empty()) { + lines.pop_back(); + } + + printer->Print(" * <pre>\n"); + for (int i = 0; i < lines.size(); i++) { + // Most lines should start with a space. Watch out for lines that start + // with a /, since putting that right after the leading asterisk will + // close the comment. + if (!lines[i].empty() && lines[i][0] == '/') { + printer->Print(" * ^line^\n", "line", lines[i]); + } else { + printer->Print(" *^line^\n", "line", lines[i]); + } + } + printer->Print( + " * </pre>\n" + " *\n"); + } +} + +template <typename DescriptorType> +static void GenerateDocCommentBody( + io::Printer* printer, const DescriptorType* descriptor) { + SourceLocation location; + if (descriptor->GetSourceLocation(&location)) { + GenerateDocCommentBodyForLocation(printer, location); + } +} + +static string FirstLineOf(const string& value) { + string result = value; + + string::size_type pos = result.find_first_of('\n'); + if (pos != string::npos) { + result.erase(pos); + } + + return result; +} + +void GenerateMessageDocComment(io::Printer* printer, + const Descriptor* message) { + printer->Print("/**\n"); + GenerateDocCommentBody(printer, message); + printer->Print( + " * Protobuf type <code>^fullname^</code>\n" + " */\n", + "fullname", EscapePhpdoc(message->full_name())); +} + +void GenerateFieldDocComment(io::Printer* printer, + const FieldDescriptor* field) { + // In theory we should have slightly different comments for setters, getters, + // etc., but in practice everyone already knows the difference between these + // so it's redundant information. + + // We start the comment with the main body based on the comments from the + // .proto file (if present). We then end with the field declaration, e.g.: + // optional string foo = 5; + // If the field is a group, the debug string might end with {. + printer->Print("/**\n"); + GenerateDocCommentBody(printer, field); + printer->Print( + " * <code>^def^</code>\n", + "def", EscapePhpdoc(FirstLineOf(field->DebugString()))); + printer->Print(" */\n"); +} + +void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_) { + printer->Print("/**\n"); + GenerateDocCommentBody(printer, enum_); + printer->Print( + " * Protobuf enum <code>^fullname^</code>\n" + " */\n", + "fullname", EscapePhpdoc(enum_->full_name())); +} + +void GenerateEnumValueDocComment(io::Printer* printer, + const EnumValueDescriptor* value) { + printer->Print("/**\n"); + GenerateDocCommentBody(printer, value); + printer->Print( + " * <code>^def^</code>\n" + " */\n", + "def", EscapePhpdoc(FirstLineOf(value->DebugString()))); +} + +bool Generator::Generate(const FileDescriptor* file, const string& parameter, + GeneratorContext* generator_context, + string* error) const { bool is_descriptor = parameter == "internal"; if (is_descriptor && file->name() != kDescriptorFile) { @@ -765,12 +1078,7 @@ bool Generator::Generate( return false; } - std::string filename = GeneratedFileName(file->name(), is_descriptor); - scoped_ptr<io::ZeroCopyOutputStream> output( - generator_context->Open(filename)); - io::Printer printer(output.get(), '@'); - - GenerateFile(file, is_descriptor, &printer); + GenerateFile(file, is_descriptor, generator_context); return true; } diff --git a/src/google/protobuf/compiler/plugin.cc b/src/google/protobuf/compiler/plugin.cc index e1087601..3848101d 100644 --- a/src/google/protobuf/compiler/plugin.cc +++ b/src/google/protobuf/compiler/plugin.cc @@ -62,9 +62,12 @@ namespace compiler { class GeneratorResponseContext : public GeneratorContext { public: - GeneratorResponseContext(CodeGeneratorResponse* response, - const vector<const FileDescriptor*>& parsed_files) - : response_(response), + GeneratorResponseContext( + const Version& compiler_version, + CodeGeneratorResponse* response, + const std::vector<const FileDescriptor*>& parsed_files) + : compiler_version_(compiler_version), + response_(response), parsed_files_(parsed_files) {} virtual ~GeneratorResponseContext() {} @@ -84,13 +87,18 @@ 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_; } + void GetCompilerVersion(Version* version) const { + *version = compiler_version_; + } + private: + Version compiler_version_; CodeGeneratorResponse* response_; - const vector<const FileDescriptor*>& parsed_files_; + const std::vector<const FileDescriptor*>& parsed_files_; }; bool GenerateCode(const CodeGeneratorRequest& request, @@ -105,7 +113,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) { @@ -116,7 +124,8 @@ bool GenerateCode(const CodeGeneratorRequest& request, } } - GeneratorResponseContext context(response, parsed_files); + GeneratorResponseContext context( + request.compiler_version(), response, parsed_files); string error; bool succeeded = generator.GenerateAll( diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index a4d4a530..686ee477 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -20,172 +20,681 @@ namespace google { namespace protobuf { namespace compiler { +class VersionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Version> { +} _Version_default_instance_; +class CodeGeneratorRequestDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> { +} _CodeGeneratorRequest_default_instance_; +class CodeGeneratorResponse_FileDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> { +} _CodeGeneratorResponse_File_default_instance_; +class CodeGeneratorResponseDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> { +} _CodeGeneratorResponse_default_instance_; + +namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto { + 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[4]; } // 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] = { - 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] = { - 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_), - }; - 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_)); -} +const ::google::protobuf::uint32 TableStruct::offsets[] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, major_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, minor_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, patch_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, suffix_), + 1, + 2, + 3, + 0, + 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_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, compiler_version_), + ~0u, + 0, + ~0u, + 1, + 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, + ~0u, +}; + +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, 8, sizeof(Version)}, + { 12, 20, sizeof(CodeGeneratorRequest)}, + { 24, 31, sizeof(CodeGeneratorResponse_File)}, + { 34, 40, sizeof(CodeGeneratorResponse)}, +}; + +static ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_Version_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorRequest_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_File_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_default_instance_), +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/compiler/plugin.proto", schemas, file_default_instances, TableStruct::offsets, 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, 4); } } // 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_; -} - -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(); +void TableStruct::Shutdown() { + _Version_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; + _CodeGeneratorRequest_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; + _CodeGeneratorResponse_File_default_instance_.Shutdown(); + delete file_level_metadata[2].reflection; + _CodeGeneratorResponse_default_instance_.Shutdown(); + delete file_level_metadata[3].reflection; } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_); -void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl); -} -void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() { +void TableStruct::InitDefaultsImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + ::google::protobuf::internal::InitProtobufDefaults(); + ::google::protobuf::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + _Version_default_instance_.DefaultConstruct(); + _CodeGeneratorRequest_default_instance_.DefaultConstruct(); + _CodeGeneratorResponse_File_default_instance_.DefaultConstruct(); + _CodeGeneratorResponse_default_instance_.DefaultConstruct(); + _CodeGeneratorRequest_default_instance_.get_mutable()->compiler_version_ = const_cast< ::google::protobuf::compiler::Version*>( + ::google::protobuf::compiler::Version::internal_default_instance()); +} + +void InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); +} +void AddDescriptorsImpl() { + InitDefaults(); + static const char descriptor[] = { + "\n%google/protobuf/compiler/plugin.proto\022" + "\030google.protobuf.compiler\032 google/protob" + "uf/descriptor.proto\"F\n\007Version\022\r\n\005major\030" + "\001 \001(\005\022\r\n\005minor\030\002 \001(\005\022\r\n\005patch\030\003 \001(\005\022\016\n\006s" + "uffix\030\004 \001(\t\"\272\001\n\024CodeGeneratorRequest\022\030\n\020" + "file_to_generate\030\001 \003(\t\022\021\n\tparameter\030\002 \001(" + "\t\0228\n\nproto_file\030\017 \003(\0132$.google.protobuf." + "FileDescriptorProto\022;\n\020compiler_version\030" + "\003 \001(\0132!.google.protobuf.compiler.Version" + "\"\252\001\n\025CodeGeneratorResponse\022\r\n\005error\030\001 \001(" + "\t\022B\n\004file\030\017 \003(\01324.google.protobuf.compil" + "er.CodeGeneratorResponse.File\032>\n\004File\022\014\n" + "\004name\030\001 \001(\t\022\027\n\017insertion_point\030\002 \001(\t\022\017\n\007" + "content\030\017 \001(\tB7\n\034com.google.protobuf.com" + "pilerB\014PluginProtosZ\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, 590); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/compiler/plugin.proto", &protobuf_RegisterTypes); - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto); + ::google::protobuf::protobuf_google_2fprotobuf_2fdescriptor_2eproto::AddDescriptors(); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_); -void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_, - &protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl); +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); } -} static_descriptor_initializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto_; +} static_descriptor_initializer; -namespace { +} // namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto + + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int Version::kMajorFieldNumber; +const int Version::kMinorFieldNumber; +const int Version::kPatchFieldNumber; +const int Version::kSuffixFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +Version::Version() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); + } + SharedCtor(); + // @@protoc_insertion_point(constructor:google.protobuf.compiler.Version) +} +Version::Version(const Version& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + suffix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_suffix()) { + suffix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.suffix_); + } + ::memcpy(&major_, &from.major_, + reinterpret_cast<char*>(&patch_) - + reinterpret_cast<char*>(&major_) + sizeof(patch_)); + // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.Version) +} -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); +void Version::SharedCtor() { + _cached_size_ = 0; + suffix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::memset(&major_, 0, reinterpret_cast<char*>(&patch_) - + reinterpret_cast<char*>(&major_) + sizeof(patch_)); } -} // namespace +Version::~Version() { + // @@protoc_insertion_point(destructor:google.protobuf.compiler.Version) + SharedDtor(); +} + +void Version::SharedDtor() { + suffix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + +void Version::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* Version::descriptor() { + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[0].descriptor; +} + +const Version& Version::default_instance() { + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); + return *internal_default_instance(); +} + +Version* Version::New(::google::protobuf::Arena* arena) const { + Version* n = new Version; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void Version::Clear() { +// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.Version) + if (has_suffix()) { + GOOGLE_DCHECK(!suffix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*suffix_.UnsafeRawStringPointer())->clear(); + } + if (_has_bits_[0 / 32] & 14u) { + ::memset(&major_, 0, reinterpret_cast<char*>(&patch_) - + reinterpret_cast<char*>(&major_) + sizeof(patch_)); + } + _has_bits_.Clear(); + _internal_metadata_.Clear(); +} + +bool Version::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.compiler.Version) + 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)) { + // optional int32 major = 1; + case 1: { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { + set_has_major(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &major_))); + } else { + goto handle_unusual; + } + break; + } + + // optional int32 minor = 2; + case 2: { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(16u)) { + set_has_minor(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &minor_))); + } else { + goto handle_unusual; + } + break; + } + + // optional int32 patch = 3; + case 3: { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(24u)) { + set_has_patch(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &patch_))); + } else { + goto handle_unusual; + } + break; + } + + // optional string suffix = 4; + case 4: { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(34u)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_suffix())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->suffix().data(), this->suffix().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "google.protobuf.compiler.Version.suffix"); + } else { + goto handle_unusual; + } + 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.compiler.Version) + return true; +failure: + // @@protoc_insertion_point(parse_failure:google.protobuf.compiler.Version) + return false; +#undef DO_ +} + +void Version::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.Version) + // optional int32 major = 1; + if (has_major()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->major(), output); + } + + // optional int32 minor = 2; + if (has_minor()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->minor(), output); + } + + // optional int32 patch = 3; + if (has_patch()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->patch(), output); + } + + // optional string suffix = 4; + if (has_suffix()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->suffix().data(), this->suffix().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.compiler.Version.suffix"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 4, this->suffix(), output); + } + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.Version) +} + +::google::protobuf::uint8* Version::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.Version) + // optional int32 major = 1; + if (has_major()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->major(), target); + } + + // optional int32 minor = 2; + if (has_minor()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->minor(), target); + } + + // optional int32 patch = 3; + if (has_patch()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->patch(), target); + } + + // optional string suffix = 4; + if (has_suffix()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->suffix().data(), this->suffix().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.compiler.Version.suffix"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 4, this->suffix(), 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.compiler.Version) + return target; +} + +size_t Version::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.Version) + 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] & 15u) { + // optional string suffix = 4; + if (has_suffix()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->suffix()); + } + + // optional int32 major = 1; + if (has_major()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->major()); + } + + // optional int32 minor = 2; + if (has_minor()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->minor()); + } + + // optional int32 patch = 3; + if (has_patch()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->patch()); + } + + } + 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 Version::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.Version) + GOOGLE_DCHECK_NE(&from, this); + const Version* source = + ::google::protobuf::internal::DynamicCastToGenerated<const Version>( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.compiler.Version) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.Version) + MergeFrom(*source); + } +} + +void Version::MergeFrom(const Version& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 15u) { + if (from.has_suffix()) { + set_has_suffix(); + suffix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.suffix_); + } + if (from.has_major()) { + set_major(from.major()); + } + if (from.has_minor()) { + set_minor(from.minor()); + } + if (from.has_patch()) { + set_patch(from.patch()); + } + } +} + +void Version::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.compiler.Version) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Version::CopyFrom(const Version& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.Version) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Version::IsInitialized() const { + return true; +} + +void Version::Swap(Version* other) { + if (other == this) return; + InternalSwap(other); +} +void Version::InternalSwap(Version* other) { + suffix_.Swap(&other->suffix_); + std::swap(major_, other->major_); + std::swap(minor_, other->minor_); + std::swap(patch_, other->patch_); + 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 Version::GetMetadata() const { + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[0]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// Version + +// optional int32 major = 1; +bool Version::has_major() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void Version::set_has_major() { + _has_bits_[0] |= 0x00000002u; +} +void Version::clear_has_major() { + _has_bits_[0] &= ~0x00000002u; +} +void Version::clear_major() { + major_ = 0; + clear_has_major(); +} +::google::protobuf::int32 Version::major() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.major) + return major_; +} +void Version::set_major(::google::protobuf::int32 value) { + set_has_major(); + major_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.major) +} + +// optional int32 minor = 2; +bool Version::has_minor() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void Version::set_has_minor() { + _has_bits_[0] |= 0x00000004u; +} +void Version::clear_has_minor() { + _has_bits_[0] &= ~0x00000004u; +} +void Version::clear_minor() { + minor_ = 0; + clear_has_minor(); +} +::google::protobuf::int32 Version::minor() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.minor) + return minor_; +} +void Version::set_minor(::google::protobuf::int32 value) { + set_has_minor(); + minor_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.minor) +} + +// optional int32 patch = 3; +bool Version::has_patch() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void Version::set_has_patch() { + _has_bits_[0] |= 0x00000008u; +} +void Version::clear_has_patch() { + _has_bits_[0] &= ~0x00000008u; +} +void Version::clear_patch() { + patch_ = 0; + clear_has_patch(); +} +::google::protobuf::int32 Version::patch() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.patch) + return patch_; +} +void Version::set_patch(::google::protobuf::int32 value) { + set_has_patch(); + patch_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.patch) +} + +// optional string suffix = 4; +bool Version::has_suffix() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void Version::set_has_suffix() { + _has_bits_[0] |= 0x00000001u; +} +void Version::clear_has_suffix() { + _has_bits_[0] &= ~0x00000001u; +} +void Version::clear_suffix() { + suffix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_suffix(); +} +const ::std::string& Version::suffix() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix) + return suffix_.GetNoArena(); +} +void Version::set_suffix(const ::std::string& value) { + set_has_suffix(); + suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) +} +#if LANG_CXX11 +void Version::set_suffix(::std::string&& value) { + set_has_suffix(); + suffix_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.Version.suffix) +} +#endif +void Version::set_suffix(const char* value) { + set_has_suffix(); + suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.Version.suffix) +} +void Version::set_suffix(const char* value, size_t size) { + set_has_suffix(); + suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.Version.suffix) +} +::std::string* Version::mutable_suffix() { + set_has_suffix(); + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.Version.suffix) + return suffix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* Version::release_suffix() { + // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix) + clear_has_suffix(); + return suffix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void Version::set_allocated_suffix(::std::string* suffix) { + if (suffix != NULL) { + set_has_suffix(); + } else { + clear_has_suffix(); + } + suffix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), suffix); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -193,29 +702,41 @@ static void MergeFromFail(int line) { const int CodeGeneratorRequest::kFileToGenerateFieldNumber; const int CodeGeneratorRequest::kParameterFieldNumber; const int CodeGeneratorRequest::kProtoFileFieldNumber; +const int CodeGeneratorRequest::kCompilerVersionFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 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_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); + } 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_); + } + if (from.has_compiler_version()) { + compiler_version_ = new ::google::protobuf::compiler::Version(*from.compiler_version_); + } else { + compiler_version_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorRequest) } void CodeGeneratorRequest::SharedCtor() { _cached_size_ = 0; parameter_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + compiler_version_ = NULL; } CodeGeneratorRequest::~CodeGeneratorRequest() { @@ -225,6 +746,9 @@ CodeGeneratorRequest::~CodeGeneratorRequest() { void CodeGeneratorRequest::SharedDtor() { parameter_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != internal_default_instance()) { + delete compiler_version_; + } } void CodeGeneratorRequest::SetCachedSize(int size) const { @@ -233,17 +757,15 @@ void CodeGeneratorRequest::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* CodeGeneratorRequest::descriptor() { - protobuf_AssignDescriptorsOnce(); - return CodeGeneratorRequest_descriptor_; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[1].descriptor; } const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); 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 +776,20 @@ 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_bits_[0 / 32] & 3u) { + if (has_parameter()) { + GOOGLE_DCHECK(!parameter_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*parameter_.UnsafeRawStringPointer())->clear(); + } + if (has_compiler_version()) { + GOOGLE_DCHECK(compiler_version_ != NULL); + compiler_version_->::google::protobuf::compiler::Version::Clear(); + } } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool CodeGeneratorRequest::MergePartialFromCodedStream( @@ -271,14 +798,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_file_to_generate())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -289,15 +816,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_parameter())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -307,24 +832,32 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(122)) goto parse_proto_file; + break; + } + + // optional .google.protobuf.compiler.Version compiler_version = 3; + case 3: { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(26u)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_compiler_version())); + } else { + goto handle_unusual; + } break; } // repeated .google.protobuf.FileDescriptorProto proto_file = 15; case 15: { - if (tag == 122) { - parse_proto_file: + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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; } @@ -354,7 +887,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.CodeGeneratorRequest) // repeated string file_to_generate = 1; - for (int i = 0; i < this->file_to_generate_size(); i++) { + for (int i = 0, n = this->file_to_generate_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->file_to_generate(i).data(), this->file_to_generate(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -373,6 +906,12 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( 2, this->parameter(), output); } + // optional .google.protobuf.compiler.Version compiler_version = 3; + if (has_compiler_version()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 3, *this->compiler_version_, output); + } + // repeated .google.protobuf.FileDescriptorProto proto_file = 15; for (unsigned int i = 0, n = this->proto_file_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( @@ -388,10 +927,10 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( ::google::protobuf::uint8* CodeGeneratorRequest::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest) // repeated string file_to_generate = 1; - for (int i = 0; i < this->file_to_generate_size(); i++) { + for (int i = 0, n = this->file_to_generate_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->file_to_generate(i).data(), this->file_to_generate(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -411,6 +950,13 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( 2, this->parameter(), target); } + // optional .google.protobuf.compiler.Version compiler_version = 3; + if (has_compiler_version()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 3, *this->compiler_version_, false, target); + } + // repeated .google.protobuf.FileDescriptorProto proto_file = 15; for (unsigned int i = 0, n = this->proto_file_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: @@ -430,17 +976,15 @@ 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()); - for (int i = 0; i < this->file_to_generate_size(); i++) { + for (int i = 0, n = this->file_to_generate_size(); i < n; i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->file_to_generate(i)); } @@ -456,10 +1000,21 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + if (_has_bits_[0 / 32] & 3u) { + // optional string parameter = 2; + if (has_parameter()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->parameter()); + } + + // optional .google.protobuf.compiler.Version compiler_version = 3; + if (has_compiler_version()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->compiler_version_); + } + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -470,7 +1025,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 +1034,24 @@ 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_bits_[0 / 32] & 3u) { 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_compiler_version()) { + mutable_compiler_version()->::google::protobuf::compiler::Version::MergeFrom(from.compiler_version()); + } } } @@ -519,11 +1066,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,19 +1080,17 @@ 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(compiler_version_, other->compiler_version_); 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 CodeGeneratorRequest::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = CodeGeneratorRequest_descriptor_; - metadata.reflection = CodeGeneratorRequest_reflection_; - return metadata; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -571,6 +1115,12 @@ void CodeGeneratorRequest::set_file_to_generate(int index, const ::std::string& // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) file_to_generate_.Mutable(index)->assign(value); } +#if LANG_CXX11 +void CodeGeneratorRequest::set_file_to_generate(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) + file_to_generate_.Mutable(index)->assign(std::move(value)); +} +#endif void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { file_to_generate_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) @@ -588,6 +1138,12 @@ void CodeGeneratorRequest::add_file_to_generate(const ::std::string& value) { file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } +#if LANG_CXX11 +void CodeGeneratorRequest::add_file_to_generate(::std::string&& value) { + file_to_generate_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) +} +#endif void CodeGeneratorRequest::add_file_to_generate(const char* value) { file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) @@ -609,13 +1165,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,13 +1179,21 @@ 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(); parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter) } +#if LANG_CXX11 +void CodeGeneratorRequest::set_parameter(::std::string&& value) { + set_has_parameter(); + parameter_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorRequest.parameter) +} +#endif void CodeGeneratorRequest::set_parameter(const char* value) { set_has_parameter(); parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -691,9 +1255,51 @@ CodeGeneratorRequest::proto_file() const { return proto_file_; } -inline const CodeGeneratorRequest* CodeGeneratorRequest::internal_default_instance() { - return &CodeGeneratorRequest_default_instance_.get(); +// optional .google.protobuf.compiler.Version compiler_version = 3; +bool CodeGeneratorRequest::has_compiler_version() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void CodeGeneratorRequest::set_has_compiler_version() { + _has_bits_[0] |= 0x00000002u; +} +void CodeGeneratorRequest::clear_has_compiler_version() { + _has_bits_[0] &= ~0x00000002u; +} +void CodeGeneratorRequest::clear_compiler_version() { + if (compiler_version_ != NULL) compiler_version_->::google::protobuf::compiler::Version::Clear(); + clear_has_compiler_version(); +} +const ::google::protobuf::compiler::Version& CodeGeneratorRequest::compiler_version() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + return compiler_version_ != NULL ? *compiler_version_ + : *::google::protobuf::compiler::Version::internal_default_instance(); +} +::google::protobuf::compiler::Version* CodeGeneratorRequest::mutable_compiler_version() { + set_has_compiler_version(); + if (compiler_version_ == NULL) { + compiler_version_ = new ::google::protobuf::compiler::Version; + } + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + return compiler_version_; +} +::google::protobuf::compiler::Version* CodeGeneratorRequest::release_compiler_version() { + // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + clear_has_compiler_version(); + ::google::protobuf::compiler::Version* temp = compiler_version_; + compiler_version_ = NULL; + return temp; +} +void CodeGeneratorRequest::set_allocated_compiler_version(::google::protobuf::compiler::Version* compiler_version) { + delete compiler_version_; + compiler_version_ = compiler_version; + if (compiler_version) { + set_has_compiler_version(); + } else { + clear_has_compiler_version(); + } + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) } + #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -706,19 +1312,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_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); + } 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) } @@ -746,17 +1363,15 @@ void CodeGeneratorResponse_File::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* CodeGeneratorResponse_File::descriptor() { - protobuf_AssignDescriptorsOnce(); - return CodeGeneratorResponse_File_descriptor_; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[2].descriptor; } const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); 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 +1384,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 +1406,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -806,14 +1423,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_insertion_point())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -823,14 +1439,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(122u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_content())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -840,7 +1455,6 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -908,7 +1522,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes( ::google::protobuf::uint8* CodeGeneratorResponse_File::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse.File) // optional string name = 1; if (has_name()) { @@ -955,6 +1569,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 +1597,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 +1606,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 +1615,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 +1637,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 +1650,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; } @@ -1069,15 +1671,202 @@ 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; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::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(); +} +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) +} +#if LANG_CXX11 +void CodeGeneratorResponse_File::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.name) +} +#endif +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) +} +#if LANG_CXX11 +void CodeGeneratorResponse_File::set_insertion_point(::std::string&& value) { + set_has_insertion_point(); + insertion_point_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) +} +#endif +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) +} +#if LANG_CXX11 +void CodeGeneratorResponse_File::set_content(::std::string&& value) { + set_has_content(); + content_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.content) +} +#endif +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 +1875,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_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); + } 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) } @@ -1122,17 +1915,15 @@ void CodeGeneratorResponse::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* CodeGeneratorResponse::descriptor() { - protobuf_AssignDescriptorsOnce(); - return CodeGeneratorResponse_descriptor_; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[3].descriptor; } const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); 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 +1934,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 +1949,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_error())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1175,24 +1966,20 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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; } @@ -1246,7 +2033,7 @@ void CodeGeneratorResponse::SerializeWithCachedSizes( ::google::protobuf::uint8* CodeGeneratorResponse::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse) // optional string error = 1; if (has_error()) { @@ -1278,13 +2065,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 +2081,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 +2097,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 +2106,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 +2132,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,191 +2144,19 @@ 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_); } ::google::protobuf::Metadata CodeGeneratorResponse::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = CodeGeneratorResponse_descriptor_; - metadata.reflection = CodeGeneratorResponse_reflection_; - return metadata; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[3]; } #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,13 +2175,21 @@ 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(); error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error) } +#if LANG_CXX11 +void CodeGeneratorResponse::set_error(::std::string&& value) { + set_has_error(); + error_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.error) +} +#endif void CodeGeneratorResponse::set_error(const char* value) { set_has_error(); error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -1642,9 +2251,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..1b91daca 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -8,44 +8,272 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3001000 +#if GOOGLE_PROTOBUF_VERSION < 3002000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #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; +LIBPROTOC_EXPORT extern DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; +class DescriptorProto_ExtensionRange; +class DescriptorProto_ExtensionRangeDefaultTypeInternal; +LIBPROTOC_EXPORT extern DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; +class DescriptorProto_ReservedRange; +class DescriptorProto_ReservedRangeDefaultTypeInternal; +LIBPROTOC_EXPORT extern DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; +class EnumDescriptorProto; +class EnumDescriptorProtoDefaultTypeInternal; +LIBPROTOC_EXPORT extern EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; +class EnumOptions; +class EnumOptionsDefaultTypeInternal; +LIBPROTOC_EXPORT extern EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; +class EnumValueDescriptorProto; +class EnumValueDescriptorProtoDefaultTypeInternal; +LIBPROTOC_EXPORT extern EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; +class EnumValueOptions; +class EnumValueOptionsDefaultTypeInternal; +LIBPROTOC_EXPORT extern EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; +class FieldDescriptorProto; +class FieldDescriptorProtoDefaultTypeInternal; +LIBPROTOC_EXPORT extern FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; +class FieldOptions; +class FieldOptionsDefaultTypeInternal; +LIBPROTOC_EXPORT extern FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; +class FileDescriptorProto; +class FileDescriptorProtoDefaultTypeInternal; +LIBPROTOC_EXPORT extern FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; +class FileDescriptorSet; +class FileDescriptorSetDefaultTypeInternal; +LIBPROTOC_EXPORT extern FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; +class FileOptions; +class FileOptionsDefaultTypeInternal; +LIBPROTOC_EXPORT extern FileOptionsDefaultTypeInternal _FileOptions_default_instance_; +class GeneratedCodeInfo; +class GeneratedCodeInfoDefaultTypeInternal; +LIBPROTOC_EXPORT extern GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; +class GeneratedCodeInfo_Annotation; +class GeneratedCodeInfo_AnnotationDefaultTypeInternal; +LIBPROTOC_EXPORT extern GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; +class MessageOptions; +class MessageOptionsDefaultTypeInternal; +LIBPROTOC_EXPORT extern MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; +class MethodDescriptorProto; +class MethodDescriptorProtoDefaultTypeInternal; +LIBPROTOC_EXPORT extern MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; +class MethodOptions; +class MethodOptionsDefaultTypeInternal; +LIBPROTOC_EXPORT extern MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; +class OneofDescriptorProto; +class OneofDescriptorProtoDefaultTypeInternal; +LIBPROTOC_EXPORT extern OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; +class OneofOptions; +class OneofOptionsDefaultTypeInternal; +LIBPROTOC_EXPORT extern OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; +class ServiceDescriptorProto; +class ServiceDescriptorProtoDefaultTypeInternal; +LIBPROTOC_EXPORT extern ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; +class ServiceOptions; +class ServiceOptionsDefaultTypeInternal; +LIBPROTOC_EXPORT extern ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; +class SourceCodeInfo; +class SourceCodeInfoDefaultTypeInternal; +LIBPROTOC_EXPORT extern SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; +class SourceCodeInfo_Location; +class SourceCodeInfo_LocationDefaultTypeInternal; +LIBPROTOC_EXPORT extern SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; +class UninterpretedOption; +class UninterpretedOptionDefaultTypeInternal; +LIBPROTOC_EXPORT extern UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; +class UninterpretedOption_NamePart; +class UninterpretedOption_NamePartDefaultTypeInternal; +LIBPROTOC_EXPORT extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; 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 CodeGeneratorRequestDefaultTypeInternal; +LIBPROTOC_EXPORT extern CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; class CodeGeneratorResponse; +class CodeGeneratorResponseDefaultTypeInternal; +LIBPROTOC_EXPORT extern CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; class CodeGeneratorResponse_File; +class CodeGeneratorResponse_FileDefaultTypeInternal; +LIBPROTOC_EXPORT extern CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; +class Version; +class VersionDefaultTypeInternal; +LIBPROTOC_EXPORT extern VersionDefaultTypeInternal _Version_default_instance_; +} // namespace compiler +} // namespace protobuf +} // namespace google + +namespace google { +namespace protobuf { +namespace compiler { + +namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto { +// Internal implementation detail -- do not call these. +struct LIBPROTOC_EXPORT TableStruct { + static const ::google::protobuf::uint32 offsets[]; + static void InitDefaultsImpl(); + static void Shutdown(); +}; +void LIBPROTOC_EXPORT AddDescriptors(); +void LIBPROTOC_EXPORT InitDefaults(); +} // namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto // =================================================================== +class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ { + public: + Version(); + virtual ~Version(); + + Version(const Version& from); + + inline Version& operator=(const Version& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields(); + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const Version& default_instance(); + + static inline const Version* internal_default_instance() { + return reinterpret_cast<const Version*>( + &_Version_default_instance_); + } + + void Swap(Version* other); + + // implements Message ---------------------------------------------- + + inline Version* New() const PROTOBUF_FINAL { return New(NULL); } + + Version* 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 Version& from); + void MergeFrom(const Version& from); + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; + + size_t ByteSizeLong() const PROTOBUF_FINAL; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output); + } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const PROTOBUF_FINAL; + void InternalSwap(Version* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return NULL; + } + inline void* MaybeArenaPtr() const { + return NULL; + } + public: + + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional string suffix = 4; + bool has_suffix() const; + void clear_suffix(); + static const int kSuffixFieldNumber = 4; + const ::std::string& suffix() const; + void set_suffix(const ::std::string& value); + #if LANG_CXX11 + void set_suffix(::std::string&& value); + #endif + void set_suffix(const char* value); + void set_suffix(const char* value, size_t size); + ::std::string* mutable_suffix(); + ::std::string* release_suffix(); + void set_allocated_suffix(::std::string* suffix); + + // optional int32 major = 1; + bool has_major() const; + void clear_major(); + static const int kMajorFieldNumber = 1; + ::google::protobuf::int32 major() const; + void set_major(::google::protobuf::int32 value); + + // optional int32 minor = 2; + bool has_minor() const; + void clear_minor(); + static const int kMinorFieldNumber = 2; + ::google::protobuf::int32 minor() const; + void set_minor(::google::protobuf::int32 value); + + // optional int32 patch = 3; + bool has_patch() const; + void clear_patch(); + static const int kPatchFieldNumber = 3; + ::google::protobuf::int32 patch() const; + void set_patch(::google::protobuf::int32 value); + + // @@protoc_insertion_point(class_scope:google.protobuf.compiler.Version) + private: + void set_has_major(); + void clear_has_major(); + void set_has_minor(); + void clear_has_minor(); + void set_has_patch(); + void clear_has_patch(); + void set_has_suffix(); + void clear_has_suffix(); + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::internal::ArenaStringPtr suffix_; + ::google::protobuf::int32 major_; + ::google::protobuf::int32 minor_; + ::google::protobuf::int32 patch_; + friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; +}; +// ------------------------------------------------------------------- + class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ { public: CodeGeneratorRequest(); @@ -69,49 +297,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -124,43 +356,63 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message const ::std::string& file_to_generate(int index) const; ::std::string* mutable_file_to_generate(int index); void set_file_to_generate(int index, const ::std::string& value); + #if LANG_CXX11 + void set_file_to_generate(int index, ::std::string&& value); + #endif void set_file_to_generate(int index, const char* value); void set_file_to_generate(int index, const char* value, size_t size); ::std::string* add_file_to_generate(); void add_file_to_generate(const ::std::string& value); + #if LANG_CXX11 + void add_file_to_generate(::std::string&& value); + #endif void add_file_to_generate(const char* value); void add_file_to_generate(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& file_to_generate() const; ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_file_to_generate(); + // repeated .google.protobuf.FileDescriptorProto proto_file = 15; + int proto_file_size() const; + void clear_proto_file(); + static const int kProtoFileFieldNumber = 15; + const ::google::protobuf::FileDescriptorProto& proto_file(int index) const; + ::google::protobuf::FileDescriptorProto* mutable_proto_file(int index); + ::google::protobuf::FileDescriptorProto* add_proto_file(); + ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* + mutable_proto_file(); + const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& + proto_file() const; + // optional string parameter = 2; bool has_parameter() const; void clear_parameter(); static const int kParameterFieldNumber = 2; const ::std::string& parameter() const; void set_parameter(const ::std::string& value); + #if LANG_CXX11 + void set_parameter(::std::string&& value); + #endif void set_parameter(const char* value); void set_parameter(const char* value, size_t size); ::std::string* mutable_parameter(); ::std::string* release_parameter(); void set_allocated_parameter(::std::string* parameter); - // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - int proto_file_size() const; - void clear_proto_file(); - static const int kProtoFileFieldNumber = 15; - const ::google::protobuf::FileDescriptorProto& proto_file(int index) const; - ::google::protobuf::FileDescriptorProto* mutable_proto_file(int index); - ::google::protobuf::FileDescriptorProto* add_proto_file(); - ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* - mutable_proto_file(); - const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& - proto_file() const; + // optional .google.protobuf.compiler.Version compiler_version = 3; + bool has_compiler_version() const; + void clear_compiler_version(); + static const int kCompilerVersionFieldNumber = 3; + const ::google::protobuf::compiler::Version& compiler_version() const; + ::google::protobuf::compiler::Version* mutable_compiler_version(); + ::google::protobuf::compiler::Version* release_compiler_version(); + void set_allocated_compiler_version(::google::protobuf::compiler::Version* compiler_version); // @@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(); + void set_has_compiler_version(); + void clear_has_compiler_version(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -168,15 +420,9 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message ::google::protobuf::RepeatedPtrField< ::std::string> file_to_generate_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > proto_file_; ::google::protobuf::internal::ArenaStringPtr parameter_; - friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - - void InitAsDefaultInstance(); + ::google::protobuf::compiler::Version* compiler_version_; + friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; }; -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 +448,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -256,6 +506,9 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M static const int kNameFieldNumber = 1; const ::std::string& name() const; void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); @@ -268,6 +521,9 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M static const int kInsertionPointFieldNumber = 2; const ::std::string& insertion_point() const; void set_insertion_point(const ::std::string& value); + #if LANG_CXX11 + void set_insertion_point(::std::string&& value); + #endif void set_insertion_point(const char* value); void set_insertion_point(const char* value, size_t size); ::std::string* mutable_insertion_point(); @@ -280,6 +536,9 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M static const int kContentFieldNumber = 15; const ::std::string& content() const; void set_content(const ::std::string& value); + #if LANG_CXX11 + void set_content(::std::string&& value); + #endif void set_content(const char* value); void set_content(const char* value, size_t size); ::std::string* mutable_content(); @@ -288,12 +547,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_; @@ -301,15 +560,8 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr insertion_point_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; }; -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 +587,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -385,18 +641,6 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag // accessors ------------------------------------------------------- - // optional string error = 1; - bool has_error() const; - void clear_error(); - static const int kErrorFieldNumber = 1; - const ::std::string& error() const; - void set_error(const ::std::string& value); - void set_error(const char* value); - void set_error(const char* value, size_t size); - ::std::string* mutable_error(); - ::std::string* release_error(); - void set_allocated_error(::std::string* error); - // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; int file_size() const; void clear_file(); @@ -409,31 +653,177 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >& file() const; + // optional string error = 1; + bool has_error() const; + void clear_error(); + static const int kErrorFieldNumber = 1; + const ::std::string& error() const; + void set_error(const ::std::string& value); + #if LANG_CXX11 + void set_error(::std::string&& value); + #endif + void set_error(const char* value); + void set_error(const char* value, size_t size); + ::std::string* mutable_error(); + ::std::string* release_error(); + void set_allocated_error(::std::string* error); + // @@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_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File > file_; ::google::protobuf::internal::ArenaStringPtr error_; - friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; }; -extern ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> CodeGeneratorResponse_default_instance_; - // =================================================================== // =================================================================== #if !PROTOBUF_INLINE_NOT_IN_HEADERS +// Version + +// optional int32 major = 1; +inline bool Version::has_major() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void Version::set_has_major() { + _has_bits_[0] |= 0x00000002u; +} +inline void Version::clear_has_major() { + _has_bits_[0] &= ~0x00000002u; +} +inline void Version::clear_major() { + major_ = 0; + clear_has_major(); +} +inline ::google::protobuf::int32 Version::major() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.major) + return major_; +} +inline void Version::set_major(::google::protobuf::int32 value) { + set_has_major(); + major_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.major) +} + +// optional int32 minor = 2; +inline bool Version::has_minor() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void Version::set_has_minor() { + _has_bits_[0] |= 0x00000004u; +} +inline void Version::clear_has_minor() { + _has_bits_[0] &= ~0x00000004u; +} +inline void Version::clear_minor() { + minor_ = 0; + clear_has_minor(); +} +inline ::google::protobuf::int32 Version::minor() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.minor) + return minor_; +} +inline void Version::set_minor(::google::protobuf::int32 value) { + set_has_minor(); + minor_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.minor) +} + +// optional int32 patch = 3; +inline bool Version::has_patch() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +inline void Version::set_has_patch() { + _has_bits_[0] |= 0x00000008u; +} +inline void Version::clear_has_patch() { + _has_bits_[0] &= ~0x00000008u; +} +inline void Version::clear_patch() { + patch_ = 0; + clear_has_patch(); +} +inline ::google::protobuf::int32 Version::patch() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.patch) + return patch_; +} +inline void Version::set_patch(::google::protobuf::int32 value) { + set_has_patch(); + patch_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.patch) +} + +// optional string suffix = 4; +inline bool Version::has_suffix() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void Version::set_has_suffix() { + _has_bits_[0] |= 0x00000001u; +} +inline void Version::clear_has_suffix() { + _has_bits_[0] &= ~0x00000001u; +} +inline void Version::clear_suffix() { + suffix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_suffix(); +} +inline const ::std::string& Version::suffix() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix) + return suffix_.GetNoArena(); +} +inline void Version::set_suffix(const ::std::string& value) { + set_has_suffix(); + suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) +} +#if LANG_CXX11 +inline void Version::set_suffix(::std::string&& value) { + set_has_suffix(); + suffix_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.Version.suffix) +} +#endif +inline void Version::set_suffix(const char* value) { + set_has_suffix(); + suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.Version.suffix) +} +inline void Version::set_suffix(const char* value, size_t size) { + set_has_suffix(); + suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.Version.suffix) +} +inline ::std::string* Version::mutable_suffix() { + set_has_suffix(); + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.Version.suffix) + return suffix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* Version::release_suffix() { + // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix) + clear_has_suffix(); + return suffix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void Version::set_allocated_suffix(::std::string* suffix) { + if (suffix != NULL) { + set_has_suffix(); + } else { + clear_has_suffix(); + } + suffix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), suffix); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) +} + +// ------------------------------------------------------------------- + // CodeGeneratorRequest // repeated string file_to_generate = 1; @@ -455,6 +845,12 @@ inline void CodeGeneratorRequest::set_file_to_generate(int index, const ::std::s // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) file_to_generate_.Mutable(index)->assign(value); } +#if LANG_CXX11 +inline void CodeGeneratorRequest::set_file_to_generate(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) + file_to_generate_.Mutable(index)->assign(std::move(value)); +} +#endif inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { file_to_generate_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) @@ -472,6 +868,12 @@ inline void CodeGeneratorRequest::add_file_to_generate(const ::std::string& valu file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } +#if LANG_CXX11 +inline void CodeGeneratorRequest::add_file_to_generate(::std::string&& value) { + file_to_generate_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) +} +#endif inline void CodeGeneratorRequest::add_file_to_generate(const char* value) { file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) @@ -493,13 +895,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,13 +909,21 @@ 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(); parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter) } +#if LANG_CXX11 +inline void CodeGeneratorRequest::set_parameter(::std::string&& value) { + set_has_parameter(); + parameter_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorRequest.parameter) +} +#endif inline void CodeGeneratorRequest::set_parameter(const char* value) { set_has_parameter(); parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -575,9 +985,51 @@ CodeGeneratorRequest::proto_file() const { return proto_file_; } -inline const CodeGeneratorRequest* CodeGeneratorRequest::internal_default_instance() { - return &CodeGeneratorRequest_default_instance_.get(); +// optional .google.protobuf.compiler.Version compiler_version = 3; +inline bool CodeGeneratorRequest::has_compiler_version() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void CodeGeneratorRequest::set_has_compiler_version() { + _has_bits_[0] |= 0x00000002u; } +inline void CodeGeneratorRequest::clear_has_compiler_version() { + _has_bits_[0] &= ~0x00000002u; +} +inline void CodeGeneratorRequest::clear_compiler_version() { + if (compiler_version_ != NULL) compiler_version_->::google::protobuf::compiler::Version::Clear(); + clear_has_compiler_version(); +} +inline const ::google::protobuf::compiler::Version& CodeGeneratorRequest::compiler_version() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + return compiler_version_ != NULL ? *compiler_version_ + : *::google::protobuf::compiler::Version::internal_default_instance(); +} +inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::mutable_compiler_version() { + set_has_compiler_version(); + if (compiler_version_ == NULL) { + compiler_version_ = new ::google::protobuf::compiler::Version; + } + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + return compiler_version_; +} +inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::release_compiler_version() { + // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + clear_has_compiler_version(); + ::google::protobuf::compiler::Version* temp = compiler_version_; + compiler_version_ = NULL; + return temp; +} +inline void CodeGeneratorRequest::set_allocated_compiler_version(::google::protobuf::compiler::Version* compiler_version) { + delete compiler_version_; + compiler_version_ = compiler_version; + if (compiler_version) { + set_has_compiler_version(); + } else { + clear_has_compiler_version(); + } + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) +} + // ------------------------------------------------------------------- // CodeGeneratorResponse_File @@ -598,13 +1050,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) } +#if LANG_CXX11 +inline void CodeGeneratorResponse_File::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.name) +} +#endif inline void CodeGeneratorResponse_File::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -652,13 +1112,21 @@ 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(); insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } +#if LANG_CXX11 +inline void CodeGeneratorResponse_File::set_insertion_point(::std::string&& value) { + set_has_insertion_point(); + insertion_point_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) +} +#endif inline void CodeGeneratorResponse_File::set_insertion_point(const char* value) { set_has_insertion_point(); insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -706,13 +1174,21 @@ 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(); content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) } +#if LANG_CXX11 +inline void CodeGeneratorResponse_File::set_content(::std::string&& value) { + set_has_content(); + content_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.content) +} +#endif inline void CodeGeneratorResponse_File::set_content(const char* value) { set_has_content(); content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -744,9 +1220,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,13 +1240,21 @@ 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(); error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error) } +#if LANG_CXX11 +inline void CodeGeneratorResponse::set_error(::std::string&& value) { + set_has_error(); + error_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.error) +} +#endif inline void CodeGeneratorResponse::set_error(const char* value) { set_has_error(); error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -835,17 +1316,17 @@ 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) + } // namespace compiler } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/compiler/plugin.proto b/src/google/protobuf/compiler/plugin.proto index acaee1f4..6e4da2c1 100644 --- a/src/google/protobuf/compiler/plugin.proto +++ b/src/google/protobuf/compiler/plugin.proto @@ -53,6 +53,16 @@ option go_package = "plugin_go"; import "google/protobuf/descriptor.proto"; +// The version number of protocol compiler. +message Version { + optional int32 major = 1; + optional int32 minor = 2; + optional int32 patch = 3; + // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should + // be empty for mainline stable releases. + optional string suffix = 4; +} + // An encoded CodeGeneratorRequest is written to the plugin's stdin. message CodeGeneratorRequest { // The .proto files that were explicitly listed on the command-line. The @@ -75,6 +85,9 @@ message CodeGeneratorRequest { // is not similarly optimized on protoc's end -- it will store all fields in // memory at once before sending them to the plugin. repeated FileDescriptorProto proto_file = 15; + + // The version number of protocol compiler. + optional Version compiler_version = 3; } // The plugin writes an encoded CodeGeneratorResponse to stdout. diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc index 3b1b0d1d..f83f155a 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()); @@ -1380,8 +1380,17 @@ void Generator::FixOptionsForMessage(const Descriptor& descriptor) const { void Generator::CopyPublicDependenciesAliases( const string& copy_from, const FileDescriptor* file) const { for (int i = 0; i < file->public_dependency_count(); ++i) { + string module_name = ModuleName(file->public_dependency(i)->name()); string module_alias = ModuleAlias(file->public_dependency(i)->name()); - printer_->Print("$alias$ = $copy_from$.$alias$\n", "alias", module_alias, + // There's no module alias in the dependent file if it was generated by + // an old protoc (less than 3.0.0-alpha-1). Use module name in this + // situation. + printer_->Print("try:\n" + " $alias$ = $copy_from$.$alias$\n" + "except AttributeError:\n" + " $alias$ = $copy_from$.$module$\n", + "alias", module_alias, + "module", module_name, "copy_from", copy_from); CopyPublicDependenciesAliases(copy_from, file->public_dependency(i)); } 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..c87327ce 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,10 +464,10 @@ 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"}; + "EnumValueOptions", "ServiceOptions", "MethodOptions", "OneofOptions"}; for (int i = 0; i < GOOGLE_ARRAYSIZE(kOptionNames); ++i) { // descriptor.proto has a different package name in opensource. We allow // both so the opensource protocol compiler can also compile internal @@ -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)); } @@ -4056,6 +4114,14 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl( dependency = pool_->underlay_->FindFileByName(proto.dependency(i)); } + if (dependency == result) { + // Recursive import. dependency/result is not fully initialized, and it's + // dangerous to try to do anything with it. The recursive import error + // will be detected and reported in DescriptorBuilder::BuildFile(). + tables_->RollbackToLastCheckpoint(); + return NULL; + } + if (dependency == NULL) { if (pool_->allow_unknown_ || (!pool_->enforce_weak_ && weak_deps.find(i) != weak_deps.end())) { @@ -4141,7 +4207,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 +4355,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 +4366,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 +4477,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 +4492,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 +4762,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 +5243,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 +5260,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 +5454,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 +5605,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 +5732,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 +5752,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 +5764,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 +5776,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 +5911,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 +6019,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 +6069,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 +6531,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..15c97d0b 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -19,898 +19,912 @@ namespace google { namespace protobuf { +class FileDescriptorSetDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> { +} _FileDescriptorSet_default_instance_; +class FileDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> { +} _FileDescriptorProto_default_instance_; +class DescriptorProto_ExtensionRangeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> { +} _DescriptorProto_ExtensionRange_default_instance_; +class DescriptorProto_ReservedRangeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> { +} _DescriptorProto_ReservedRange_default_instance_; +class DescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> { +} _DescriptorProto_default_instance_; +class FieldDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> { +} _FieldDescriptorProto_default_instance_; +class OneofDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> { +} _OneofDescriptorProto_default_instance_; +class EnumDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> { +} _EnumDescriptorProto_default_instance_; +class EnumValueDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> { +} _EnumValueDescriptorProto_default_instance_; +class ServiceDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> { +} _ServiceDescriptorProto_default_instance_; +class MethodDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> { +} _MethodDescriptorProto_default_instance_; +class FileOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileOptions> { +} _FileOptions_default_instance_; +class MessageOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> { +} _MessageOptions_default_instance_; +class FieldOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> { +} _FieldOptions_default_instance_; +class OneofOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> { +} _OneofOptions_default_instance_; +class EnumOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> { +} _EnumOptions_default_instance_; +class EnumValueOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> { +} _EnumValueOptions_default_instance_; +class ServiceOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> { +} _ServiceOptions_default_instance_; +class MethodOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> { +} _MethodOptions_default_instance_; +class UninterpretedOption_NamePartDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> { +} _UninterpretedOption_NamePart_default_instance_; +class UninterpretedOptionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> { +} _UninterpretedOption_default_instance_; +class SourceCodeInfo_LocationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> { +} _SourceCodeInfo_Location_default_instance_; +class SourceCodeInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> { +} _SourceCodeInfo_default_instance_; +class GeneratedCodeInfo_AnnotationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> { +} _GeneratedCodeInfo_Annotation_default_instance_; +class GeneratedCodeInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> { +} _GeneratedCodeInfo_default_instance_; + +namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto { + 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] = { - 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] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, package_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, dependency_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, public_dependency_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, weak_dependency_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, message_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, enum_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, service_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, extension_), - 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] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, field_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, nested_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, enum_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_range_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, oneof_decl_), - 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] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, number_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, label_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, extendee_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, default_value_), - 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] = { - 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] = { - 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] = { - 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] = { - 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] = { - 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] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generate_equals_and_hash_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_string_check_utf8_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, optimize_for_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, go_package_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_generic_services_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generic_services_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, py_generic_services_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, deprecated_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_), - 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] = { - 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] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, ctype_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, packed_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, jstype_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, lazy_), - 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] = { - 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] = { - 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] = { - 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] = { - 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] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, deprecated_), - 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] = { - 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_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, negative_int_value_), - 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] = { - 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] = { - 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_), - }; - 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_)); -} +const ::google::protobuf::uint32 TableStruct::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_), + ~0u, + 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_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, public_dependency_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, weak_dependency_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, message_type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, enum_type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, service_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, extension_), + 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_), + 0, + 1, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + 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_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, nested_type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, enum_type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_range_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, oneof_decl_), + 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_), + 0, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + 1, + ~0u, + ~0u, + 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_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, extendee_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, default_value_), + 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_), + 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_), + 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_), + 0, + ~0u, + 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_), + 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_), + 0, + ~0u, + 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_), + 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_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generate_equals_and_hash_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_string_check_utf8_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, optimize_for_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, go_package_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_generic_services_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generic_services_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, py_generic_services_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, deprecated_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_), + 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, swift_prefix_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_), + 0, + 1, + 6, + 7, + 8, + 14, + 2, + 9, + 10, + 11, + 12, + 13, + 3, + 4, + 5, + ~0u, + 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_), + 0, + 1, + 2, + 3, + ~0u, + 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_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, lazy_), + 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_), + 0, + 2, + 1, + 3, + 4, + 5, + ~0u, + 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_), + ~0u, + 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_), + 0, + 1, + ~0u, + 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_), + 0, + ~0u, + 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_), + 0, + ~0u, + 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_), + 0, + 1, + ~0u, + 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_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, negative_int_value_), + 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_), + ~0u, + 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_), + ~0u, + ~0u, + 0, + 1, + ~0u, + 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_), + ~0u, + 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_), + ~0u, + 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_), + ~0u, +}; + +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, 172, sizeof(FileOptions)}, + { 188, 197, sizeof(MessageOptions)}, + { 202, 213, sizeof(FieldOptions)}, + { 220, 225, sizeof(OneofOptions)}, + { 226, 233, sizeof(EnumOptions)}, + { 236, 242, sizeof(EnumValueOptions)}, + { 244, 250, sizeof(ServiceOptions)}, + { 252, 259, sizeof(MethodOptions)}, + { 262, 268, sizeof(UninterpretedOption_NamePart)}, + { 270, 281, sizeof(UninterpretedOption)}, + { 288, 297, sizeof(SourceCodeInfo_Location)}, + { 302, 307, sizeof(SourceCodeInfo)}, + { 308, 316, sizeof(GeneratedCodeInfo_Annotation)}, + { 320, 325, sizeof(GeneratedCodeInfo)}, +}; + +static ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_FileDescriptorSet_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_FileDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_ExtensionRange_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_ReservedRange_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_FieldDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_OneofDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_EnumDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValueDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_ServiceDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_MethodDescriptorProto_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_FileOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_MessageOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_FieldOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_OneofOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_EnumOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValueOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_ServiceOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_MethodOptions_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_UninterpretedOption_NamePart_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_UninterpretedOption_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_SourceCodeInfo_Location_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_SourceCodeInfo_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_GeneratedCodeInfo_Annotation_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_GeneratedCodeInfo_default_instance_), +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/descriptor.proto", schemas, file_default_instances, TableStruct::offsets, 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_; -} - -void protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl() { +void TableStruct::Shutdown() { + _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 TableStruct::InitDefaultsImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - FileDescriptorSet_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - FileDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - DescriptorProto_default_instance_.DefaultConstruct(); - DescriptorProto_ExtensionRange_default_instance_.DefaultConstruct(); - DescriptorProto_ReservedRange_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - FieldDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - OneofDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - EnumDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - EnumValueDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - ServiceDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - MethodDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - FileOptions_default_instance_.DefaultConstruct(); - MessageOptions_default_instance_.DefaultConstruct(); - FieldOptions_default_instance_.DefaultConstruct(); - OneofOptions_default_instance_.DefaultConstruct(); - EnumOptions_default_instance_.DefaultConstruct(); - EnumValueOptions_default_instance_.DefaultConstruct(); - ServiceOptions_default_instance_.DefaultConstruct(); - MethodOptions_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - UninterpretedOption_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - UninterpretedOption_NamePart_default_instance_.DefaultConstruct(); - SourceCodeInfo_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - SourceCodeInfo_Location_default_instance_.DefaultConstruct(); - GeneratedCodeInfo_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - GeneratedCodeInfo_Annotation_default_instance_.DefaultConstruct(); - FileDescriptorSet_default_instance_.get_mutable()->InitAsDefaultInstance(); - FileDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - DescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - DescriptorProto_ExtensionRange_default_instance_.get_mutable()->InitAsDefaultInstance(); - DescriptorProto_ReservedRange_default_instance_.get_mutable()->InitAsDefaultInstance(); - FieldDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - OneofDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - EnumDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - EnumValueDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - ServiceDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - MethodDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - FileOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - MessageOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - FieldOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - OneofOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - EnumOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - EnumValueOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - ServiceOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - MethodOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - UninterpretedOption_default_instance_.get_mutable()->InitAsDefaultInstance(); - UninterpretedOption_NamePart_default_instance_.get_mutable()->InitAsDefaultInstance(); - SourceCodeInfo_default_instance_.get_mutable()->InitAsDefaultInstance(); - SourceCodeInfo_Location_default_instance_.get_mutable()->InitAsDefaultInstance(); - GeneratedCodeInfo_default_instance_.get_mutable()->InitAsDefaultInstance(); - GeneratedCodeInfo_Annotation_default_instance_.get_mutable()->InitAsDefaultInstance(); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_once_); -void protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl); -} -void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; + ::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()); +} - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); +void InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); +} +void AddDescriptorsImpl() { + InitDefaults(); + 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\"\232\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\022\024\n\014s" + "wift_prefix\030\' \001(\t\022C\n\024uninterpreted_optio" + "n\030\347\007 \003(\0132$.google.protobuf.Uninterpreted" + "Option\":\n\014OptimizeMode\022\t\n\005SPEED\020\001\022\r\n\tCOD" + "E_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010" + "&\020\'\"\354\001\n\016MessageOptions\022&\n\027message_set_wi" + "re_format\030\001 \001(\010:\005false\022.\n\037no_standard_de" + "scriptor_accessor\030\002 \001(\010:\005false\022\031\n\ndeprec" + "ated\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024" + "uninterpreted_option\030\347\007 \003(\0132$.google.pro" + "tobuf.UninterpretedOption*\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#.goo" + "gle.protobuf.FieldOptions.CType:\006STRING\022" + "\016\n\006packed\030\002 \001(\010\022\?\n\006jstype\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\024uninter" + "preted_option\030\347\007 \003(\0132$.google.protobuf.U" + "ninterpretedOption\"/\n\005CType\022\n\n\006STRING\020\000\022" + "\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020\002\"5\n\006JSType\022\r\n" + "\tJS_NORMAL\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER" + "\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024u" + "ninterpreted_option\030\347\007 \003(\0132$.google.prot" + "obuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013" + "EnumOptions\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndepr" + "ecated\030\003 \001(\010:\005false\022C\n\024uninterpreted_opt" + "ion\030\347\007 \003(\0132$.google.protobuf.Uninterpret" + "edOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020EnumValueOptions\022" + "\031\n\ndeprecated\030\001 \001(\010:\005false\022C\n\024uninterpre" + "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin" + "terpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOpt" + "ions\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024unint" + "erpreted_option\030\347\007 \003(\0132$.google.protobuf" + ".UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMeth" + "odOptions\022\031\n\ndeprecated\030! \001(\010:\005false\022_\n\021" + "idempotency_level\030\" \001(\0162/.google.protobu" + "f.MethodOptions.IdempotencyLevel:\023IDEMPO" + "TENCY_UNKNOWN\022C\n\024uninterpreted_option\030\347\007" + " \003(\0132$.google.protobuf.UninterpretedOpti" + "on\"P\n\020IdempotencyLevel\022\027\n\023IDEMPOTENCY_UN" + "KNOWN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTE" + "NT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022" + ";\n\004name\030\002 \003(\0132-.google.protobuf.Uninterp" + "retedOption.NamePart\022\030\n\020identifier_value" + "\030\003 \001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022ne" + "gative_int_value\030\005 \001(\003\022\024\n\014double_value\030\006" + " \001(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_" + "value\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002" + "(\t\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeI" + "nfo\022:\n\010location\030\001 \003(\0132(.google.protobuf." + "SourceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004" + "path\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020lead" + "ing_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" + "(\0132-.google.protobuf.GeneratedCodeInfo.A" + "nnotation\032O\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020" + "\001\022\023\n\013source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n" + "\003end\030\004 \001(\005B\214\001\n\023com.google.protobufB\020Desc" + "riptorProtosH\001Z>github.com/golang/protob" + "uf/protoc-gen-go/descriptor;descriptor\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, 5553); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_once_); -void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_once_, - &protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl); +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); } -} static_descriptor_initializer_google_2fprotobuf_2fdescriptor_2eproto_; +} static_descriptor_initializer; -namespace { +} // namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto + +const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor() { + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::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; + } +} -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_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_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[1]; +} +bool FieldDescriptorProto_Label_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 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_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[2]; +} +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 +const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor() { + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::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_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::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_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::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 +934,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -954,17 +968,15 @@ void FileDescriptorSet::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FileDescriptorSet::descriptor() { - protobuf_AssignDescriptorsOnce(); - return FileDescriptorSet_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[0].descriptor; } const FileDescriptorSet& FileDescriptorSet::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +989,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 +998,21 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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; } @@ -1048,7 +1056,7 @@ void FileDescriptorSet::SerializeWithCachedSizes( ::google::protobuf::uint8* FileDescriptorSet::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorSet) // repeated .google.protobuf.FileDescriptorProto file = 1; for (unsigned int i = 0, n = this->file_size(); i < n; i++) { @@ -1069,6 +1077,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 +1093,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 +1102,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 +1111,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 +1133,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; } @@ -1157,11 +1153,8 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -1197,9 +1190,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 +1211,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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 +1260,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 +1273,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_; } } @@ -1271,17 +1287,15 @@ void FileDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FileDescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return FileDescriptorProto_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[1].descriptor; } const FileDescriptorProto& FileDescriptorProto::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +1306,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 +1345,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1346,14 +1362,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1363,14 +1378,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_dependency())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1381,144 +1395,129 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(98u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_syntax())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1528,7 +1527,6 @@ bool FileDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1578,7 +1576,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( } // repeated string dependency = 3; - for (int i = 0; i < this->dependency_size(); i++) { + for (int i = 0, n = this->dependency_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->dependency(i).data(), this->dependency(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -1624,13 +1622,13 @@ void FileDescriptorProto::SerializeWithCachedSizes( } // repeated int32 public_dependency = 10; - for (int i = 0; i < this->public_dependency_size(); i++) { + for (int i = 0, n = this->public_dependency_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteInt32( 10, this->public_dependency(i), output); } // repeated int32 weak_dependency = 11; - for (int i = 0; i < this->weak_dependency_size(); i++) { + for (int i = 0, n = this->weak_dependency_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteInt32( 11, this->weak_dependency(i), output); } @@ -1654,7 +1652,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( ::google::protobuf::uint8* FileDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorProto) // optional string name = 1; if (has_name()) { @@ -1679,7 +1677,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( } // repeated string dependency = 3; - for (int i = 0; i < this->dependency_size(); i++) { + for (int i = 0, n = this->dependency_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->dependency(i).data(), this->dependency(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -1731,13 +1729,13 @@ void FileDescriptorProto::SerializeWithCachedSizes( } // repeated int32 public_dependency = 10; - for (int i = 0; i < this->public_dependency_size(); i++) { + for (int i = 0, n = this->public_dependency_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: WriteInt32ToArray(10, this->public_dependency(i), target); } // repeated int32 weak_dependency = 11; - for (int i = 0; i < this->weak_dependency_size(); i++) { + for (int i = 0, n = this->weak_dependency_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: WriteInt32ToArray(11, this->weak_dependency(i), target); } @@ -1765,61 +1763,23 @@ 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 * ::google::protobuf::internal::FromIntSize(this->dependency_size()); - for (int i = 0; i < this->dependency_size(); i++) { + for (int i = 0, n = this->dependency_size(); i < n; i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->dependency(i)); } // repeated int32 public_dependency = 10; { - size_t data_size = 0; - unsigned int count = this->public_dependency_size(); - for (unsigned int i = 0; i < count; i++) { - data_size += ::google::protobuf::internal::WireFormatLite:: - Int32Size(this->public_dependency(i)); - } + size_t data_size = ::google::protobuf::internal::WireFormatLite:: + Int32Size(this->public_dependency_); total_size += 1 * ::google::protobuf::internal::FromIntSize(this->public_dependency_size()); total_size += data_size; @@ -1827,12 +1787,8 @@ size_t FileDescriptorProto::ByteSizeLong() const { // repeated int32 weak_dependency = 11; { - size_t data_size = 0; - unsigned int count = this->weak_dependency_size(); - for (unsigned int i = 0; i < count; i++) { - data_size += ::google::protobuf::internal::WireFormatLite:: - Int32Size(this->weak_dependency(i)); - } + size_t data_size = ::google::protobuf::internal::WireFormatLite:: + Int32Size(this->weak_dependency_); total_size += 1 * ::google::protobuf::internal::FromIntSize(this->weak_dependency_size()); total_size += data_size; @@ -1882,10 +1838,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 +1884,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 +1893,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 +1917,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 +1941,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 +1960,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,20 +1967,19 @@ 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_); } ::google::protobuf::Metadata FileDescriptorProto::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FileDescriptorProto_descriptor_; - metadata.reflection = FileDescriptorProto_reflection_; - return metadata; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -2030,13 +2001,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name) } +#if LANG_CXX11 +void FileDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.name) +} +#endif void FileDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -2084,13 +2063,21 @@ 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(); package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package) } +#if LANG_CXX11 +void FileDescriptorProto::set_package(::std::string&& value) { + set_has_package(); + package_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.package) +} +#endif void FileDescriptorProto::set_package(const char* value) { set_has_package(); package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -2141,6 +2128,12 @@ void FileDescriptorProto::set_dependency(int index, const ::std::string& value) // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) dependency_.Mutable(index)->assign(value); } +#if LANG_CXX11 +void FileDescriptorProto::set_dependency(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) + dependency_.Mutable(index)->assign(std::move(value)); +} +#endif void FileDescriptorProto::set_dependency(int index, const char* value) { dependency_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency) @@ -2158,6 +2151,12 @@ void FileDescriptorProto::add_dependency(const ::std::string& value) { dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) } +#if LANG_CXX11 +void FileDescriptorProto::add_dependency(::std::string&& value) { + dependency_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) +} +#endif void FileDescriptorProto::add_dependency(const char* value) { dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency) @@ -2359,13 +2358,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 +2403,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 +2448,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,13 +2462,21 @@ 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(); syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax) } +#if LANG_CXX11 +void FileDescriptorProto::set_syntax(::std::string&& value) { + set_has_syntax(); + syntax_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.syntax) +} +#endif void FileDescriptorProto::set_syntax(const char* value) { set_has_syntax(); syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -2501,9 +2508,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 +2519,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -2551,17 +2557,15 @@ void DescriptorProto_ExtensionRange::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange::descriptor() { - protobuf_AssignDescriptorsOnce(); - return DescriptorProto_ExtensionRange_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[2].descriptor; } const DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +2576,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 +2590,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2619,14 +2605,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(16u)) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2634,7 +2619,6 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2682,7 +2666,7 @@ void DescriptorProto_ExtensionRange::SerializeWithCachedSizes( ::google::protobuf::uint8* DescriptorProto_ExtensionRange::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ExtensionRange) // optional int32 start = 1; if (has_start()) { @@ -2706,6 +2690,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 +2711,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 +2720,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 +2729,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 +2745,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 +2758,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; } @@ -2806,15 +2778,64 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::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 +2844,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -2859,17 +2882,15 @@ void DescriptorProto_ReservedRange::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* DescriptorProto_ReservedRange::descriptor() { - protobuf_AssignDescriptorsOnce(); - return DescriptorProto_ReservedRange_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[3].descriptor; } const DescriptorProto_ReservedRange& DescriptorProto_ReservedRange::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +2901,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 +2915,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2927,14 +2930,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(16u)) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2942,7 +2944,6 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2990,7 +2991,7 @@ void DescriptorProto_ReservedRange::SerializeWithCachedSizes( ::google::protobuf::uint8* DescriptorProto_ReservedRange::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ReservedRange) // optional int32 start = 1; if (has_start()) { @@ -3014,6 +3015,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 +3036,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 +3045,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 +3054,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 +3070,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 +3083,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; } @@ -3114,15 +3103,64 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::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 +3177,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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 +3222,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_; } } @@ -3181,17 +3233,15 @@ void DescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* DescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return DescriptorProto_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[4].descriptor; } const DescriptorProto& DescriptorProto::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +3252,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 +3260,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 +3280,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -3246,141 +3297,123 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(82u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_reserved_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -3391,8 +3424,6 @@ bool DescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(82)) goto parse_reserved_name; - if (input->ExpectAtEnd()) goto success; break; } @@ -3480,7 +3511,7 @@ void DescriptorProto::SerializeWithCachedSizes( } // repeated string reserved_name = 10; - for (int i = 0; i < this->reserved_name_size(); i++) { + for (int i = 0, n = this->reserved_name_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->reserved_name(i).data(), this->reserved_name(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -3498,7 +3529,7 @@ void DescriptorProto::SerializeWithCachedSizes( ::google::protobuf::uint8* DescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto) // optional string name = 1; if (has_name()) { @@ -3568,7 +3599,7 @@ void DescriptorProto::SerializeWithCachedSizes( } // repeated string reserved_name = 10; - for (int i = 0; i < this->reserved_name_size(); i++) { + for (int i = 0, n = this->reserved_name_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->reserved_name(i).data(), this->reserved_name(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -3589,21 +3620,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; { @@ -3685,15 +3705,26 @@ size_t DescriptorProto::ByteSizeLong() const { // repeated string reserved_name = 10; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->reserved_name_size()); - for (int i = 0; i < this->reserved_name_size(); i++) { + for (int i = 0, n = this->reserved_name_size(); i < n; i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( 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 +3735,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 +3744,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 +3759,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 +3769,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 +3782,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,140 +3802,27 @@ 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_); } ::google::protobuf::Metadata DescriptorProto::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DescriptorProto_descriptor_; - metadata.reflection = DescriptorProto_reflection_; - return metadata; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::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,13 +3841,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name) } +#if LANG_CXX11 +void DescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.DescriptorProto.name) +} +#endif void DescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -4155,13 +4069,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(); @@ -4247,6 +4161,12 @@ void DescriptorProto::set_reserved_name(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) reserved_name_.Mutable(index)->assign(value); } +#if LANG_CXX11 +void DescriptorProto::set_reserved_name(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) + reserved_name_.Mutable(index)->assign(std::move(value)); +} +#endif void DescriptorProto::set_reserved_name(int index, const char* value) { reserved_name_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name) @@ -4264,6 +4184,12 @@ void DescriptorProto::add_reserved_name(const ::std::string& value) { reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) } +#if LANG_CXX11 +void DescriptorProto::add_reserved_name(::std::string&& value) { + reserved_name_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) +} +#endif void DescriptorProto::add_reserved_name(const char* value) { reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name) @@ -4283,89 +4209,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 +4228,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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 +4278,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 +4295,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_; } } @@ -4435,17 +4306,15 @@ void FieldDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FieldDescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldDescriptorProto_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[5].descriptor; } const FieldDescriptorProto& FieldDescriptorProto::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +4325,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 +4369,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4529,14 +4386,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_extendee())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4546,14 +4402,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(24u)) { set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -4561,14 +4416,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(32u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -4581,14 +4435,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(40u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -4601,14 +4454,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(50u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4618,14 +4470,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(58u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_default_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4635,27 +4486,25 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(72u)) { set_has_oneof_index(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -4663,14 +4512,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(82u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_json_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4680,7 +4528,6 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -4796,7 +4643,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes( ::google::protobuf::uint8* FieldDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldDescriptorProto) // optional string name = 1; if (has_name()) { @@ -4894,6 +4741,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 +4754,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 +4775,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 +4789,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 +4827,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 +4836,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 +4861,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 +4868,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 +4896,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,26 +4912,23 @@ 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_); } ::google::protobuf::Metadata FieldDescriptorProto::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FieldDescriptorProto_descriptor_; - metadata.reflection = FieldDescriptorProto_reflection_; - return metadata; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[5]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -5118,13 +4950,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name) } +#if LANG_CXX11 +void FieldDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.name) +} +#endif void FieldDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5158,13 +4998,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 +5022,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 +5047,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 +5072,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,13 +5086,21 @@ 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(); type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name) } +#if LANG_CXX11 +void FieldDescriptorProto::set_type_name(::std::string&& value) { + set_has_type_name(); + type_name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.type_name) +} +#endif void FieldDescriptorProto::set_type_name(const char* value) { set_has_type_name(); type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5286,13 +5134,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,13 +5148,21 @@ 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(); extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee) } +#if LANG_CXX11 +void FieldDescriptorProto::set_extendee(::std::string&& value) { + set_has_extendee(); + extendee_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.extendee) +} +#endif void FieldDescriptorProto::set_extendee(const char* value) { set_has_extendee(); extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5340,13 +5196,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,13 +5210,21 @@ 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(); default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value) } +#if LANG_CXX11 +void FieldDescriptorProto::set_default_value(::std::string&& value) { + set_has_default_value(); + default_value_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.default_value) +} +#endif void FieldDescriptorProto::set_default_value(const char* value) { set_has_default_value(); default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5418,13 +5282,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,13 +5296,21 @@ 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(); json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name) } +#if LANG_CXX11 +void FieldDescriptorProto::set_json_name(::std::string&& value) { + set_has_json_name(); + json_name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.json_name) +} +#endif void FieldDescriptorProto::set_json_name(const char* value) { set_has_json_name(); json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5472,13 +5344,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 +5387,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 +5398,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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 +5435,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_; } } @@ -5571,17 +5446,15 @@ void OneofDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* OneofDescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return OneofDescriptorProto_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[6].descriptor; } const OneofDescriptorProto& OneofDescriptorProto::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +5467,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 +5485,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -5628,20 +5502,18 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -5695,7 +5567,7 @@ void OneofDescriptorProto::SerializeWithCachedSizes( ::google::protobuf::uint8* OneofDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofDescriptorProto) // optional string name = 1; if (has_name()) { @@ -5727,6 +5599,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 +5620,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 +5629,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 +5638,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 +5655,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 +5668,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; } @@ -5831,11 +5691,8 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[6]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -5857,13 +5714,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name) } +#if LANG_CXX11 +void OneofDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.OneofDescriptorProto.name) +} +#endif void OneofDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5940,9 +5805,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 +5817,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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 +5855,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_; } } @@ -5997,17 +5866,15 @@ void EnumDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* EnumDescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return EnumDescriptorProto_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[7].descriptor; } const EnumDescriptorProto& EnumDescriptorProto::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +5885,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 +5906,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -6055,37 +5923,32 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -6145,7 +6008,7 @@ void EnumDescriptorProto::SerializeWithCachedSizes( ::google::protobuf::uint8* EnumDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumDescriptorProto) // optional string name = 1; if (has_name()) { @@ -6184,7 +6047,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 +6079,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 +6088,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 +6097,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 +6115,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 +6128,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 +6144,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_); @@ -6302,11 +6153,8 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[7]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -6328,13 +6176,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name) } +#if LANG_CXX11 +void EnumDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumDescriptorProto.name) +} +#endif void EnumDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -6398,13 +6254,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 +6297,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 +6309,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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 +6348,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_; } } @@ -6499,17 +6359,15 @@ void EnumValueDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* EnumValueDescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return EnumValueDescriptorProto_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[8].descriptor; } const EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +6378,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 +6399,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -6557,14 +6416,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(16u)) { set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -6572,20 +6430,18 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -6644,7 +6500,7 @@ void EnumValueDescriptorProto::SerializeWithCachedSizes( ::google::protobuf::uint8* EnumValueDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueDescriptorProto) // optional string name = 1; if (has_name()) { @@ -6681,6 +6537,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 +6550,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 +6557,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 +6574,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 +6583,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 +6616,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,19 +6632,16 @@ 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_); } ::google::protobuf::Metadata EnumValueDescriptorProto::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumValueDescriptorProto_descriptor_; - metadata.reflection = EnumValueDescriptorProto_reflection_; - return metadata; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[8]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -6822,13 +6663,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name) } +#if LANG_CXX11 +void EnumValueDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumValueDescriptorProto.name) +} +#endif void EnumValueDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -6862,13 +6711,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 +6735,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 +6778,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 +6790,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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 +6828,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_; } } @@ -6986,17 +6839,15 @@ void ServiceDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* ServiceDescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return ServiceDescriptorProto_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[9].descriptor; } const ServiceDescriptorProto& ServiceDescriptorProto::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +6858,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 +6879,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7044,37 +6896,32 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -7134,7 +6981,7 @@ void ServiceDescriptorProto::SerializeWithCachedSizes( ::google::protobuf::uint8* ServiceDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceDescriptorProto) // optional string name = 1; if (has_name()) { @@ -7173,7 +7020,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 +7052,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 +7061,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 +7070,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 +7088,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 +7101,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 +7117,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_); @@ -7291,11 +7126,8 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[9]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -7317,13 +7149,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name) } +#if LANG_CXX11 +void ServiceDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.ServiceDescriptorProto.name) +} +#endif void ServiceDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -7387,13 +7227,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 +7270,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 +7285,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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 +7325,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 +7338,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_; } } @@ -7496,17 +7349,15 @@ void MethodDescriptorProto::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* MethodDescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return MethodDescriptorProto_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[10].descriptor; } const MethodDescriptorProto& MethodDescriptorProto::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +7368,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 +7400,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7580,14 +7417,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_input_type())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7597,14 +7433,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_output_type())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7614,27 +7449,25 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(40u)) { set_has_client_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -7642,14 +7475,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(48u)) { set_has_server_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -7657,7 +7489,6 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -7741,7 +7572,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes( ::google::protobuf::uint8* MethodDescriptorProto::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodDescriptorProto) // optional string name = 1; if (has_name()) { @@ -7805,6 +7636,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 +7681,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 +7690,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 +7699,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 +7730,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 +7743,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; } @@ -7951,11 +7770,8 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[10]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -7977,13 +7793,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name) } +#if LANG_CXX11 +void MethodDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.name) +} +#endif void MethodDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -8031,13 +7855,21 @@ 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(); input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type) } +#if LANG_CXX11 +void MethodDescriptorProto::set_input_type(::std::string&& value) { + set_has_input_type(); + input_type_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.input_type) +} +#endif void MethodDescriptorProto::set_input_type(const char* value) { set_has_input_type(); input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -8085,13 +7917,21 @@ 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(); output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type) } +#if LANG_CXX11 +void MethodDescriptorProto::set_output_type(::std::string&& value) { + set_has_output_type(); + output_type_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.output_type) +} +#endif void MethodDescriptorProto::set_output_type(const char* value) { set_has_output_type(); output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -8216,36 +8056,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; @@ -8261,24 +8075,53 @@ const int FileOptions::kDeprecatedFieldNumber; const int FileOptions::kCcEnableArenasFieldNumber; const int FileOptions::kObjcClassPrefixFieldNumber; const int FileOptions::kCsharpNamespaceFieldNumber; +const int FileOptions::kSwiftPrefixFieldNumber; const int FileOptions::kUninterpretedOptionFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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_); + } + swift_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_swift_prefix()) { + swift_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.swift_prefix_); + } + ::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) } @@ -8289,6 +8132,7 @@ void FileOptions::SharedCtor() { go_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + swift_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); ::memset(&java_multiple_files_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) - reinterpret_cast<char*>(&java_multiple_files_) + sizeof(cc_enable_arenas_)); optimize_for_ = 1; @@ -8305,6 +8149,7 @@ void FileOptions::SharedDtor() { go_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); objc_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + swift_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void FileOptions::SetCachedSize(int size) const { @@ -8313,17 +8158,15 @@ void FileOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FileOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return FileOptions_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[11].descriptor; } const FileOptions& FileOptions::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +8178,44 @@ 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] & 63u) { 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(); + } + if (has_swift_prefix()) { + GOOGLE_DCHECK(!swift_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*swift_prefix_.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] & 192u) { + ::memset(&java_multiple_files_, 0, reinterpret_cast<char*>(&java_generate_equals_and_hash_) - + reinterpret_cast<char*>(&java_multiple_files_) + sizeof(java_generate_equals_and_hash_)); + } + if (_has_bits_[8 / 32] & 32512u) { + ::memset(&java_string_check_utf8_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) - + reinterpret_cast<char*>(&java_string_check_utf8_) + sizeof(cc_enable_arenas_)); + optimize_for_ = 1; } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool FileOptions::MergePartialFromCodedStream( @@ -8390,13 +8224,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_java_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8406,14 +8241,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(66u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_java_outer_classname())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8423,14 +8257,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(72u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -8443,14 +8276,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(80u)) { set_has_java_multiple_files(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8458,14 +8290,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(90u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_go_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8475,14 +8306,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(128u)) { set_has_cc_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8490,14 +8320,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(136u)) { set_has_java_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8505,14 +8334,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(144u)) { set_has_py_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8520,14 +8348,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(160u)) { set_has_java_generate_equals_and_hash(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8535,14 +8362,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(184u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8550,14 +8376,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(216u)) { set_has_java_string_check_utf8(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8565,14 +8390,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(248u)) { set_has_cc_enable_arenas(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8580,14 +8404,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(290u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_objc_class_prefix())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8597,14 +8420,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(298u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_csharp_namespace())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8614,24 +8436,36 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; + break; + } + + // optional string swift_prefix = 39; + case 39: { + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(314u)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_swift_prefix())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->swift_prefix().data(), this->swift_prefix().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "google.protobuf.FileOptions.swift_prefix"); + } else { + goto handle_unusual; + } break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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; } @@ -8761,6 +8595,16 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), output); } + // optional string swift_prefix = 39; + if (has_swift_prefix()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->swift_prefix().data(), this->swift_prefix().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.swift_prefix"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 39, this->swift_prefix(), 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( @@ -8780,7 +8624,7 @@ void FileOptions::SerializeWithCachedSizes( ::google::protobuf::uint8* FileOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileOptions) // optional string java_package = 1; if (has_java_package()) { @@ -8883,6 +8727,17 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), target); } + // optional string swift_prefix = 39; + if (has_swift_prefix()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->swift_prefix().data(), this->swift_prefix().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.swift_prefix"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 39, this->swift_prefix(), 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:: @@ -8892,7 +8747,7 @@ void FileOptions::SerializeWithCachedSizes( // Extension range [1000, 536870912) target = _extensions_.InternalSerializeWithCachedSizesToArray( - 1000, 536870912, false, target); + 1000, 536870912, deterministic, target); if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( @@ -8906,6 +8761,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 +8794,34 @@ 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 string swift_prefix = 39; + if (has_swift_prefix()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->swift_prefix()); + } + // optional bool java_multiple_files = 10 [default = false]; if (has_java_multiple_files()) { total_size += 1 + 1; @@ -8931,31 +8832,18 @@ size_t FileOptions::ByteSizeLong() const { total_size += 2 + 1; } + } + if (_has_bits_[8 / 32] & 32512u) { // optional bool java_string_check_utf8 = 27 [default = false]; if (has_java_string_check_utf8()) { 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()); - } - // 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 +8864,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 +8880,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 +8889,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,27 +8908,36 @@ 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_swift_prefix()) { + set_has_swift_prefix(); + swift_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.swift_prefix_); + } if (from.has_java_multiple_files()) { set_java_multiple_files(from.java_multiple_files()); } if (from.has_java_generate_equals_and_hash()) { set_java_generate_equals_and_hash(from.java_generate_equals_and_hash()); } + } + if (from._has_bits_[8 / 32] & 32512u) { 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_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 +8950,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 +8967,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 +8984,22 @@ 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_); + swift_prefix_.Swap(&other->swift_prefix_); 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_); @@ -9152,11 +9007,8 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[11]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -9178,13 +9030,21 @@ 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(); java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package) } +#if LANG_CXX11 +void FileOptions::set_java_package(::std::string&& value) { + set_has_java_package(); + java_package_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_package) +} +#endif void FileOptions::set_java_package(const char* value) { set_has_java_package(); java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -9232,13 +9092,21 @@ 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(); java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname) } +#if LANG_CXX11 +void FileOptions::set_java_outer_classname(::std::string&& value) { + set_has_java_outer_classname(); + java_outer_classname_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_outer_classname) +} +#endif void FileOptions::set_java_outer_classname(const char* value) { set_has_java_outer_classname(); java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -9272,13 +9140,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] & 0x00000040u) != 0; } void FileOptions::set_has_java_multiple_files() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000040u; } void FileOptions::clear_has_java_multiple_files() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000040u; } void FileOptions::clear_java_multiple_files() { java_multiple_files_ = false; @@ -9296,13 +9164,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] & 0x00000080u) != 0; } void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000080u; } void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000080u; } void FileOptions::clear_java_generate_equals_and_hash() { java_generate_equals_and_hash_ = false; @@ -9320,13 +9188,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] & 0x00000100u) != 0; } void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000100u; } void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000100u; } void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; @@ -9344,13 +9212,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] & 0x00004000u) != 0; } void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00004000u; } void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00004000u; } void FileOptions::clear_optimize_for() { optimize_for_ = 1; @@ -9369,13 +9237,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,13 +9251,21 @@ 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(); go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package) } +#if LANG_CXX11 +void FileOptions::set_go_package(::std::string&& value) { + set_has_go_package(); + go_package_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.go_package) +} +#endif void FileOptions::set_go_package(const char* value) { set_has_go_package(); go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -9423,13 +9299,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] & 0x00000200u) != 0; } void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000200u; } void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000200u; } void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; @@ -9447,13 +9323,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] & 0x00000400u) != 0; } void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000400u; } void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000400u; } void FileOptions::clear_java_generic_services() { java_generic_services_ = false; @@ -9471,13 +9347,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] & 0x00000800u) != 0; } void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000800u; } void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000800u; } void FileOptions::clear_py_generic_services() { py_generic_services_ = false; @@ -9495,13 +9371,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] & 0x00001000u) != 0; } void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00001000u; } void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00001000u; } void FileOptions::clear_deprecated() { deprecated_ = false; @@ -9519,13 +9395,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] & 0x00002000u) != 0; } void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00002000u; } void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00002000u; } void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; @@ -9543,13 +9419,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,13 +9433,21 @@ 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(); objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix) } +#if LANG_CXX11 +void FileOptions::set_objc_class_prefix(::std::string&& value) { + set_has_objc_class_prefix(); + objc_class_prefix_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.objc_class_prefix) +} +#endif void FileOptions::set_objc_class_prefix(const char* value) { set_has_objc_class_prefix(); objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -9597,13 +9481,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,13 +9495,21 @@ 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(); csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace) } +#if LANG_CXX11 +void FileOptions::set_csharp_namespace(::std::string&& value) { + set_has_csharp_namespace(); + csharp_namespace_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.csharp_namespace) +} +#endif void FileOptions::set_csharp_namespace(const char* value) { set_has_csharp_namespace(); csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -9649,6 +9541,68 @@ void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_namespace // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } +// optional string swift_prefix = 39; +bool FileOptions::has_swift_prefix() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void FileOptions::set_has_swift_prefix() { + _has_bits_[0] |= 0x00000020u; +} +void FileOptions::clear_has_swift_prefix() { + _has_bits_[0] &= ~0x00000020u; +} +void FileOptions::clear_swift_prefix() { + swift_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_swift_prefix(); +} +const ::std::string& FileOptions::swift_prefix() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.swift_prefix) + return swift_prefix_.GetNoArena(); +} +void FileOptions::set_swift_prefix(const ::std::string& value) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix) +} +#if LANG_CXX11 +void FileOptions::set_swift_prefix(::std::string&& value) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.swift_prefix) +} +#endif +void FileOptions::set_swift_prefix(const char* value) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.swift_prefix) +} +void FileOptions::set_swift_prefix(const char* value, size_t size) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.swift_prefix) +} +::std::string* FileOptions::mutable_swift_prefix() { + set_has_swift_prefix(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.swift_prefix) + return swift_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* FileOptions::release_swift_prefix() { + // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix) + clear_has_swift_prefix(); + return swift_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void FileOptions::set_allocated_swift_prefix(::std::string* swift_prefix) { + if (swift_prefix != NULL) { + set_has_swift_prefix(); + } else { + clear_has_swift_prefix(); + } + swift_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), swift_prefix); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int FileOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); @@ -9679,9 +9633,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 +9647,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -9732,17 +9687,15 @@ void MessageOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* MessageOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return MessageOptions_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[12].descriptor; } const MessageOptions& MessageOptions::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +9707,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 +9722,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { set_has_message_set_wire_format(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9802,14 +9737,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(16u)) { set_has_no_standard_descriptor_accessor(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9817,14 +9751,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(24u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9832,14 +9765,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(56u)) { set_has_map_entry(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9847,24 +9779,20 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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; } @@ -9937,7 +9865,7 @@ void MessageOptions::SerializeWithCachedSizes( ::google::protobuf::uint8* MessageOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MessageOptions) // optional bool message_set_wire_format = 1 [default = false]; if (has_message_set_wire_format()) { @@ -9968,7 +9896,7 @@ void MessageOptions::SerializeWithCachedSizes( // Extension range [1000, 536870912) target = _extensions_.InternalSerializeWithCachedSizesToArray( - 1000, 536870912, false, target); + 1000, 536870912, deterministic, target); if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( @@ -9982,6 +9910,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 +9950,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 +9959,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 +9968,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 +9992,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 +10005,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 +10022,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_); @@ -10118,11 +10034,8 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[12]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -10254,59 +10167,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 +10183,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -10355,17 +10223,15 @@ void FieldOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FieldOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldOptions_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[13].descriptor; } const FieldOptions& FieldOptions::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +10243,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 +10258,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -10430,14 +10278,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(16u)) { set_has_packed(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10445,14 +10292,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(24u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10460,14 +10306,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(40u)) { set_has_lazy(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10475,14 +10320,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(48u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -10495,14 +10339,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(80u)) { set_has_weak(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10510,24 +10353,20 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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; } @@ -10612,7 +10451,7 @@ void FieldOptions::SerializeWithCachedSizes( ::google::protobuf::uint8* FieldOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldOptions) // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; if (has_ctype()) { @@ -10655,7 +10494,7 @@ void FieldOptions::SerializeWithCachedSizes( // Extension range [1000, 536870912) target = _extensions_.InternalSerializeWithCachedSizesToArray( - 1000, 536870912, false, target); + 1000, 536870912, deterministic, target); if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( @@ -10669,6 +10508,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 +10533,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 +10560,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 +10569,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 +10578,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 +10608,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 +10621,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 +10638,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_); @@ -10825,11 +10652,8 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[13]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -10862,13 +10686,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 +10710,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 +10835,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 +10845,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -11058,17 +10880,15 @@ void OneofOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* OneofOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return OneofOptions_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[14].descriptor; } const OneofOptions& OneofOptions::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +10902,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 +10911,21 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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; } @@ -11162,7 +10978,7 @@ void OneofOptions::SerializeWithCachedSizes( ::google::protobuf::uint8* OneofOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofOptions) // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { @@ -11173,7 +10989,7 @@ void OneofOptions::SerializeWithCachedSizes( // Extension range [1000, 536870912) target = _extensions_.InternalSerializeWithCachedSizesToArray( - 1000, 536870912, false, target); + 1000, 536870912, deterministic, target); if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( @@ -11187,6 +11003,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 +11021,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 +11030,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 +11039,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 +11062,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; } @@ -11283,11 +11087,8 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[14]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -11323,9 +11124,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 +11136,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -11374,17 +11176,15 @@ void EnumOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* EnumOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return EnumOptions_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[15].descriptor; } const EnumOptions& EnumOptions::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +11196,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 +11211,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(16u)) { set_has_allow_alias(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11444,14 +11226,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(24u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11459,24 +11240,20 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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; } @@ -11539,7 +11316,7 @@ void EnumOptions::SerializeWithCachedSizes( ::google::protobuf::uint8* EnumOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumOptions) // optional bool allow_alias = 2; if (has_allow_alias()) { @@ -11560,7 +11337,7 @@ void EnumOptions::SerializeWithCachedSizes( // Extension range [1000, 536870912) target = _extensions_.InternalSerializeWithCachedSizesToArray( - 1000, 536870912, false, target); + 1000, 536870912, deterministic, target); if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( @@ -11574,17 +11351,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 +11369,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 +11390,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 +11399,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 +11417,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 +11430,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 +11447,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_); @@ -11692,11 +11457,8 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[15]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -11780,9 +11542,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 +11553,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -11829,17 +11590,15 @@ void EnumValueOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* EnumValueOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return EnumValueOptions_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[16].descriptor; } const EnumValueOptions& EnumValueOptions::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +11610,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 +11622,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11879,24 +11637,20 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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; } @@ -11954,7 +11708,7 @@ void EnumValueOptions::SerializeWithCachedSizes( ::google::protobuf::uint8* EnumValueOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueOptions) // optional bool deprecated = 1 [default = false]; if (has_deprecated()) { @@ -11970,7 +11724,7 @@ void EnumValueOptions::SerializeWithCachedSizes( // Extension range [1000, 536870912) target = _extensions_.InternalSerializeWithCachedSizesToArray( - 1000, 536870912, false, target); + 1000, 536870912, deterministic, target); if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( @@ -11984,11 +11738,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 +11756,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 +11770,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 +11779,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 +11805,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 +11822,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_); @@ -12091,11 +11831,8 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[16]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -12155,9 +11892,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 +11903,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -12204,17 +11940,15 @@ void ServiceOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* ServiceOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return ServiceOptions_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[17].descriptor; } const ServiceOptions& ServiceOptions::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +11960,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 +11972,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(264u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -12254,24 +11987,20 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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; } @@ -12329,7 +12058,7 @@ void ServiceOptions::SerializeWithCachedSizes( ::google::protobuf::uint8* ServiceOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceOptions) // optional bool deprecated = 33 [default = false]; if (has_deprecated()) { @@ -12345,7 +12074,7 @@ void ServiceOptions::SerializeWithCachedSizes( // Extension range [1000, 536870912) target = _extensions_.InternalSerializeWithCachedSizesToArray( - 1000, 536870912, false, target); + 1000, 536870912, deterministic, target); if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( @@ -12359,11 +12088,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 +12106,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 +12120,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 +12129,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 +12155,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 +12172,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_); @@ -12466,11 +12181,8 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[17]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -12530,39 +12242,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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() { @@ -12579,17 +12294,15 @@ void MethodOptions::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* MethodOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return MethodOptions_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[18].descriptor; } const MethodOptions& MethodOptions::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +12314,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 +12329,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(264u)) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -12629,24 +12344,39 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 +12415,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( @@ -12704,13 +12440,19 @@ void MethodOptions::SerializeWithCachedSizes( ::google::protobuf::uint8* MethodOptions::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodOptions) // optional bool deprecated = 33 [default = false]; if (has_deprecated()) { 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:: @@ -12720,7 +12462,7 @@ void MethodOptions::SerializeWithCachedSizes( // Extension range [1000, 536870912) target = _extensions_.InternalSerializeWithCachedSizesToArray( - 1000, 536870912, false, target); + 1000, 536870912, deterministic, target); if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( @@ -12734,11 +12476,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 +12494,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 +12516,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 +12525,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 +12556,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 +12573,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_); @@ -12841,11 +12583,8 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[18]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -12875,6 +12614,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 +12669,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 +12680,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -12956,17 +12721,15 @@ void UninterpretedOption_NamePart::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* UninterpretedOption_NamePart::descriptor() { - protobuf_AssignDescriptorsOnce(); - return UninterpretedOption_NamePart_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[19].descriptor; } const UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +12740,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 +12755,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name_part())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13011,14 +12772,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(16u)) { set_has_is_extension(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -13026,7 +12786,6 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -13079,7 +12838,7 @@ void UninterpretedOption_NamePart::SerializeWithCachedSizes( ::google::protobuf::uint8* UninterpretedOption_NamePart::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption.NamePart) // required string name_part = 1; if (has_name_part()) { @@ -13127,6 +12886,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 +12903,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 +12912,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 +12921,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 +12938,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 +12951,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; } @@ -13225,15 +12972,102 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::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) +} +#if LANG_CXX11 +void UninterpretedOption_NamePart::set_name_part(::std::string&& value) { + set_has_name_part(); + name_part_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.NamePart.name_part) +} +#endif +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 +13081,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -13289,17 +13138,15 @@ void UninterpretedOption::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* UninterpretedOption::descriptor() { - protobuf_AssignDescriptorsOnce(); - return UninterpretedOption_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[20].descriptor; } const UninterpretedOption& UninterpretedOption::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +13157,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 +13186,28 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_identifier_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13388,14 +13217,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(32u)) { set_has_positive_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( @@ -13403,14 +13231,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(40u)) { set_has_negative_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -13418,14 +13245,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(49u)) { set_has_double_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -13433,27 +13259,25 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(66u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_aggregate_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13463,7 +13287,6 @@ bool UninterpretedOption::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -13548,7 +13371,7 @@ void UninterpretedOption::SerializeWithCachedSizes( ::google::protobuf::uint8* UninterpretedOption::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption) // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; for (unsigned int i = 0, n = this->name_size(); i < n; i++) { @@ -13613,7 +13436,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 +13460,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 +13493,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 +13503,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 +13512,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 +13543,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 +13557,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,110 +13572,22 @@ 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_); } ::google::protobuf::Metadata UninterpretedOption::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = UninterpretedOption_descriptor_; - metadata.reflection = UninterpretedOption_reflection_; - return metadata; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::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 +13622,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,13 +13636,21 @@ 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(); identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value) } +#if LANG_CXX11 +void UninterpretedOption::set_identifier_value(::std::string&& value) { + set_has_identifier_value(); + identifier_value_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.identifier_value) +} +#endif void UninterpretedOption::set_identifier_value(const char* value) { set_has_identifier_value(); identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -13953,13 +13684,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 +13708,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 +13732,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 +13756,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,13 +13770,21 @@ 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(); string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value) } +#if LANG_CXX11 +void UninterpretedOption::set_string_value(::std::string&& value) { + set_has_string_value(); + string_value_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.string_value) +} +#endif void UninterpretedOption::set_string_value(const char* value) { set_has_string_value(); string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -14079,13 +13818,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,13 +13832,21 @@ 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(); aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value) } +#if LANG_CXX11 +void UninterpretedOption::set_aggregate_value(::std::string&& value) { + set_has_aggregate_value(); + aggregate_value_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.aggregate_value) +} +#endif void UninterpretedOption::set_aggregate_value(const char* value) { set_has_aggregate_value(); aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -14131,9 +13878,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 +13892,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -14186,17 +13940,15 @@ void SourceCodeInfo_Location::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* SourceCodeInfo_Location::descriptor() { - protobuf_AssignDescriptorsOnce(); - return SourceCodeInfo_Location_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[21].descriptor; } const SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +13959,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 +13982,50 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_leading_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -14282,14 +14035,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(34u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_trailing_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -14299,14 +14051,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(50u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_leading_detached_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -14317,8 +14068,6 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_leading_detached_comments; - if (input->ExpectAtEnd()) goto success; break; } @@ -14352,7 +14101,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); output->WriteVarint32(_path_cached_byte_size_); } - for (int i = 0; i < this->path_size(); i++) { + for (int i = 0, n = this->path_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag( this->path(i), output); } @@ -14362,7 +14111,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteTag(2, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); output->WriteVarint32(_span_cached_byte_size_); } - for (int i = 0; i < this->span_size(); i++) { + for (int i = 0, n = this->span_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag( this->span(i), output); } @@ -14388,7 +14137,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( } // repeated string leading_detached_comments = 6; - for (int i = 0; i < this->leading_detached_comments_size(); i++) { + for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -14406,7 +14155,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( ::google::protobuf::uint8* SourceCodeInfo_Location::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo.Location) // repeated int32 path = 1 [packed = true]; if (this->path_size() > 0) { @@ -14417,7 +14166,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( _path_cached_byte_size_, target); } - for (int i = 0; i < this->path_size(); i++) { + for (int i = 0, n = this->path_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: WriteInt32NoTagToArray(this->path(i), target); } @@ -14431,7 +14180,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( _span_cached_byte_size_, target); } - for (int i = 0; i < this->span_size(); i++) { + for (int i = 0, n = this->span_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: WriteInt32NoTagToArray(this->span(i), target); } @@ -14459,7 +14208,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( } // repeated string leading_detached_comments = 6; - for (int i = 0; i < this->leading_detached_comments_size(); i++) { + for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(), ::google::protobuf::internal::WireFormat::SERIALIZE, @@ -14480,30 +14229,15 @@ 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]; { - 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)); - } + size_t data_size = ::google::protobuf::internal::WireFormatLite:: + Int32Size(this->path_); if (data_size > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); @@ -14517,12 +14251,8 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { // repeated int32 span = 2 [packed = true]; { - size_t data_size = 0; - unsigned int count = this->span_size(); - for (unsigned int i = 0; i < count; i++) { - data_size += ::google::protobuf::internal::WireFormatLite:: - Int32Size(this->span(i)); - } + size_t data_size = ::google::protobuf::internal::WireFormatLite:: + Int32Size(this->span_); if (data_size > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); @@ -14537,15 +14267,26 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { // repeated string leading_detached_comments = 6; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->leading_detached_comments_size()); - for (int i = 0; i < this->leading_detached_comments_size(); i++) { + for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( 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 +14297,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 +14306,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 +14327,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 +14340,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,272 +14354,17 @@ 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_); } ::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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[21]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -14958,13 +14432,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,13 +14446,21 @@ 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(); leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments) } +#if LANG_CXX11 +void SourceCodeInfo_Location::set_leading_comments(::std::string&& value) { + set_has_leading_comments(); + leading_comments_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.leading_comments) +} +#endif void SourceCodeInfo_Location::set_leading_comments(const char* value) { set_has_leading_comments(); leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -15012,13 +14494,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,13 +14508,21 @@ 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(); trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments) } +#if LANG_CXX11 +void SourceCodeInfo_Location::set_trailing_comments(::std::string&& value) { + set_has_trailing_comments(); + trailing_comments_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.trailing_comments) +} +#endif void SourceCodeInfo_Location::set_trailing_comments(const char* value) { set_has_trailing_comments(); trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -15083,6 +14573,12 @@ void SourceCodeInfo_Location::set_leading_detached_comments(int index, const ::s // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) leading_detached_comments_.Mutable(index)->assign(value); } +#if LANG_CXX11 +void SourceCodeInfo_Location::set_leading_detached_comments(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) + leading_detached_comments_.Mutable(index)->assign(std::move(value)); +} +#endif void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) { leading_detached_comments_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) @@ -15100,6 +14596,12 @@ void SourceCodeInfo_Location::add_leading_detached_comments(const ::std::string& leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } +#if LANG_CXX11 +void SourceCodeInfo_Location::add_leading_detached_comments(::std::string&& value) { + leading_detached_comments_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) +} +#endif void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) { leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) @@ -15119,11 +14621,239 @@ 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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } + 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_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[22].descriptor; +} + +const SourceCodeInfo& SourceCodeInfo::default_instance() { + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[22]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS // SourceCodeInfo // repeated .google.protobuf.SourceCodeInfo.Location location = 1; @@ -15156,9 +14886,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 +14899,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -15210,17 +14944,15 @@ void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* GeneratedCodeInfo_Annotation::descriptor() { - protobuf_AssignDescriptorsOnce(); - return GeneratedCodeInfo_Annotation_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[23].descriptor; } const GeneratedCodeInfo_Annotation& GeneratedCodeInfo_Annotation::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +14963,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 +14982,32 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_source_file())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -15304,14 +15017,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(24u)) { set_has_begin(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -15319,14 +15031,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(32u)) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -15334,7 +15045,6 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -15368,7 +15078,7 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); output->WriteVarint32(_path_cached_byte_size_); } - for (int i = 0; i < this->path_size(); i++) { + for (int i = 0, n = this->path_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag( this->path(i), output); } @@ -15402,7 +15112,7 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes( ::google::protobuf::uint8* GeneratedCodeInfo_Annotation::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo.Annotation) // repeated int32 path = 1 [packed = true]; if (this->path_size() > 0) { @@ -15413,7 +15123,7 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes( target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( _path_cached_byte_size_, target); } - for (int i = 0; i < this->path_size(); i++) { + for (int i = 0, n = this->path_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: WriteInt32NoTagToArray(this->path(i), target); } @@ -15451,7 +15161,27 @@ 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 = ::google::protobuf::internal::WireFormatLite:: + Int32Size(this->path_); + 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 +15204,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 +15213,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 +15222,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 +15243,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 +15256,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; } @@ -15584,15 +15278,156 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::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) +} +#if LANG_CXX11 +void GeneratedCodeInfo_Annotation::set_source_file(::std::string&& value) { + set_has_source_file(); + source_file_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.GeneratedCodeInfo.Annotation.source_file) +} +#endif +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 +15435,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_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); + } 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) } @@ -15634,17 +15469,15 @@ void GeneratedCodeInfo::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* GeneratedCodeInfo::descriptor() { - protobuf_AssignDescriptorsOnce(); - return GeneratedCodeInfo_descriptor_; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[24].descriptor; } const GeneratedCodeInfo& GeneratedCodeInfo::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); 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 +15490,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 +15499,21 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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; } @@ -15728,7 +15557,7 @@ void GeneratedCodeInfo::SerializeWithCachedSizes( ::google::protobuf::uint8* GeneratedCodeInfo::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo) // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; for (unsigned int i = 0, n = this->annotation_size(); i < n; i++) { @@ -15749,6 +15578,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 +15594,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 +15603,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 +15612,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 +15634,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; } @@ -15836,153 +15653,11 @@ 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; + protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fdescriptor_2eproto::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 +15690,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..73b7a8dd 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -8,62 +8,121 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3001000 +#if GOOGLE_PROTOBUF_VERSION < 3002000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #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; +LIBPROTOBUF_EXPORT extern DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; class DescriptorProto_ExtensionRange; +class DescriptorProto_ExtensionRangeDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; class DescriptorProto_ReservedRange; +class DescriptorProto_ReservedRangeDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; class EnumDescriptorProto; +class EnumDescriptorProtoDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; class EnumOptions; +class EnumOptionsDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; class EnumValueDescriptorProto; +class EnumValueDescriptorProtoDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; class EnumValueOptions; +class EnumValueOptionsDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; class FieldDescriptorProto; +class FieldDescriptorProtoDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; class FieldOptions; +class FieldOptionsDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; class FileDescriptorProto; +class FileDescriptorProtoDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; class FileDescriptorSet; +class FileDescriptorSetDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; class FileOptions; +class FileOptionsDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern FileOptionsDefaultTypeInternal _FileOptions_default_instance_; class GeneratedCodeInfo; +class GeneratedCodeInfoDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; class GeneratedCodeInfo_Annotation; +class GeneratedCodeInfo_AnnotationDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; class MessageOptions; +class MessageOptionsDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; class MethodDescriptorProto; +class MethodDescriptorProtoDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; class MethodOptions; +class MethodOptionsDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; class OneofDescriptorProto; +class OneofDescriptorProtoDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; class OneofOptions; +class OneofOptionsDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; class ServiceDescriptorProto; +class ServiceDescriptorProtoDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; class ServiceOptions; +class ServiceOptionsDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; class SourceCodeInfo; +class SourceCodeInfoDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; class SourceCodeInfo_Location; +class SourceCodeInfo_LocationDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; class UninterpretedOption; +class UninterpretedOptionDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; class UninterpretedOption_NamePart; +class UninterpretedOption_NamePartDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; +} // namespace protobuf +} // namespace google + +namespace google { +namespace protobuf { + +namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto { +// Internal implementation detail -- do not call these. +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::uint32 offsets[]; + static void InitDefaultsImpl(); + static void Shutdown(); +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaults(); +} // namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto enum FieldDescriptorProto_Type { FieldDescriptorProto_Type_TYPE_DOUBLE = 1, @@ -180,6 +239,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 +284,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -272,15 +355,8 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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,78 +382,58 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; - bool has_name() const; - void clear_name(); - static const int kNameFieldNumber = 1; - const ::std::string& name() const; - void set_name(const ::std::string& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); - ::std::string* mutable_name(); - ::std::string* release_name(); - void set_allocated_name(::std::string* name); - - // optional string package = 2; - bool has_package() const; - void clear_package(); - static const int kPackageFieldNumber = 2; - const ::std::string& package() const; - void set_package(const ::std::string& value); - void set_package(const char* value); - void set_package(const char* value, size_t size); - ::std::string* mutable_package(); - ::std::string* release_package(); - void set_allocated_package(::std::string* package); - // repeated string dependency = 3; int dependency_size() const; void clear_dependency(); @@ -385,10 +441,16 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag const ::std::string& dependency(int index) const; ::std::string* mutable_dependency(int index); void set_dependency(int index, const ::std::string& value); + #if LANG_CXX11 + void set_dependency(int index, ::std::string&& value); + #endif void set_dependency(int index, const char* value); void set_dependency(int index, const char* value, size_t size); ::std::string* add_dependency(); void add_dependency(const ::std::string& value); + #if LANG_CXX11 + void add_dependency(::std::string&& value); + #endif void add_dependency(const char* value); void add_dependency(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& dependency() const; @@ -466,6 +528,51 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& extension() const; + // optional string name = 1; + bool has_name() const; + void clear_name(); + static const int kNameFieldNumber = 1; + const ::std::string& name() const; + void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); + + // optional string package = 2; + bool has_package() const; + void clear_package(); + static const int kPackageFieldNumber = 2; + const ::std::string& package() const; + void set_package(const ::std::string& value); + #if LANG_CXX11 + void set_package(::std::string&& value); + #endif + void set_package(const char* value); + void set_package(const char* value, size_t size); + ::std::string* mutable_package(); + ::std::string* release_package(); + void set_allocated_package(::std::string* package); + + // optional string syntax = 12; + bool has_syntax() const; + void clear_syntax(); + static const int kSyntaxFieldNumber = 12; + const ::std::string& syntax() const; + void set_syntax(const ::std::string& value); + #if LANG_CXX11 + void set_syntax(::std::string&& value); + #endif + void set_syntax(const char* value); + void set_syntax(const char* value, size_t size); + ::std::string* mutable_syntax(); + ::std::string* release_syntax(); + void set_allocated_syntax(::std::string* syntax); + // optional .google.protobuf.FileOptions options = 8; bool has_options() const; void clear_options(); @@ -484,30 +591,18 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag ::google::protobuf::SourceCodeInfo* release_source_code_info(); void set_allocated_source_code_info(::google::protobuf::SourceCodeInfo* source_code_info); - // optional string syntax = 12; - bool has_syntax() const; - void clear_syntax(); - static const int kSyntaxFieldNumber = 12; - const ::std::string& syntax() const; - void set_syntax(const ::std::string& value); - void set_syntax(const char* value); - void set_syntax(const char* value, size_t size); - ::std::string* mutable_syntax(); - ::std::string* release_syntax(); - void set_allocated_syntax(::std::string* syntax); - // @@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_; @@ -524,15 +619,8 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag ::google::protobuf::internal::ArenaStringPtr syntax_; ::google::protobuf::FileOptions* options_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +646,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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,25 +714,18 @@ 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_; mutable int _cached_size_; ::google::protobuf::int32 start_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +751,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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,25 +819,18 @@ 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_; mutable int _cached_size_; ::google::protobuf::int32 start_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +856,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -825,18 +911,6 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* // accessors ------------------------------------------------------- - // optional string name = 1; - bool has_name() const; - void clear_name(); - static const int kNameFieldNumber = 1; - const ::std::string& name() const; - void set_name(const ::std::string& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); - ::std::string* mutable_name(); - ::std::string* release_name(); - void set_allocated_name(::std::string* name); - // repeated .google.protobuf.FieldDescriptorProto field = 2; int field_size() const; void clear_field(); @@ -909,15 +983,6 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* const ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >& oneof_decl() const; - // optional .google.protobuf.MessageOptions options = 7; - bool has_options() const; - void clear_options(); - static const int kOptionsFieldNumber = 7; - const ::google::protobuf::MessageOptions& options() const; - ::google::protobuf::MessageOptions* mutable_options(); - ::google::protobuf::MessageOptions* release_options(); - void set_allocated_options(::google::protobuf::MessageOptions* options); - // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; int reserved_range_size() const; void clear_reserved_range(); @@ -937,21 +1002,51 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* const ::std::string& reserved_name(int index) const; ::std::string* mutable_reserved_name(int index); void set_reserved_name(int index, const ::std::string& value); + #if LANG_CXX11 + void set_reserved_name(int index, ::std::string&& value); + #endif void set_reserved_name(int index, const char* value); void set_reserved_name(int index, const char* value, size_t size); ::std::string* add_reserved_name(); void add_reserved_name(const ::std::string& value); + #if LANG_CXX11 + void add_reserved_name(::std::string&& value); + #endif void add_reserved_name(const char* value); void add_reserved_name(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& reserved_name() const; ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_reserved_name(); + // optional string name = 1; + bool has_name() const; + void clear_name(); + static const int kNameFieldNumber = 1; + const ::std::string& name() const; + void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); + + // optional .google.protobuf.MessageOptions options = 7; + bool has_options() const; + void clear_options(); + static const int kOptionsFieldNumber = 7; + const ::google::protobuf::MessageOptions& options() const; + ::google::protobuf::MessageOptions* mutable_options(); + ::google::protobuf::MessageOptions* release_options(); + void set_allocated_options(::google::protobuf::MessageOptions* options); + // @@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_; @@ -966,15 +1061,8 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* ::google::protobuf::RepeatedPtrField< ::std::string> reserved_name_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::MessageOptions* options_; - friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +1088,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -1140,39 +1232,24 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa static const int kNameFieldNumber = 1; const ::std::string& name() const; void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); - // optional int32 number = 3; - bool has_number() const; - void clear_number(); - static const int kNumberFieldNumber = 3; - ::google::protobuf::int32 number() const; - void set_number(::google::protobuf::int32 value); - - // optional .google.protobuf.FieldDescriptorProto.Label label = 4; - bool has_label() const; - void clear_label(); - static const int kLabelFieldNumber = 4; - ::google::protobuf::FieldDescriptorProto_Label label() const; - void set_label(::google::protobuf::FieldDescriptorProto_Label value); - - // optional .google.protobuf.FieldDescriptorProto.Type type = 5; - bool has_type() const; - void clear_type(); - static const int kTypeFieldNumber = 5; - ::google::protobuf::FieldDescriptorProto_Type type() const; - void set_type(::google::protobuf::FieldDescriptorProto_Type value); - // optional string type_name = 6; bool has_type_name() const; void clear_type_name(); static const int kTypeNameFieldNumber = 6; const ::std::string& type_name() const; void set_type_name(const ::std::string& value); + #if LANG_CXX11 + void set_type_name(::std::string&& value); + #endif void set_type_name(const char* value); void set_type_name(const char* value, size_t size); ::std::string* mutable_type_name(); @@ -1185,6 +1262,9 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa static const int kExtendeeFieldNumber = 2; const ::std::string& extendee() const; void set_extendee(const ::std::string& value); + #if LANG_CXX11 + void set_extendee(::std::string&& value); + #endif void set_extendee(const char* value); void set_extendee(const char* value, size_t size); ::std::string* mutable_extendee(); @@ -1197,25 +1277,24 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa static const int kDefaultValueFieldNumber = 7; const ::std::string& default_value() const; void set_default_value(const ::std::string& value); + #if LANG_CXX11 + void set_default_value(::std::string&& value); + #endif void set_default_value(const char* value); void set_default_value(const char* value, size_t size); ::std::string* mutable_default_value(); ::std::string* release_default_value(); void set_allocated_default_value(::std::string* default_value); - // optional int32 oneof_index = 9; - bool has_oneof_index() const; - void clear_oneof_index(); - static const int kOneofIndexFieldNumber = 9; - ::google::protobuf::int32 oneof_index() const; - void set_oneof_index(::google::protobuf::int32 value); - // optional string json_name = 10; bool has_json_name() const; void clear_json_name(); static const int kJsonNameFieldNumber = 10; const ::std::string& json_name() const; void set_json_name(const ::std::string& value); + #if LANG_CXX11 + void set_json_name(::std::string&& value); + #endif void set_json_name(const char* value); void set_json_name(const char* value, size_t size); ::std::string* mutable_json_name(); @@ -1231,28 +1310,56 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa ::google::protobuf::FieldOptions* release_options(); void set_allocated_options(::google::protobuf::FieldOptions* options); + // optional int32 number = 3; + bool has_number() const; + void clear_number(); + static const int kNumberFieldNumber = 3; + ::google::protobuf::int32 number() const; + void set_number(::google::protobuf::int32 value); + + // optional int32 oneof_index = 9; + bool has_oneof_index() const; + void clear_oneof_index(); + static const int kOneofIndexFieldNumber = 9; + ::google::protobuf::int32 oneof_index() const; + void set_oneof_index(::google::protobuf::int32 value); + + // optional .google.protobuf.FieldDescriptorProto.Label label = 4; + bool has_label() const; + void clear_label(); + static const int kLabelFieldNumber = 4; + ::google::protobuf::FieldDescriptorProto_Label label() const; + void set_label(::google::protobuf::FieldDescriptorProto_Label value); + + // optional .google.protobuf.FieldDescriptorProto.Type type = 5; + bool has_type() const; + void clear_type(); + static const int kTypeFieldNumber = 5; + ::google::protobuf::FieldDescriptorProto_Type type() const; + void set_type(::google::protobuf::FieldDescriptorProto_Type value); + // @@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_; @@ -1267,15 +1374,8 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa ::google::protobuf::int32 oneof_index_; int label_; int type_; - friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +1401,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -1355,6 +1459,9 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa static const int kNameFieldNumber = 1; const ::std::string& name() const; void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); @@ -1372,25 +1479,18 @@ 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_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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,66 +1516,58 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; - bool has_name() const; - void clear_name(); - static const int kNameFieldNumber = 1; - const ::std::string& name() const; - void set_name(const ::std::string& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); - ::std::string* mutable_name(); - ::std::string* release_name(); - void set_allocated_name(::std::string* name); - // repeated .google.protobuf.EnumValueDescriptorProto value = 2; int value_size() const; void clear_value(); @@ -1488,6 +1580,21 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >& value() const; + // optional string name = 1; + bool has_name() const; + void clear_name(); + static const int kNameFieldNumber = 1; + const ::std::string& name() const; + void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); + // optional .google.protobuf.EnumOptions options = 3; bool has_options() const; void clear_options(); @@ -1499,10 +1606,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_; @@ -1510,15 +1617,8 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto > value_; ::google::protobuf::internal::ArenaStringPtr name_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +1644,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -1598,19 +1702,15 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M static const int kNameFieldNumber = 1; const ::std::string& name() const; void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); - // optional int32 number = 2; - bool has_number() const; - void clear_number(); - static const int kNumberFieldNumber = 2; - ::google::protobuf::int32 number() const; - void set_number(::google::protobuf::int32 value); - // optional .google.protobuf.EnumValueOptions options = 3; bool has_options() const; void clear_options(); @@ -1620,14 +1720,21 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M ::google::protobuf::EnumValueOptions* release_options(); void set_allocated_options(::google::protobuf::EnumValueOptions* options); + // optional int32 number = 2; + bool has_number() const; + void clear_number(); + static const int kNumberFieldNumber = 2; + ::google::protobuf::int32 number() const; + void set_number(::google::protobuf::int32 value); + // @@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_; @@ -1635,15 +1742,8 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::EnumValueOptions* options_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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,66 +1769,58 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; - bool has_name() const; - void clear_name(); - static const int kNameFieldNumber = 1; - const ::std::string& name() const; - void set_name(const ::std::string& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); - ::std::string* mutable_name(); - ::std::string* release_name(); - void set_allocated_name(::std::string* name); - // repeated .google.protobuf.MethodDescriptorProto method = 2; int method_size() const; void clear_method(); @@ -1741,6 +1833,21 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes const ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >& method() const; + // optional string name = 1; + bool has_name() const; + void clear_name(); + static const int kNameFieldNumber = 1; + const ::std::string& name() const; + void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); + // optional .google.protobuf.ServiceOptions options = 3; bool has_options() const; void clear_options(); @@ -1752,10 +1859,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_; @@ -1763,15 +1870,8 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto > method_; ::google::protobuf::internal::ArenaStringPtr name_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +1897,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -1851,6 +1955,9 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess static const int kNameFieldNumber = 1; const ::std::string& name() const; void set_name(const ::std::string& value); + #if LANG_CXX11 + void set_name(::std::string&& value); + #endif void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); @@ -1863,6 +1970,9 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess static const int kInputTypeFieldNumber = 2; const ::std::string& input_type() const; void set_input_type(const ::std::string& value); + #if LANG_CXX11 + void set_input_type(::std::string&& value); + #endif void set_input_type(const char* value); void set_input_type(const char* value, size_t size); ::std::string* mutable_input_type(); @@ -1875,6 +1985,9 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess static const int kOutputTypeFieldNumber = 3; const ::std::string& output_type() const; void set_output_type(const ::std::string& value); + #if LANG_CXX11 + void set_output_type(::std::string&& value); + #endif void set_output_type(const char* value); void set_output_type(const char* value, size_t size); ::std::string* mutable_output_type(); @@ -1906,18 +2019,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_; @@ -1928,15 +2041,8 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess ::google::protobuf::MethodOptions* options_; bool client_streaming_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +2068,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -2038,12 +2148,27 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p // accessors ------------------------------------------------------- + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + int uninterpreted_option_size() const; + void clear_uninterpreted_option(); + static const int kUninterpretedOptionFieldNumber = 999; + const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; + ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); + ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* + mutable_uninterpreted_option(); + const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& + uninterpreted_option() const; + // optional string java_package = 1; bool has_java_package() const; void clear_java_package(); static const int kJavaPackageFieldNumber = 1; const ::std::string& java_package() const; void set_java_package(const ::std::string& value); + #if LANG_CXX11 + void set_java_package(::std::string&& value); + #endif void set_java_package(const char* value); void set_java_package(const char* value, size_t size); ::std::string* mutable_java_package(); @@ -2056,12 +2181,75 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p static const int kJavaOuterClassnameFieldNumber = 8; const ::std::string& java_outer_classname() const; void set_java_outer_classname(const ::std::string& value); + #if LANG_CXX11 + void set_java_outer_classname(::std::string&& value); + #endif void set_java_outer_classname(const char* value); void set_java_outer_classname(const char* value, size_t size); ::std::string* mutable_java_outer_classname(); ::std::string* release_java_outer_classname(); void set_allocated_java_outer_classname(::std::string* java_outer_classname); + // optional string go_package = 11; + bool has_go_package() const; + void clear_go_package(); + static const int kGoPackageFieldNumber = 11; + const ::std::string& go_package() const; + void set_go_package(const ::std::string& value); + #if LANG_CXX11 + void set_go_package(::std::string&& value); + #endif + void set_go_package(const char* value); + void set_go_package(const char* value, size_t size); + ::std::string* mutable_go_package(); + ::std::string* release_go_package(); + void set_allocated_go_package(::std::string* go_package); + + // optional string objc_class_prefix = 36; + bool has_objc_class_prefix() const; + void clear_objc_class_prefix(); + static const int kObjcClassPrefixFieldNumber = 36; + const ::std::string& objc_class_prefix() const; + void set_objc_class_prefix(const ::std::string& value); + #if LANG_CXX11 + void set_objc_class_prefix(::std::string&& value); + #endif + void set_objc_class_prefix(const char* value); + void set_objc_class_prefix(const char* value, size_t size); + ::std::string* mutable_objc_class_prefix(); + ::std::string* release_objc_class_prefix(); + void set_allocated_objc_class_prefix(::std::string* objc_class_prefix); + + // optional string csharp_namespace = 37; + bool has_csharp_namespace() const; + void clear_csharp_namespace(); + static const int kCsharpNamespaceFieldNumber = 37; + const ::std::string& csharp_namespace() const; + void set_csharp_namespace(const ::std::string& value); + #if LANG_CXX11 + void set_csharp_namespace(::std::string&& value); + #endif + void set_csharp_namespace(const char* value); + void set_csharp_namespace(const char* value, size_t size); + ::std::string* mutable_csharp_namespace(); + ::std::string* release_csharp_namespace(); + void set_allocated_csharp_namespace(::std::string* csharp_namespace); + + // optional string swift_prefix = 39; + bool has_swift_prefix() const; + void clear_swift_prefix(); + static const int kSwiftPrefixFieldNumber = 39; + const ::std::string& swift_prefix() const; + void set_swift_prefix(const ::std::string& value); + #if LANG_CXX11 + void set_swift_prefix(::std::string&& value); + #endif + void set_swift_prefix(const char* value); + void set_swift_prefix(const char* value, size_t size); + ::std::string* mutable_swift_prefix(); + ::std::string* release_swift_prefix(); + void set_allocated_swift_prefix(::std::string* swift_prefix); + // optional bool java_multiple_files = 10 [default = false]; bool has_java_multiple_files() const; void clear_java_multiple_files(); @@ -2083,25 +2271,6 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p bool java_string_check_utf8() const; void set_java_string_check_utf8(bool value); - // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - bool has_optimize_for() const; - void clear_optimize_for(); - static const int kOptimizeForFieldNumber = 9; - ::google::protobuf::FileOptions_OptimizeMode optimize_for() const; - void set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value); - - // optional string go_package = 11; - bool has_go_package() const; - void clear_go_package(); - static const int kGoPackageFieldNumber = 11; - const ::std::string& go_package() const; - void set_go_package(const ::std::string& value); - void set_go_package(const char* value); - void set_go_package(const char* value, size_t size); - ::std::string* mutable_go_package(); - ::std::string* release_go_package(); - void set_allocated_go_package(::std::string* go_package); - // optional bool cc_generic_services = 16 [default = false]; bool has_cc_generic_services() const; void clear_cc_generic_services(); @@ -2137,73 +2306,46 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p bool cc_enable_arenas() const; void set_cc_enable_arenas(bool value); - // optional string objc_class_prefix = 36; - bool has_objc_class_prefix() const; - void clear_objc_class_prefix(); - static const int kObjcClassPrefixFieldNumber = 36; - const ::std::string& objc_class_prefix() const; - void set_objc_class_prefix(const ::std::string& value); - void set_objc_class_prefix(const char* value); - void set_objc_class_prefix(const char* value, size_t size); - ::std::string* mutable_objc_class_prefix(); - ::std::string* release_objc_class_prefix(); - void set_allocated_objc_class_prefix(::std::string* objc_class_prefix); - - // optional string csharp_namespace = 37; - bool has_csharp_namespace() const; - void clear_csharp_namespace(); - static const int kCsharpNamespaceFieldNumber = 37; - const ::std::string& csharp_namespace() const; - void set_csharp_namespace(const ::std::string& value); - void set_csharp_namespace(const char* value); - void set_csharp_namespace(const char* value, size_t size); - ::std::string* mutable_csharp_namespace(); - ::std::string* release_csharp_namespace(); - void set_allocated_csharp_namespace(::std::string* csharp_namespace); - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - int uninterpreted_option_size() const; - void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; - const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; - ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* - mutable_uninterpreted_option(); - const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& - uninterpreted_option() const; + // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; + bool has_optimize_for() const; + void clear_optimize_for(); + static const int kOptimizeForFieldNumber = 9; + ::google::protobuf::FileOptions_OptimizeMode optimize_for() const; + void set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value); 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(); + void set_has_swift_prefix(); + void clear_has_swift_prefix(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2216,6 +2358,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::google::protobuf::internal::ArenaStringPtr go_package_; ::google::protobuf::internal::ArenaStringPtr objc_class_prefix_; ::google::protobuf::internal::ArenaStringPtr csharp_namespace_; + ::google::protobuf::internal::ArenaStringPtr swift_prefix_; bool java_multiple_files_; bool java_generate_equals_and_hash_; bool java_string_check_utf8_; @@ -2225,15 +2368,8 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p bool deprecated_; bool cc_enable_arenas_; int optimize_for_; - friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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,54 +2395,70 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- // accessors ------------------------------------------------------- + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + int uninterpreted_option_size() const; + void clear_uninterpreted_option(); + static const int kUninterpretedOptionFieldNumber = 999; + const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; + ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); + ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* + mutable_uninterpreted_option(); + const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& + uninterpreted_option() const; + // optional bool message_set_wire_format = 1 [default = false]; bool has_message_set_wire_format() const; void clear_message_set_wire_format(); @@ -2335,29 +2487,17 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* bool map_entry() const; void set_map_entry(bool value); - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - int uninterpreted_option_size() const; - void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; - const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; - ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* - mutable_uninterpreted_option(); - const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& - uninterpreted_option() const; - 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_; @@ -2369,15 +2509,8 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* bool no_standard_descriptor_accessor_; bool deprecated_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +2536,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -2507,6 +2644,18 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ // accessors ------------------------------------------------------- + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + int uninterpreted_option_size() const; + void clear_uninterpreted_option(); + static const int kUninterpretedOptionFieldNumber = 999; + const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; + ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); + ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* + mutable_uninterpreted_option(); + const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& + uninterpreted_option() const; + // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; bool has_ctype() const; void clear_ctype(); @@ -2514,13 +2663,6 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ ::google::protobuf::FieldOptions_CType ctype() const; void set_ctype(::google::protobuf::FieldOptions_CType value); - // optional bool packed = 2; - bool has_packed() const; - void clear_packed(); - static const int kPackedFieldNumber = 2; - bool packed() const; - void set_packed(bool value); - // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; bool has_jstype() const; void clear_jstype(); @@ -2528,6 +2670,13 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ ::google::protobuf::FieldOptions_JSType jstype() const; void set_jstype(::google::protobuf::FieldOptions_JSType value); + // optional bool packed = 2; + bool has_packed() const; + void clear_packed(); + static const int kPackedFieldNumber = 2; + bool packed() const; + void set_packed(bool value); + // optional bool lazy = 5 [default = false]; bool has_lazy() const; void clear_lazy(); @@ -2549,33 +2698,21 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ bool weak() const; void set_weak(bool value); - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - int uninterpreted_option_size() const; - void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; - const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; - ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* - mutable_uninterpreted_option(); - const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& - uninterpreted_option() const; - 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_; @@ -2589,15 +2726,8 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ bool lazy_; bool deprecated_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +2753,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -2693,15 +2827,8 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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,54 +2854,70 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- // accessors ------------------------------------------------------- + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + int uninterpreted_option_size() const; + void clear_uninterpreted_option(); + static const int kUninterpretedOptionFieldNumber = 999; + const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; + ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); + ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* + mutable_uninterpreted_option(); + const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& + uninterpreted_option() const; + // optional bool allow_alias = 2; bool has_allow_alias() const; void clear_allow_alias(); @@ -2789,25 +2932,13 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p bool deprecated() const; void set_deprecated(bool value); - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - int uninterpreted_option_size() const; - void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; - const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; - ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* - mutable_uninterpreted_option(); - const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& - uninterpreted_option() const; - 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_; @@ -2817,15 +2948,8 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool allow_alias_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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,61 +2975,58 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional bool deprecated = 1 [default = false]; - bool has_deprecated() const; - void clear_deprecated(); - static const int kDeprecatedFieldNumber = 1; - bool deprecated() const; - void set_deprecated(bool value); - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); @@ -2918,11 +3039,18 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& uninterpreted_option() const; + // optional bool deprecated = 1 [default = false]; + bool has_deprecated() const; + void clear_deprecated(); + static const int kDeprecatedFieldNumber = 1; + bool deprecated() const; + void set_deprecated(bool value); + 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_; @@ -2931,15 +3059,8 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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,61 +3086,58 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional bool deprecated = 33 [default = false]; - bool has_deprecated() const; - void clear_deprecated(); - static const int kDeprecatedFieldNumber = 33; - bool deprecated() const; - void set_deprecated(bool value); - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); @@ -3032,11 +3150,18 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& uninterpreted_option() const; + // optional bool deprecated = 33 [default = false]; + bool has_deprecated() const; + void clear_deprecated(); + static const int kDeprecatedFieldNumber = 33; + bool deprecated() const; + void set_deprecated(bool value); + 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_; @@ -3045,15 +3170,8 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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,60 +3197,85 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- - // accessors ------------------------------------------------------- + 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); + } - // optional bool deprecated = 33 [default = false]; - bool has_deprecated() const; - void clear_deprecated(); - static const int kDeprecatedFieldNumber = 33; - bool deprecated() const; - void set_deprecated(bool value); + // accessors ------------------------------------------------------- // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; @@ -3146,11 +3289,27 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& uninterpreted_option() const; + // optional bool deprecated = 33 [default = false]; + bool has_deprecated() const; + void clear_deprecated(); + static const int kDeprecatedFieldNumber = 33; + 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); + 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 +3318,9 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + int idempotency_level_; + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +3346,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -3247,6 +3404,9 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu static const int kNamePartFieldNumber = 1; const ::std::string& name_part() const; void set_name_part(const ::std::string& value); + #if LANG_CXX11 + void set_name_part(::std::string&& value); + #endif void set_name_part(const char* value); void set_name_part(const char* value, size_t size); ::std::string* mutable_name_part(); @@ -3262,10 +3422,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; @@ -3275,15 +3435,8 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_part_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +3462,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -3377,39 +3534,24 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag static const int kIdentifierValueFieldNumber = 3; const ::std::string& identifier_value() const; void set_identifier_value(const ::std::string& value); + #if LANG_CXX11 + void set_identifier_value(::std::string&& value); + #endif void set_identifier_value(const char* value); void set_identifier_value(const char* value, size_t size); ::std::string* mutable_identifier_value(); ::std::string* release_identifier_value(); void set_allocated_identifier_value(::std::string* identifier_value); - // optional uint64 positive_int_value = 4; - bool has_positive_int_value() const; - void clear_positive_int_value(); - static const int kPositiveIntValueFieldNumber = 4; - ::google::protobuf::uint64 positive_int_value() const; - void set_positive_int_value(::google::protobuf::uint64 value); - - // optional int64 negative_int_value = 5; - bool has_negative_int_value() const; - void clear_negative_int_value(); - static const int kNegativeIntValueFieldNumber = 5; - ::google::protobuf::int64 negative_int_value() const; - void set_negative_int_value(::google::protobuf::int64 value); - - // optional double double_value = 6; - bool has_double_value() const; - void clear_double_value(); - static const int kDoubleValueFieldNumber = 6; - double double_value() const; - void set_double_value(double value); - // optional bytes string_value = 7; bool has_string_value() const; void clear_string_value(); static const int kStringValueFieldNumber = 7; const ::std::string& string_value() const; void set_string_value(const ::std::string& value); + #if LANG_CXX11 + void set_string_value(::std::string&& value); + #endif void set_string_value(const char* value); void set_string_value(const void* value, size_t size); ::std::string* mutable_string_value(); @@ -3422,26 +3564,50 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag static const int kAggregateValueFieldNumber = 8; const ::std::string& aggregate_value() const; void set_aggregate_value(const ::std::string& value); + #if LANG_CXX11 + void set_aggregate_value(::std::string&& value); + #endif void set_aggregate_value(const char* value); void set_aggregate_value(const char* value, size_t size); ::std::string* mutable_aggregate_value(); ::std::string* release_aggregate_value(); void set_allocated_aggregate_value(::std::string* aggregate_value); + // optional uint64 positive_int_value = 4; + bool has_positive_int_value() const; + void clear_positive_int_value(); + static const int kPositiveIntValueFieldNumber = 4; + ::google::protobuf::uint64 positive_int_value() const; + void set_positive_int_value(::google::protobuf::uint64 value); + + // optional int64 negative_int_value = 5; + bool has_negative_int_value() const; + void clear_negative_int_value(); + static const int kNegativeIntValueFieldNumber = 5; + ::google::protobuf::int64 negative_int_value() const; + void set_negative_int_value(::google::protobuf::int64 value); + + // optional double double_value = 6; + bool has_double_value() const; + void clear_double_value(); + static const int kDoubleValueFieldNumber = 6; + double double_value() const; + void set_double_value(double value); + // @@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_; @@ -3453,15 +3619,8 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag ::google::protobuf::uint64 positive_int_value_; ::google::protobuf::int64 negative_int_value_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +3646,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -3559,12 +3722,37 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* mutable_span(); + // repeated string leading_detached_comments = 6; + int leading_detached_comments_size() const; + void clear_leading_detached_comments(); + static const int kLeadingDetachedCommentsFieldNumber = 6; + const ::std::string& leading_detached_comments(int index) const; + ::std::string* mutable_leading_detached_comments(int index); + void set_leading_detached_comments(int index, const ::std::string& value); + #if LANG_CXX11 + void set_leading_detached_comments(int index, ::std::string&& value); + #endif + void set_leading_detached_comments(int index, const char* value); + void set_leading_detached_comments(int index, const char* value, size_t size); + ::std::string* add_leading_detached_comments(); + void add_leading_detached_comments(const ::std::string& value); + #if LANG_CXX11 + void add_leading_detached_comments(::std::string&& value); + #endif + void add_leading_detached_comments(const char* value); + void add_leading_detached_comments(const char* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& leading_detached_comments() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_leading_detached_comments(); + // optional string leading_comments = 3; bool has_leading_comments() const; void clear_leading_comments(); static const int kLeadingCommentsFieldNumber = 3; const ::std::string& leading_comments() const; void set_leading_comments(const ::std::string& value); + #if LANG_CXX11 + void set_leading_comments(::std::string&& value); + #endif void set_leading_comments(const char* value); void set_leading_comments(const char* value, size_t size); ::std::string* mutable_leading_comments(); @@ -3577,34 +3765,21 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me static const int kTrailingCommentsFieldNumber = 4; const ::std::string& trailing_comments() const; void set_trailing_comments(const ::std::string& value); + #if LANG_CXX11 + void set_trailing_comments(::std::string&& value); + #endif void set_trailing_comments(const char* value); void set_trailing_comments(const char* value, size_t size); ::std::string* mutable_trailing_comments(); ::std::string* release_trailing_comments(); void set_allocated_trailing_comments(::std::string* trailing_comments); - // repeated string leading_detached_comments = 6; - int leading_detached_comments_size() const; - void clear_leading_detached_comments(); - static const int kLeadingDetachedCommentsFieldNumber = 6; - const ::std::string& leading_detached_comments(int index) const; - ::std::string* mutable_leading_detached_comments(int index); - void set_leading_detached_comments(int index, const ::std::string& value); - void set_leading_detached_comments(int index, const char* value); - void set_leading_detached_comments(int index, const char* value, size_t size); - ::std::string* add_leading_detached_comments(); - void add_leading_detached_comments(const ::std::string& value); - void add_leading_detached_comments(const char* value); - void add_leading_detached_comments(const char* value, size_t size); - const ::google::protobuf::RepeatedPtrField< ::std::string>& leading_detached_comments() const; - ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_leading_detached_comments(); - // @@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_; @@ -3616,15 +3791,8 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me ::google::protobuf::RepeatedPtrField< ::std::string> leading_detached_comments_; ::google::protobuf::internal::ArenaStringPtr leading_comments_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +3818,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -3719,15 +3891,8 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +3918,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -3819,6 +3988,9 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu static const int kSourceFileFieldNumber = 2; const ::std::string& source_file() const; void set_source_file(const ::std::string& value); + #if LANG_CXX11 + void set_source_file(::std::string&& value); + #endif void set_source_file(const char* value); void set_source_file(const char* value, size_t size); ::std::string* mutable_source_file(); @@ -3841,12 +4013,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_; @@ -3856,15 +4028,8 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu ::google::protobuf::internal::ArenaStringPtr source_file_; ::google::protobuf::int32 begin_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -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 +4055,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -3959,15 +4128,8 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::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 void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; -extern ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> GeneratedCodeInfo_default_instance_; - // =================================================================== @@ -4006,9 +4168,6 @@ FileDescriptorSet::file() const { return file_; } -inline const FileDescriptorSet* FileDescriptorSet::internal_default_instance() { - return &FileDescriptorSet_default_instance_.get(); -} // ------------------------------------------------------------------- // FileDescriptorProto @@ -4029,13 +4188,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name) } +#if LANG_CXX11 +inline void FileDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.name) +} +#endif inline void FileDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -4083,13 +4250,21 @@ 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(); package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package) } +#if LANG_CXX11 +inline void FileDescriptorProto::set_package(::std::string&& value) { + set_has_package(); + package_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.package) +} +#endif inline void FileDescriptorProto::set_package(const char* value) { set_has_package(); package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -4140,6 +4315,12 @@ inline void FileDescriptorProto::set_dependency(int index, const ::std::string& // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) dependency_.Mutable(index)->assign(value); } +#if LANG_CXX11 +inline void FileDescriptorProto::set_dependency(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) + dependency_.Mutable(index)->assign(std::move(value)); +} +#endif inline void FileDescriptorProto::set_dependency(int index, const char* value) { dependency_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency) @@ -4157,6 +4338,12 @@ inline void FileDescriptorProto::add_dependency(const ::std::string& value) { dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) } +#if LANG_CXX11 +inline void FileDescriptorProto::add_dependency(::std::string&& value) { + dependency_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) +} +#endif inline void FileDescriptorProto::add_dependency(const char* value) { dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency) @@ -4358,13 +4545,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 +4590,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 +4635,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,13 +4649,21 @@ 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(); syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax) } +#if LANG_CXX11 +inline void FileDescriptorProto::set_syntax(::std::string&& value) { + set_has_syntax(); + syntax_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.syntax) +} +#endif inline void FileDescriptorProto::set_syntax(const char* value) { set_has_syntax(); syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -4500,9 +4695,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 +4747,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 +4799,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,13 +4819,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name) } +#if LANG_CXX11 +inline void DescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.DescriptorProto.name) +} +#endif inline void DescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -4853,13 +5047,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(); @@ -4945,6 +5139,12 @@ inline void DescriptorProto::set_reserved_name(int index, const ::std::string& v // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) reserved_name_.Mutable(index)->assign(value); } +#if LANG_CXX11 +inline void DescriptorProto::set_reserved_name(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) + reserved_name_.Mutable(index)->assign(std::move(value)); +} +#endif inline void DescriptorProto::set_reserved_name(int index, const char* value) { reserved_name_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name) @@ -4962,6 +5162,12 @@ inline void DescriptorProto::add_reserved_name(const ::std::string& value) { reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) } +#if LANG_CXX11 +inline void DescriptorProto::add_reserved_name(::std::string&& value) { + reserved_name_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) +} +#endif inline void DescriptorProto::add_reserved_name(const char* value) { reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name) @@ -4981,9 +5187,6 @@ DescriptorProto::mutable_reserved_name() { return &reserved_name_; } -inline const DescriptorProto* DescriptorProto::internal_default_instance() { - return &DescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // FieldDescriptorProto @@ -5004,13 +5207,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name) } +#if LANG_CXX11 +inline void FieldDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.name) +} +#endif inline void FieldDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5044,13 +5255,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 +5279,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 +5304,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 +5329,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,13 +5343,21 @@ 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(); type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name) } +#if LANG_CXX11 +inline void FieldDescriptorProto::set_type_name(::std::string&& value) { + set_has_type_name(); + type_name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.type_name) +} +#endif inline void FieldDescriptorProto::set_type_name(const char* value) { set_has_type_name(); type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5172,13 +5391,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,13 +5405,21 @@ 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(); extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee) } +#if LANG_CXX11 +inline void FieldDescriptorProto::set_extendee(::std::string&& value) { + set_has_extendee(); + extendee_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.extendee) +} +#endif inline void FieldDescriptorProto::set_extendee(const char* value) { set_has_extendee(); extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5226,13 +5453,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,13 +5467,21 @@ 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(); default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value) } +#if LANG_CXX11 +inline void FieldDescriptorProto::set_default_value(::std::string&& value) { + set_has_default_value(); + default_value_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.default_value) +} +#endif inline void FieldDescriptorProto::set_default_value(const char* value) { set_has_default_value(); default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5304,13 +5539,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,13 +5553,21 @@ 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(); json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name) } +#if LANG_CXX11 +inline void FieldDescriptorProto::set_json_name(::std::string&& value) { + set_has_json_name(); + json_name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.json_name) +} +#endif inline void FieldDescriptorProto::set_json_name(const char* value) { set_has_json_name(); json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5358,13 +5601,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 +5644,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,13 +5664,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name) } +#if LANG_CXX11 +inline void OneofDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.OneofDescriptorProto.name) +} +#endif inline void OneofDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5507,9 +5755,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,13 +5775,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name) } +#if LANG_CXX11 +inline void EnumDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumDescriptorProto.name) +} +#endif inline void EnumDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5600,13 +5853,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 +5896,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,13 +5916,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name) } +#if LANG_CXX11 +inline void EnumValueDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumValueDescriptorProto.name) +} +#endif inline void EnumValueDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5706,13 +5964,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 +5988,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 +6031,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,13 +6051,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name) } +#if LANG_CXX11 +inline void ServiceDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.ServiceDescriptorProto.name) +} +#endif inline void ServiceDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5866,13 +6129,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 +6172,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,13 +6192,21 @@ 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(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name) } +#if LANG_CXX11 +inline void MethodDescriptorProto::set_name(::std::string&& value) { + set_has_name(); + name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.name) +} +#endif inline void MethodDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -5986,13 +6254,21 @@ 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(); input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type) } +#if LANG_CXX11 +inline void MethodDescriptorProto::set_input_type(::std::string&& value) { + set_has_input_type(); + input_type_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.input_type) +} +#endif inline void MethodDescriptorProto::set_input_type(const char* value) { set_has_input_type(); input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -6040,13 +6316,21 @@ 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(); output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type) } +#if LANG_CXX11 +inline void MethodDescriptorProto::set_output_type(::std::string&& value) { + set_has_output_type(); + output_type_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.output_type) +} +#endif inline void MethodDescriptorProto::set_output_type(const char* value) { set_has_output_type(); output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -6171,9 +6455,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,13 +6475,21 @@ 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(); java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package) } +#if LANG_CXX11 +inline void FileOptions::set_java_package(::std::string&& value) { + set_has_java_package(); + java_package_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_package) +} +#endif inline void FileOptions::set_java_package(const char* value) { set_has_java_package(); java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -6248,13 +6537,21 @@ 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(); java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname) } +#if LANG_CXX11 +inline void FileOptions::set_java_outer_classname(::std::string&& value) { + set_has_java_outer_classname(); + java_outer_classname_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_outer_classname) +} +#endif inline void FileOptions::set_java_outer_classname(const char* value) { set_has_java_outer_classname(); java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -6288,13 +6585,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] & 0x00000040u) != 0; } inline void FileOptions::set_has_java_multiple_files() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000040u; } inline void FileOptions::clear_has_java_multiple_files() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000040u; } inline void FileOptions::clear_java_multiple_files() { java_multiple_files_ = false; @@ -6312,13 +6609,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] & 0x00000080u) != 0; } inline void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000080u; } inline void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000080u; } inline void FileOptions::clear_java_generate_equals_and_hash() { java_generate_equals_and_hash_ = false; @@ -6336,13 +6633,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] & 0x00000100u) != 0; } inline void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000100u; } inline void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000100u; } inline void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; @@ -6360,13 +6657,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] & 0x00004000u) != 0; } inline void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00004000u; } inline void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00004000u; } inline void FileOptions::clear_optimize_for() { optimize_for_ = 1; @@ -6385,13 +6682,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,13 +6696,21 @@ 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(); go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package) } +#if LANG_CXX11 +inline void FileOptions::set_go_package(::std::string&& value) { + set_has_go_package(); + go_package_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.go_package) +} +#endif inline void FileOptions::set_go_package(const char* value) { set_has_go_package(); go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -6439,13 +6744,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] & 0x00000200u) != 0; } inline void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000200u; } inline void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000200u; } inline void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; @@ -6463,13 +6768,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] & 0x00000400u) != 0; } inline void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000400u; } inline void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000400u; } inline void FileOptions::clear_java_generic_services() { java_generic_services_ = false; @@ -6487,13 +6792,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] & 0x00000800u) != 0; } inline void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000800u; } inline void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000800u; } inline void FileOptions::clear_py_generic_services() { py_generic_services_ = false; @@ -6511,13 +6816,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] & 0x00001000u) != 0; } inline void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00001000u; } inline void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00001000u; } inline void FileOptions::clear_deprecated() { deprecated_ = false; @@ -6535,13 +6840,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] & 0x00002000u) != 0; } inline void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00002000u; } inline void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00002000u; } inline void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; @@ -6559,13 +6864,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,13 +6878,21 @@ 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(); objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix) } +#if LANG_CXX11 +inline void FileOptions::set_objc_class_prefix(::std::string&& value) { + set_has_objc_class_prefix(); + objc_class_prefix_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.objc_class_prefix) +} +#endif inline void FileOptions::set_objc_class_prefix(const char* value) { set_has_objc_class_prefix(); objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -6613,13 +6926,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,13 +6940,21 @@ 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(); csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace) } +#if LANG_CXX11 +inline void FileOptions::set_csharp_namespace(::std::string&& value) { + set_has_csharp_namespace(); + csharp_namespace_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.csharp_namespace) +} +#endif inline void FileOptions::set_csharp_namespace(const char* value) { set_has_csharp_namespace(); csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -6665,6 +6986,68 @@ inline void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_na // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } +// optional string swift_prefix = 39; +inline bool FileOptions::has_swift_prefix() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +inline void FileOptions::set_has_swift_prefix() { + _has_bits_[0] |= 0x00000020u; +} +inline void FileOptions::clear_has_swift_prefix() { + _has_bits_[0] &= ~0x00000020u; +} +inline void FileOptions::clear_swift_prefix() { + swift_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_swift_prefix(); +} +inline const ::std::string& FileOptions::swift_prefix() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.swift_prefix) + return swift_prefix_.GetNoArena(); +} +inline void FileOptions::set_swift_prefix(const ::std::string& value) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix) +} +#if LANG_CXX11 +inline void FileOptions::set_swift_prefix(::std::string&& value) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.swift_prefix) +} +#endif +inline void FileOptions::set_swift_prefix(const char* value) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.swift_prefix) +} +inline void FileOptions::set_swift_prefix(const char* value, size_t size) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.swift_prefix) +} +inline ::std::string* FileOptions::mutable_swift_prefix() { + set_has_swift_prefix(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.swift_prefix) + return swift_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* FileOptions::release_swift_prefix() { + // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix) + clear_has_swift_prefix(); + return swift_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void FileOptions::set_allocated_swift_prefix(::std::string* swift_prefix) { + if (swift_prefix != NULL) { + set_has_swift_prefix(); + } else { + clear_has_swift_prefix(); + } + swift_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), swift_prefix); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int FileOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); @@ -6695,9 +7078,6 @@ FileOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const FileOptions* FileOptions::internal_default_instance() { - return &FileOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // MessageOptions @@ -6828,9 +7208,6 @@ MessageOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const MessageOptions* MessageOptions::internal_default_instance() { - return &MessageOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // FieldOptions @@ -6862,13 +7239,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 +7263,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 +7388,6 @@ FieldOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const FieldOptions* FieldOptions::internal_default_instance() { - return &FieldOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // OneofOptions @@ -7048,9 +7422,6 @@ OneofOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const OneofOptions* OneofOptions::internal_default_instance() { - return &OneofOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // EnumOptions @@ -7133,9 +7504,6 @@ EnumOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const EnumOptions* EnumOptions::internal_default_instance() { - return &EnumOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // EnumValueOptions @@ -7194,9 +7562,6 @@ EnumValueOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const EnumValueOptions* EnumValueOptions::internal_default_instance() { - return &EnumValueOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // ServiceOptions @@ -7255,9 +7620,6 @@ ServiceOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const ServiceOptions* ServiceOptions::internal_default_instance() { - return &ServiceOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // MethodOptions @@ -7286,6 +7648,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 +7703,6 @@ MethodOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const MethodOptions* MethodOptions::internal_default_instance() { - return &MethodOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // UninterpretedOption_NamePart @@ -7339,13 +7723,21 @@ 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(); name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part) } +#if LANG_CXX11 +inline void UninterpretedOption_NamePart::set_name_part(::std::string&& value) { + set_has_name_part(); + name_part_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.NamePart.name_part) +} +#endif inline void UninterpretedOption_NamePart::set_name_part(const char* value) { set_has_name_part(); name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -7401,9 +7793,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 +7829,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,13 +7843,21 @@ 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(); identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value) } +#if LANG_CXX11 +inline void UninterpretedOption::set_identifier_value(::std::string&& value) { + set_has_identifier_value(); + identifier_value_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.identifier_value) +} +#endif inline void UninterpretedOption::set_identifier_value(const char* value) { set_has_identifier_value(); identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -7494,13 +7891,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 +7915,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 +7939,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 +7963,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,13 +7977,21 @@ 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(); string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value) } +#if LANG_CXX11 +inline void UninterpretedOption::set_string_value(::std::string&& value) { + set_has_string_value(); + string_value_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.string_value) +} +#endif inline void UninterpretedOption::set_string_value(const char* value) { set_has_string_value(); string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -7620,13 +8025,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,13 +8039,21 @@ 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(); aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value) } +#if LANG_CXX11 +inline void UninterpretedOption::set_aggregate_value(::std::string&& value) { + set_has_aggregate_value(); + aggregate_value_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.aggregate_value) +} +#endif inline void UninterpretedOption::set_aggregate_value(const char* value) { set_has_aggregate_value(); aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -7672,9 +8085,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 +8151,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,13 +8165,21 @@ 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(); leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments) } +#if LANG_CXX11 +inline void SourceCodeInfo_Location::set_leading_comments(::std::string&& value) { + set_has_leading_comments(); + leading_comments_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.leading_comments) +} +#endif inline void SourceCodeInfo_Location::set_leading_comments(const char* value) { set_has_leading_comments(); leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -7795,13 +8213,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,13 +8227,21 @@ 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(); trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments) } +#if LANG_CXX11 +inline void SourceCodeInfo_Location::set_trailing_comments(::std::string&& value) { + set_has_trailing_comments(); + trailing_comments_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.trailing_comments) +} +#endif inline void SourceCodeInfo_Location::set_trailing_comments(const char* value) { set_has_trailing_comments(); trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -7866,6 +8292,12 @@ inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, co // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) leading_detached_comments_.Mutable(index)->assign(value); } +#if LANG_CXX11 +inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) + leading_detached_comments_.Mutable(index)->assign(std::move(value)); +} +#endif inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) { leading_detached_comments_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) @@ -7883,6 +8315,12 @@ inline void SourceCodeInfo_Location::add_leading_detached_comments(const ::std:: leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } +#if LANG_CXX11 +inline void SourceCodeInfo_Location::add_leading_detached_comments(::std::string&& value) { + leading_detached_comments_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) +} +#endif inline void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) { leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) @@ -7902,9 +8340,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 +8374,6 @@ SourceCodeInfo::location() const { return location_; } -inline const SourceCodeInfo* SourceCodeInfo::internal_default_instance() { - return &SourceCodeInfo_default_instance_.get(); -} // ------------------------------------------------------------------- // GeneratedCodeInfo_Annotation @@ -7978,13 +8410,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,13 +8424,21 @@ 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(); source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } +#if LANG_CXX11 +inline void GeneratedCodeInfo_Annotation::set_source_file(::std::string&& value) { + set_has_source_file(); + source_file_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.GeneratedCodeInfo.Annotation.source_file) +} +#endif inline void GeneratedCodeInfo_Annotation::set_source_file(const char* value) { set_has_source_file(); source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -8032,13 +8472,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 +8496,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 +8518,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 +8552,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 +8604,7 @@ inline const GeneratedCodeInfo* GeneratedCodeInfo::internal_default_instance() { // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google @@ -8202,6 +8637,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..e5f83e62 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -40,7 +40,7 @@ syntax = "proto2"; package google.protobuf; -option go_package = "descriptor"; +option go_package = "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor"; option java_package = "com.google.protobuf"; option java_outer_classname = "DescriptorProtos"; option csharp_namespace = "Google.Protobuf.Reflection"; @@ -139,7 +139,11 @@ message FieldDescriptorProto { TYPE_FIXED32 = 7; TYPE_BOOL = 8; TYPE_STRING = 9; - TYPE_GROUP = 10; // Tag-delimited aggregate. + // Tag-delimited aggregate. + // Group type is deprecated and not supported in proto3. However, Proto3 + // implementations should still be able to parse the group wire format and + // treat group fields as unknown fields. + TYPE_GROUP = 10; TYPE_MESSAGE = 11; // Length-delimited aggregate. // New in version 2. @@ -157,7 +161,6 @@ message FieldDescriptorProto { LABEL_OPTIONAL = 1; LABEL_REQUIRED = 2; LABEL_REPEATED = 3; - // TODO(sanjay): Should we add LABEL_MAP? }; optional string name = 1; @@ -367,6 +370,12 @@ message FileOptions { // Namespace for generated classes; defaults to the package. optional string csharp_namespace = 37; + // By default Swift generators will take the proto package and CamelCase it + // replacing '.' with underscore and use that to prefix the types/symbols + // defined. When this options is provided, they will use this value instead + // to prefix the types/symbols defined. + optional string swift_prefix = 39; + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; @@ -431,13 +440,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 +561,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 +616,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..d9b4fb1f 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -19,110 +19,103 @@ namespace google { namespace protobuf { +class DurationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Duration> { +} _Duration_default_instance_; + +namespace protobuf_google_2fprotobuf_2fduration_2eproto { + namespace { -const ::google::protobuf::Descriptor* Duration_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Duration_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace +const ::google::protobuf::uint32 TableStruct::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_), +}; -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] = { - 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_)); -} +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Duration)}, +}; + +static ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_Duration_default_instance_), +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/duration.proto", schemas, file_default_instances, TableStruct::offsets, 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_; +void TableStruct::Shutdown() { + _Duration_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } -void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl() { +void TableStruct::InitDefaultsImpl() { 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); +void InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); } -void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); +void AddDescriptorsImpl() { + InitDefaults(); + 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); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_once_); -void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_once_, - &protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl); +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto(); +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); } -} static_descriptor_initializer_google_2fprotobuf_2fduration_2eproto_; +} static_descriptor_initializer; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace +} // namespace protobuf_google_2fprotobuf_2fduration_2eproto // =================================================================== @@ -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_google_2fprotobuf_2fduration_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Duration) } @@ -142,21 +137,20 @@ Duration::Duration(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); + protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -191,44 +185,23 @@ void Duration::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Duration::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Duration_descriptor_; + protobuf_google_2fprotobuf_2fduration_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fduration_2eproto::file_level_metadata[0].descriptor; } const Duration& Duration::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); + protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaults(); 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,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -251,14 +225,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(16u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -266,7 +239,6 @@ bool Duration::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -294,12 +266,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); } @@ -309,14 +281,14 @@ void Duration::SerializeWithCachedSizes( ::google::protobuf::uint8* Duration::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +301,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 +324,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 +333,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 +360,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 +372,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 +389,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; + protobuf_google_2fprotobuf_2fduration_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fduration_2eproto::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 +414,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 +428,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..591c11d1 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -8,37 +8,48 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3001000 +#if GOOGLE_PROTOBUF_VERSION < 3002000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #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; +LIBPROTOBUF_EXPORT extern DurationDefaultTypeInternal _Duration_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { +namespace protobuf_google_2fprotobuf_2fduration_2eproto { // 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; +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::uint32 offsets[]; + static void InitDefaultsImpl(); + static void Shutdown(); +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaults(); +} // namespace protobuf_google_2fprotobuf_2fduration_2eproto // =================================================================== @@ -54,47 +65,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +126,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; @@ -137,15 +154,8 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot ::google::protobuf::int64 seconds_; ::google::protobuf::int32 nanos_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fduration_2eproto::TableStruct; }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Duration> Duration_default_instance_; - // =================================================================== @@ -154,7 +164,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 +178,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 +192,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..d6bde495 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,20 +231,19 @@ 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 // looking back at this field. This would assume details about the // implementation of scoped_ptr. const DynamicMessage* prototype; - void* default_oneof_instance; - TypeInfo() : prototype(NULL), default_oneof_instance(NULL) {} + TypeInfo() : prototype(NULL) {} ~TypeInfo() { delete prototype; - operator delete(default_oneof_instance); } }; @@ -327,14 +326,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 +379,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 +413,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 +446,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<const uint8*>( + type_info_->prototype) + + type_info_->offsets[i]) + ->Get()); reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy( default_value, NULL); break; @@ -506,8 +507,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; @@ -535,10 +537,6 @@ void DynamicMessage::CrossLinkPrototypes() { for (int i = 0; i < descriptor->field_count(); i++) { const FieldDescriptor* field = descriptor->field(i); void* field_ptr = OffsetToPointer(type_info_->offsets[i]); - if (field->containing_oneof()) { - field_ptr = reinterpret_cast<uint8*>( - type_info_->default_oneof_instance) + type_info_->offsets[i]; - } if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && !field->is_repeated()) { @@ -610,7 +608,7 @@ DynamicMessageFactory::~DynamicMessageFactory() { iter != prototypes_->map_.end(); ++iter) { DeleteDefaultOneofInstance(iter->second->type, iter->second->offsets.get(), - iter->second->default_oneof_instance); + iter->second->prototype); delete iter->second; } } @@ -649,7 +647,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 +666,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 +692,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,19 +712,37 @@ 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. - size = AlignOffset(size); type_info->size = size; - // Allocate the prototype. + + // Construct the reflection object. + + if (type->oneof_decl_count() > 0) { + // Compute the size of default oneof instance and offsets of default + // oneof fields. + for (int i = 0; i < type->oneof_decl_count(); i++) { + for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) { + const FieldDescriptor* field = type->oneof_decl(i)->field(j); + int field_size = OneofFieldSpaceUsed(field); + size = AlignTo(size, std::min(kSafeAlignment, field_size)); + offsets[field->index()] = size; + size += field_size; + } + } + } + size = AlignOffset(size); + + // Allocate the prototype + oneof fields. void* base = operator new(size); memset(base, 0, size); + // The prototype in type_info has to be set before creating the prototype // instance on memory. e.g., message Foo { map<int32, Foo> a = 1; }. When // creating prototype for Foo, prototype of the map entry will also be @@ -727,38 +752,26 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( type_info->prototype = static_cast<DynamicMessage*>(base); DynamicMessage* prototype = new(base) DynamicMessage(type_info); - // Construct the reflection object. if (type->oneof_decl_count() > 0) { - // Compute the size of default oneof instance and offsets of default - // oneof fields. - int oneof_size = 0; - for (int i = 0; i < type->oneof_decl_count(); i++) { - for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = type->oneof_decl(i)->field(j); - int field_size = OneofFieldSpaceUsed(field); - oneof_size = AlignTo(oneof_size, std::min(kSafeAlignment, field_size)); - offsets[field->index()] = oneof_size; - oneof_size += field_size; - } - } // Construct default oneof instance. - type_info->default_oneof_instance = ::operator new(oneof_size); 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 */)); + prototype); } + + 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, + type_info->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 +780,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,8 +826,8 @@ void DynamicMessageFactory::ConstructDefaultOneofInstance( void DynamicMessageFactory::DeleteDefaultOneofInstance( const Descriptor* type, - const int offsets[], - void* default_oneof_instance) { + const uint32 offsets[], + const 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++) { const FieldDescriptor* field = type->oneof_decl(i)->field(j); diff --git a/src/google/protobuf/dynamic_message.h b/src/google/protobuf/dynamic_message.h index f74cd7dd..816170ea 100644 --- a/src/google/protobuf/dynamic_message.h +++ b/src/google/protobuf/dynamic_message.h @@ -38,12 +38,15 @@ #ifndef GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__ #define GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__ +#include <algorithm> #include <memory> #ifndef _SHARED_PTR_H #include <google/protobuf/stubs/shared_ptr.h> #endif +#include <vector> #include <google/protobuf/message.h> +#include <google/protobuf/repeated_field.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/mutex.h> @@ -136,16 +139,97 @@ 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[], - void* default_oneof_instance); + const uint32 offsets[], + const void* default_oneof_instance); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory); }; +// Helper for computing a sorted list of map entries via reflection. +class LIBPROTOBUF_EXPORT DynamicMapSorter { + public: + static std::vector<const Message*> Sort(const Message& message, + int map_size, + const Reflection* reflection, + const FieldDescriptor* field) { + std::vector<const Message*> result(map_size); + const RepeatedPtrField<Message>& map_field = + reflection->GetRepeatedPtrField<Message>(message, field); + int i = 0; + for (RepeatedPtrField<Message>::const_pointer_iterator it = + map_field.pointer_begin(); it != map_field.pointer_end(); ) { + result[i++] = *it++; + } + GOOGLE_DCHECK_EQ(result.size(), static_cast<size_t>(i)); + MapEntryMessageComparator comparator(field->message_type()); + std::sort(result.begin(), result.end(), comparator); + // Complain if the keys aren't in ascending order. +#ifndef NDEBUG + for (int j = 1; j < map_size; j++) { + if (!comparator(result[j - 1], result[j])) { + GOOGLE_LOG(ERROR) << (comparator(result[j], result[j - 1]) ? + "internal error in map key sorting" : + "map keys are not unique"); + } + } +#endif + return result; + } + + private: + class LIBPROTOBUF_EXPORT MapEntryMessageComparator { + public: + explicit MapEntryMessageComparator(const Descriptor* descriptor) + : field_(descriptor->field(0)) {} + + bool operator()(const Message* a, const Message* b) { + const Reflection* reflection = a->GetReflection(); + switch (field_->cpp_type()) { + case FieldDescriptor::CPPTYPE_BOOL: { + bool first = reflection->GetBool(*a, field_); + bool second = reflection->GetBool(*b, field_); + return first < second; + } + case FieldDescriptor::CPPTYPE_INT32: { + int32 first = reflection->GetInt32(*a, field_); + int32 second = reflection->GetInt32(*b, field_); + return first < second; + } + case FieldDescriptor::CPPTYPE_INT64: { + int64 first = reflection->GetInt64(*a, field_); + int64 second = reflection->GetInt64(*b, field_); + return first < second; + } + case FieldDescriptor::CPPTYPE_UINT32: { + uint32 first = reflection->GetUInt32(*a, field_); + uint32 second = reflection->GetUInt32(*b, field_); + return first < second; + } + case FieldDescriptor::CPPTYPE_UINT64: { + uint64 first = reflection->GetUInt64(*a, field_); + uint64 second = reflection->GetUInt64(*b, field_); + return first < second; + } + case FieldDescriptor::CPPTYPE_STRING: { + string first = reflection->GetString(*a, field_); + string second = reflection->GetString(*b, field_); + return first < second; + } + default: + GOOGLE_LOG(DFATAL) << "Invalid key for map field."; + return true; + } + } + + private: + const FieldDescriptor* field_; + }; +}; + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index f19bf2a6..31cba097 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -19,107 +19,100 @@ namespace google { namespace protobuf { +class EmptyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Empty> { +} _Empty_default_instance_; + +namespace protobuf_google_2fprotobuf_2fempty_2eproto { + namespace { -const ::google::protobuf::Descriptor* Empty_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Empty_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace +const ::google::protobuf::uint32 TableStruct::offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ +}; -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] = { - }; - 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_)); -} +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Empty)}, +}; + +static ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_Empty_default_instance_), +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/empty.proto", schemas, file_default_instances, TableStruct::offsets, 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_; +void TableStruct::Shutdown() { + _Empty_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } -void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl() { +void TableStruct::InitDefaultsImpl() { 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); +void InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); } -void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); +void AddDescriptorsImpl() { + InitDefaults(); + 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); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_once_); -void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_once_, - &protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl); +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto(); +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); } -} static_descriptor_initializer_google_2fprotobuf_2fempty_2eproto_; - -namespace { +} static_descriptor_initializer; -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace +} // namespace protobuf_google_2fprotobuf_2fempty_2eproto // =================================================================== @@ -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_google_2fprotobuf_2fempty_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Empty) } @@ -137,21 +132,17 @@ Empty::Empty(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); + protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -184,17 +175,15 @@ void Empty::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Empty::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Empty_descriptor_; + protobuf_google_2fprotobuf_2fempty_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fempty_2eproto::file_level_metadata[0].descriptor; } const Empty& Empty::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); + protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaults(); 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: @@ -237,7 +226,7 @@ void Empty::SerializeWithCachedSizes( ::google::protobuf::uint8* Empty::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Empty) // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Empty) return target; @@ -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; + protobuf_google_2fprotobuf_2fempty_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fempty_2eproto::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..a75d6dd6 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -8,37 +8,48 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3001000 +#if GOOGLE_PROTOBUF_VERSION < 3002000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #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; +LIBPROTOBUF_EXPORT extern EmptyDefaultTypeInternal _Empty_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { +namespace protobuf_google_2fprotobuf_2fempty_2eproto { // 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; +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::uint32 offsets[]; + static void InitDefaultsImpl(); + static void Shutdown(); +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaults(); +} // namespace protobuf_google_2fprotobuf_2fempty_2eproto // =================================================================== @@ -54,47 +65,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +126,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 ---------------------------------------------------- @@ -123,15 +140,8 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fempty_2eproto::TableStruct; }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Empty> Empty_default_instance_; - // =================================================================== @@ -140,13 +150,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..8f8f180a 100644 --- a/src/google/protobuf/extension_set_heavy.cc +++ b/src/google/protobuf/extension_set_heavy.cc @@ -35,6 +35,7 @@ // Contains methods defined in extension_set.h which cannot be part of the // lite library because they use descriptors or reflection. +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/extension_set.h> @@ -413,12 +414,16 @@ uint8* ExtensionSet::SerializeWithCachedSizesToArray(int start_field_number, int end_field_number, uint8* target) const { return InternalSerializeWithCachedSizesToArray( - start_field_number, end_field_number, false, target); + start_field_number, end_field_number, + google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), + target); } uint8* ExtensionSet::SerializeMessageSetWithCachedSizesToArray( uint8* target) const { - return InternalSerializeMessageSetWithCachedSizesToArray(false, target); + return InternalSerializeMessageSetWithCachedSizesToArray( + google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), + target); } uint8* ExtensionSet::InternalSerializeWithCachedSizesToArray( @@ -587,11 +592,12 @@ ExtensionSet::Extension::InternalSerializeMessageSetItemWithCachedSizesToArray( WireFormatLite::kMessageSetTypeIdNumber, number, target); // Write message. if (is_lazy) { - target = lazymessage_value->WriteMessageToArray( - WireFormatLite::kMessageSetMessageNumber, target); + target = lazymessage_value->InternalWriteMessageToArray( + WireFormatLite::kMessageSetMessageNumber, deterministic, target); } else { - target = WireFormatLite::WriteMessageToArray( - WireFormatLite::kMessageSetMessageNumber, *message_value, target); + target = WireFormatLite::InternalWriteMessageToArray( + WireFormatLite::kMessageSetMessageNumber, *message_value, deterministic, + target); } // End group. target = io::CodedOutputStream::WriteTagToArray( @@ -656,7 +662,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..c9409fe5 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -19,109 +19,102 @@ namespace google { namespace protobuf { +class FieldMaskDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> { +} _FieldMask_default_instance_; + +namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto { + namespace { -const ::google::protobuf::Descriptor* FieldMask_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FieldMask_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace +const ::google::protobuf::uint32 TableStruct::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_), +}; -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] = { - 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_)); -} +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(FieldMask)}, +}; + +static ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_FieldMask_default_instance_), +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/field_mask.proto", schemas, file_default_instances, TableStruct::offsets, 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_; +void TableStruct::Shutdown() { + _FieldMask_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } -void protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl() { +void TableStruct::InitDefaultsImpl() { 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); +void InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); } -void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); +void AddDescriptorsImpl() { + InitDefaults(); + 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); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_once_); -void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_once_, - &protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl); +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); } -} 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); -} +} static_descriptor_initializer; -} // namespace +} // namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto // =================================================================== @@ -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_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaults(); + } 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) } @@ -166,17 +158,15 @@ void FieldMask::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FieldMask::descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldMask_descriptor_; + protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::file_level_metadata[0].descriptor; } const FieldMask& FieldMask::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); + protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaults(); 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,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_paths())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -214,8 +204,6 @@ bool FieldMask::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_paths; - if (input->ExpectAtEnd()) goto success; break; } @@ -244,7 +232,7 @@ void FieldMask::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.FieldMask) // repeated string paths = 1; - for (int i = 0; i < this->paths_size(); i++) { + for (int i = 0, n = this->paths_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->paths(i).data(), this->paths(i).length(), ::google::protobuf::internal::WireFormatLite::SERIALIZE, @@ -258,10 +246,10 @@ void FieldMask::SerializeWithCachedSizes( ::google::protobuf::uint8* FieldMask::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldMask) // repeated string paths = 1; - for (int i = 0; i < this->paths_size(); i++) { + for (int i = 0, n = this->paths_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->paths(i).data(), this->paths(i).length(), ::google::protobuf::internal::WireFormatLite::SERIALIZE, @@ -281,7 +269,7 @@ size_t FieldMask::ByteSizeLong() const { // repeated string paths = 1; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->paths_size()); - for (int i = 0; i < this->paths_size(); i++) { + for (int i = 0, n = this->paths_size(); i < n; i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->paths(i)); } @@ -295,7 +283,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 +292,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 +314,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 +327,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; + protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -381,6 +357,12 @@ void FieldMask::set_paths(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) paths_.Mutable(index)->assign(value); } +#if LANG_CXX11 +void FieldMask::set_paths(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) + paths_.Mutable(index)->assign(std::move(value)); +} +#endif void FieldMask::set_paths(int index, const char* value) { paths_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths) @@ -398,6 +380,12 @@ void FieldMask::add_paths(const ::std::string& value) { paths_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) } +#if LANG_CXX11 +void FieldMask::add_paths(::std::string&& value) { + paths_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) +} +#endif void FieldMask::add_paths(const char* value) { paths_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths) @@ -417,9 +405,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..b609f235 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -8,37 +8,48 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3001000 +#if GOOGLE_PROTOBUF_VERSION < 3002000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #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; +LIBPROTOBUF_EXPORT extern FieldMaskDefaultTypeInternal _FieldMask_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { +namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto { // 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; +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::uint32 offsets[]; + static void InitDefaultsImpl(); + static void Shutdown(); +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaults(); +} // namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto // =================================================================== @@ -57,49 +68,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 ---------------------------------------------------- @@ -112,10 +127,16 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro const ::std::string& paths(int index) const; ::std::string* mutable_paths(int index); void set_paths(int index, const ::std::string& value); + #if LANG_CXX11 + void set_paths(int index, ::std::string&& value); + #endif void set_paths(int index, const char* value); void set_paths(int index, const char* value, size_t size); ::std::string* add_paths(); void add_paths(const ::std::string& value); + #if LANG_CXX11 + void add_paths(::std::string&& value); + #endif void add_paths(const char* value); void add_paths(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& paths() const; @@ -127,15 +148,8 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::RepeatedPtrField< ::std::string> paths_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::TableStruct; }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> FieldMask_default_instance_; - // =================================================================== @@ -163,6 +177,12 @@ inline void FieldMask::set_paths(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) paths_.Mutable(index)->assign(value); } +#if LANG_CXX11 +inline void FieldMask::set_paths(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) + paths_.Mutable(index)->assign(std::move(value)); +} +#endif inline void FieldMask::set_paths(int index, const char* value) { paths_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths) @@ -180,6 +200,12 @@ inline void FieldMask::add_paths(const ::std::string& value) { paths_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) } +#if LANG_CXX11 +inline void FieldMask::add_paths(::std::string&& value) { + paths_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) +} +#endif inline void FieldMask::add_paths(const char* value) { paths_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths) @@ -199,13 +225,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..2f8f8256 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 @@ -72,18 +73,28 @@ const string& NameOfEnum(const EnumDescriptor* descriptor, int value) { return (d == NULL ? GetEmptyString() : d->name()); } -namespace { -inline bool SupportsArenas(const Descriptor* descriptor) { - return descriptor->file()->options().cc_enable_arenas(); -} -} // anonymous namespace - // =================================================================== // Helpers for reporting usage errors (e.g. trying to use GetInt32() on // a string field). 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 +184,14 @@ 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) + const Descriptor* descriptor, const ReflectionSchema& schema, + const DescriptorPool* pool, MessageFactory* factory) : 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) - : 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) { +} GeneratedMessageReflection::~GeneratedMessageReflection() {} @@ -236,39 +218,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 +313,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 +329,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 +451,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,37 +614,49 @@ 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; + + int fields_with_has_bits = 0; + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* field = descriptor_->field(i); + if (field->is_repeated() || field->containing_oneof()) { + continue; + } + fields_with_has_bits++; + } + + int has_bits_size = (fields_with_has_bits + 31) / 32; for (int i = 0; i < has_bits_size; i++) { std::swap(has_bits1[i], has_bits2[i]); } } - 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 +666,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 +687,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( @@ -715,8 +704,11 @@ void GeneratedMessageReflection::SwapFields( swapped_oneof.insert(oneof_index); SwapOneofField(message1, message2, field->containing_oneof()); } else { - // Swap has bit. - SwapBit(message1, message2, field); + // Swap has bit for non-repeated fields. We have already checked for + // oneof already. + if (!field->is_repeated()) { + SwapBit(message1, message2, field); + } // Swap field. SwapField(message1, message2, field); } @@ -821,9 +813,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 +823,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 +1000,36 @@ 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) { + GOOGLE_DCHECK_NE(has_bit_index, ~0u); + 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 +1044,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 +1053,7 @@ void GeneratedMessageReflection::ListFields( } } - if (extensions_offset_ != -1) { + if (schema_.HasExtensionSet()) { GetExtensionSet(message).AppendToList(descriptor_, descriptor_pool_, output); } @@ -1147,9 +1147,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 +1167,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 +1188,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( @@ -1513,7 +1508,7 @@ void GeneratedMessageReflection::UnsafeArenaSetAllocatedMessage( USAGE_CHECK_ALL(SetAllocatedMessage, SINGULAR, MESSAGE); if (field->is_extension()) { - MutableExtensionSet(message)->SetAllocatedMessage( + MutableExtensionSet(message)->UnsafeArenaSetAllocatedMessage( field->number(), field->type(), field, sub_message); } else { if (field->containing_oneof()) { @@ -1581,7 +1576,9 @@ Message* GeneratedMessageReflection::UnsafeArenaReleaseMessage( MutableExtensionSet(message)->UnsafeArenaReleaseMessage(field, factory)); } else { - ClearBit(message, field); + if (!(field->is_repeated() || field->containing_oneof())) { + ClearBit(message, field); + } if (field->containing_oneof()) { if (HasOneofField(*message, field)) { *MutableOneofCase(message, field->containing_oneof()) = 0; @@ -1727,11 +1724,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 +1754,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 +1838,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 +1850,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 +1869,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 +1882,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 +2104,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 +2216,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 +2228,128 @@ 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 Message* const* default_instance, const uint32* offsets, + MigrationSchema migration_schema) { + ReflectionSchema result; + result.default_instance_ = *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.oneof_case_offset_ = offsets[migration_schema.offsets_index + 3]; + result.object_size_ = migration_schema.object_size; + result.weak_field_map_offset_ = 0; + return result; +} + +template<typename Schema> +class AssignDescriptorsHelper { + public: + AssignDescriptorsHelper(MessageFactory* factory, + Metadata* file_level_metadata, + const EnumDescriptor** file_level_enum_descriptors, + const Schema* schemas, + const Message* const* 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 Message* const * default_instance_data_; + const uint32* offsets_; +}; + +} // namespace + +void AssignDescriptors( + const string& filename, const MigrationSchema* schemas, + const Message* const* default_instances_, 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_instances_, 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 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..8b1362a2 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,148 @@ 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. +// 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 InternalMetadataWithArena member. + // For Lite this will actually be an InternalMetadataWithArenaLite. + // 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_; + } + + // The off set of WeakFieldMap when the message contains weak fields. + // The default is 0 for now. + int GetWeakFieldMapOffset() const { return weak_field_map_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 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_; + int oneof_case_offset_; + int object_size_; + int weak_field_map_offset_; +}; + +// 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 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 +240,24 @@ 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 +482,27 @@ 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_; + 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 +515,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 +608,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); }; @@ -585,14 +637,14 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { // choose 16 rather than some other number just in case the compiler would // be confused by an unaligned pointer. #define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \ - static_cast<int>( \ - reinterpret_cast<const char*>( \ - &reinterpret_cast<const TYPE*>(16)->FIELD) - \ + static_cast< ::google::protobuf::uint32>( \ + reinterpret_cast<const char*>( \ + &reinterpret_cast<const TYPE*>(16)->FIELD) - \ reinterpret_cast<const char*>(16)) #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)) @@ -622,6 +674,8 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { template<typename To, typename From> inline To dynamic_cast_if_available(From from) { #if defined(GOOGLE_PROTOBUF_NO_RTTI) || (defined(_MSC_VER)&&!defined(_CPPRTTI)) + // Avoid the compiler warning about unused variables. + (void)from; return NULL; #else return dynamic_cast<To>(from); @@ -664,6 +718,17 @@ T* DynamicCastToGenerated(Message* from) { return const_cast<T*>(DynamicCastToGenerated<const T>(message_const)); } +LIBPROTOBUF_EXPORT void AssignDescriptors( + const string& filename, const MigrationSchema* schemas, + const Message* const* default_instances_, 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 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..242cc4a1 100644 --- a/src/google/protobuf/generated_message_reflection_unittest.cc +++ b/src/google/protobuf/generated_message_reflection_unittest.cc @@ -48,9 +48,10 @@ #include <google/protobuf/stubs/shared_ptr.h> #endif -#include <google/protobuf/descriptor.h> #include <google/protobuf/test_util.h> #include <google/protobuf/unittest.pb.h> +#include <google/protobuf/arena.h> +#include <google/protobuf/descriptor.h> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> @@ -222,7 +223,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 +256,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 +271,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 +307,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)); @@ -519,6 +520,41 @@ TEST(GeneratedMessageReflectionTest, SetAllocatedMessageTest) { &to_message, TestUtil::ReflectionTester::IS_NULL); } +TEST(GeneratedMessageReflectionTest, SetAllocatedMessageOnArenaTest) { + unittest::TestAllTypes from_message1; + unittest::TestAllTypes from_message2; + ::google::protobuf::Arena arena; + unittest::TestAllTypes* to_message = + ::google::protobuf::Arena::CreateMessage<unittest::TestAllTypes>(&arena); + TestUtil::ReflectionTester reflection_tester( + unittest::TestAllTypes::descriptor()); + reflection_tester.SetAllFieldsViaReflection(&from_message1); + reflection_tester.SetAllFieldsViaReflection(&from_message2); + + // Before moving fields, we expect the nested messages to be NULL. + reflection_tester.ExpectMessagesReleasedViaReflection( + to_message, TestUtil::ReflectionTester::IS_NULL); + + // After fields are moved we should get non-NULL releases. + reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection( + &from_message1, to_message); + reflection_tester.ExpectMessagesReleasedViaReflection( + to_message, TestUtil::ReflectionTester::NOT_NULL); + + // Another move to make sure that we can SetAllocated several times. + reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection( + &from_message2, to_message); + reflection_tester.ExpectMessagesReleasedViaReflection( + to_message, TestUtil::ReflectionTester::NOT_NULL); + + // After SetAllocatedOptionalMessageFieldsToNullViaReflection() we expect the + // releases to be NULL again. + reflection_tester.SetAllocatedOptionalMessageFieldsToNullViaReflection( + to_message); + reflection_tester.ExpectMessagesReleasedViaReflection( + to_message, TestUtil::ReflectionTester::IS_NULL); +} + TEST(GeneratedMessageReflectionTest, SetAllocatedExtensionMessageTest) { unittest::TestAllExtensions from_message1; unittest::TestAllExtensions from_message2; @@ -552,6 +588,41 @@ TEST(GeneratedMessageReflectionTest, SetAllocatedExtensionMessageTest) { &to_message, TestUtil::ReflectionTester::IS_NULL); } +TEST(GeneratedMessageReflectionTest, SetAllocatedExtensionMessageOnArenaTest) { + ::google::protobuf::Arena arena; + unittest::TestAllExtensions* to_message = + ::google::protobuf::Arena::CreateMessage<unittest::TestAllExtensions>(&arena); + unittest::TestAllExtensions from_message1; + unittest::TestAllExtensions from_message2; + TestUtil::ReflectionTester reflection_tester( + unittest::TestAllExtensions::descriptor()); + reflection_tester.SetAllFieldsViaReflection(&from_message1); + reflection_tester.SetAllFieldsViaReflection(&from_message2); + + // Before moving fields, we expect the nested messages to be NULL. + reflection_tester.ExpectMessagesReleasedViaReflection( + to_message, TestUtil::ReflectionTester::IS_NULL); + + // After fields are moved we should get non-NULL releases. + reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection( + &from_message1, to_message); + reflection_tester.ExpectMessagesReleasedViaReflection( + to_message, TestUtil::ReflectionTester::NOT_NULL); + + // Another move to make sure that we can SetAllocated several times. + reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection( + &from_message2, to_message); + reflection_tester.ExpectMessagesReleasedViaReflection( + to_message, TestUtil::ReflectionTester::NOT_NULL); + + // After SetAllocatedOptionalMessageFieldsToNullViaReflection() we expect the + // releases to be NULL again. + reflection_tester.SetAllocatedOptionalMessageFieldsToNullViaReflection( + to_message); + reflection_tester.ExpectMessagesReleasedViaReflection( + to_message, TestUtil::ReflectionTester::IS_NULL); +} + TEST(GeneratedMessageReflectionTest, AddRepeatedMessage) { unittest::TestAllTypes message; @@ -608,7 +679,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()); } @@ -723,6 +794,59 @@ TEST(GeneratedMessageReflectionTest, SetAllocatedOneofMessageTest) { delete released; } +TEST(GeneratedMessageReflectionTest, SetAllocatedOneofMessageOnArenaTest) { + unittest::TestOneof2 from_message1; + unittest::TestOneof2 from_message2; + ::google::protobuf::Arena arena; + unittest::TestOneof2* to_message = + ::google::protobuf::Arena::CreateMessage<unittest::TestOneof2>(&arena); + const Descriptor* descriptor = unittest::TestOneof2::descriptor(); + const Reflection* reflection = to_message->GetReflection(); + + Message* released = reflection->ReleaseMessage( + to_message, descriptor->FindFieldByName("foo_lazy_message")); + EXPECT_TRUE(released == NULL); + released = reflection->ReleaseMessage( + to_message, descriptor->FindFieldByName("foo_message")); + EXPECT_TRUE(released == NULL); + + TestUtil::ReflectionTester::SetOneofViaReflection(&from_message1); + TestUtil::ReflectionTester::ExpectOneofSetViaReflection(from_message1); + + TestUtil::ReflectionTester:: + SetAllocatedOptionalMessageFieldsToMessageViaReflection( + &from_message1, to_message); + const Message& sub_message = reflection->GetMessage( + *to_message, descriptor->FindFieldByName("foo_lazy_message")); + released = reflection->ReleaseMessage( + to_message, descriptor->FindFieldByName("foo_lazy_message")); + EXPECT_TRUE(released != NULL); + // Since sub_message is arena allocated, releasing it results in copying it + // into new heap-allocated memory. + EXPECT_NE(&sub_message, released); + delete released; + + TestUtil::ReflectionTester::SetOneofViaReflection(&from_message2); + + reflection->MutableMessage( + &from_message2, descriptor->FindFieldByName("foo_message")); + + TestUtil::ReflectionTester:: + SetAllocatedOptionalMessageFieldsToMessageViaReflection( + &from_message2, to_message); + + const Message& sub_message2 = reflection->GetMessage( + *to_message, descriptor->FindFieldByName("foo_message")); + released = reflection->ReleaseMessage( + to_message, descriptor->FindFieldByName("foo_message")); + EXPECT_TRUE(released != NULL); + // Since sub_message2 is arena allocated, releasing it results in copying it + // into new heap-allocated memory. + EXPECT_NE(&sub_message2, released); + delete released; +} + + TEST(GeneratedMessageReflectionTest, ReleaseMessageTest) { unittest::TestAllTypes message; TestUtil::ReflectionTester reflection_tester( 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..14101832 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 LANG_CXX11 +#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 LANG_CXX11 + constexpr +#endif + const T& + get() const { + return reinterpret_cast<const T&>(union_); + } T* get_mutable() { return reinterpret_cast<T*>(&union_); } private: @@ -111,7 +125,7 @@ class ExplicitlyConstructed { // Default empty string object. Don't use this directly. Instead, call // GetEmptyString() to get the reference. -extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string; +LIBPROTOBUF_EXPORT extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string; LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_; LIBPROTOBUF_EXPORT void InitEmptyString(); @@ -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/has_bits.h b/src/google/protobuf/has_bits.h index 133bc02a..cb1d7ccc 100644 --- a/src/google/protobuf/has_bits.h +++ b/src/google/protobuf/has_bits.h @@ -61,10 +61,41 @@ class HasBits { bool operator!=(const HasBits<doublewords>& rhs) const { return !(*this == rhs); } + + bool empty() const; + private: ::google::protobuf::uint32 has_bits_[doublewords]; }; +template <> +inline bool HasBits<1>::empty() const { + return !has_bits_[0]; +} + +template <> +inline bool HasBits<2>::empty() const { + return !(has_bits_[0] | has_bits_[1]); +} + +template <> +inline bool HasBits<3>::empty() const { + return !(has_bits_[0] | has_bits_[1] | has_bits_[2]); +} + +template <> +inline bool HasBits<4>::empty() const { + return !(has_bits_[0] | has_bits_[1] | has_bits_[2] | has_bits_[3]); +} + +template <size_t doublewords> +inline bool HasBits<doublewords>::empty() const { + for (size_t i = 0; i < doublewords; ++i) { + if (has_bits_[i]) return false; + } + return true; +} + } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc index 08394ca7..3c2e0fbd 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() { @@ -903,20 +816,6 @@ bool CodedOutputStream::Refresh() { } } -size_t CodedOutputStream::VarintSize32Fallback(uint32 value) { - GOOGLE_DCHECK_NE(0, value); // This is enforced by our caller. - - return 1 + Bits::Log2FloorNonZero(value) / 7; -} - -size_t CodedOutputStream::VarintSize64(uint64 value) { - if (value < (1 << 7)) { - return 1; - } - - return 1 + Bits::Log2FloorNonZero64(value) / 7; -} - uint8* CodedOutputStream::WriteStringWithSizeToArray(const string& str, uint8* target) { GOOGLE_DCHECK_LE(str.size(), kuint32max); diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index 1402cc17..b71b4a98 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -110,6 +110,7 @@ #define GOOGLE_PROTOBUF_IO_CODED_STREAM_H__ #include <assert.h> +#include <climits> #include <string> #include <utility> #ifdef _MSC_VER @@ -139,6 +140,8 @@ namespace protobuf { class DescriptorPool; class MessageFactory; +namespace internal { void MapTestForceDeterministic(); } + namespace io { // Defined in this file. @@ -249,12 +252,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 +273,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 +302,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 +623,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 +640,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,15 +860,19 @@ 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_; } + static bool IsDefaultSerializationDeterministic() { + return default_serialization_deterministic_; + } + private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodedOutputStream); @@ -879,20 +901,11 @@ 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); - - static size_t VarintSize32Fallback(uint32 value); + void WriteVarint64SlowPath(uint64 value); // See above. Other projects may use "friend" to allow them to call this. + // Requires: no protocol buffer serialization in progress. + friend void ::google::protobuf::internal::MapTestForceDeterministic(); static void SetDefaultSerializationDeterministic() { default_serialization_deterministic_ = true; } @@ -981,8 +994,7 @@ inline const uint8* CodedInputStream::ReadLittleEndian64FromArray( inline bool CodedInputStream::ReadLittleEndian32(uint32* value) { #if defined(PROTOBUF_LITTLE_ENDIAN) if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) { - memcpy(value, buffer_, sizeof(*value)); - Advance(sizeof(*value)); + buffer_ = ReadLittleEndian32FromArray(buffer_, value); return true; } else { return ReadLittleEndian32Fallback(value); @@ -995,8 +1007,7 @@ inline bool CodedInputStream::ReadLittleEndian32(uint32* value) { inline bool CodedInputStream::ReadLittleEndian64(uint64* value) { #if defined(PROTOBUF_LITTLE_ENDIAN) if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) { - memcpy(value, buffer_, sizeof(*value)); - Advance(sizeof(*value)); + buffer_ = ReadLittleEndian64FromArray(buffer_, value); return true; } else { return ReadLittleEndian64Fallback(value); @@ -1007,21 +1018,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 +1070,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 +1084,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 +1100,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 +1199,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 +1265,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); } @@ -1226,11 +1288,23 @@ inline uint8* CodedOutputStream::WriteTagToArray( } inline size_t CodedOutputStream::VarintSize32(uint32 value) { - if (value < (1 << 7)) { - return 1; - } else { - return VarintSize32Fallback(value); - } + // This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1 + // Use an explicit multiplication to implement the divide of + // a number in the 1..31 range. + // Explicit OR 0x1 to avoid calling Bits::Log2FloorNonZero(0), which is + // undefined. + uint32 log2value = Bits::Log2FloorNonZero(value | 0x1); + return static_cast<size_t>((log2value * 9 + 73) / 64); +} + +inline size_t CodedOutputStream::VarintSize64(uint64 value) { + // 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 Bits::Log2FloorNonZero(0), which is + // undefined. + uint32 log2value = Bits::Log2FloorNonZero64(value | 0x1); + return static_cast<size_t>((log2value * 9 + 73) / 64); } inline size_t CodedOutputStream::VarintSize32SignExtended(int32 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/gzip_stream.h b/src/google/protobuf/io/gzip_stream.h index 15b02fe3..df1a446e 100644 --- a/src/google/protobuf/io/gzip_stream.h +++ b/src/google/protobuf/io/gzip_stream.h @@ -118,7 +118,7 @@ class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream { ZLIB = 2, }; - struct Options { + struct LIBPROTOBUF_EXPORT Options { // Defaults to GZIP. Format format; 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..cadeb696 100644 --- a/src/google/protobuf/io/tokenizer_unittest.cc +++ b/src/google/protobuf/io/tokenizer_unittest.cc @@ -199,8 +199,8 @@ struct SimpleTokenCase { Tokenizer::TokenType type; }; -inline ostream& operator<<(ostream& out, - const SimpleTokenCase& test_case) { +inline std::ostream& operator<<(std::ostream& out, + const SimpleTokenCase& test_case) { return out << CEscape(test_case.input); } @@ -333,8 +333,8 @@ struct MultiTokenCase { // needed. }; -inline ostream& operator<<(ostream& out, - const MultiTokenCase& test_case) { +inline std::ostream& operator<<(std::ostream& out, + const MultiTokenCase& test_case) { return out << CEscape(test_case.input); } @@ -520,8 +520,8 @@ struct DocCommentCase { const char* next_leading_comments; }; -inline ostream& operator<<(ostream& out, - const DocCommentCase& test_case) { +inline std::ostream& operator<<(std::ostream& out, + const DocCommentCase& test_case) { return out << CEscape(test_case.input); } @@ -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); @@ -860,8 +860,7 @@ struct ErrorCase { const char* errors; }; -inline ostream& operator<<(ostream& out, - const ErrorCase& test_case) { +inline std::ostream& operator<<(std::ostream& out, const ErrorCase& test_case) { return out << CEscape(test_case.input); } diff --git a/src/google/protobuf/io/zero_copy_stream_impl.cc b/src/google/protobuf/io/zero_copy_stream_impl.cc index 7ec2b5da..109c55c1 100644 --- a/src/google/protobuf/io/zero_copy_stream_impl.cc +++ b/src/google/protobuf/io/zero_copy_stream_impl.cc @@ -270,10 +270,8 @@ bool FileOutputStream::CopyingFileOutputStream::Write( // =================================================================== -IstreamInputStream::IstreamInputStream(istream* input, int block_size) - : copying_input_(input), - impl_(©ing_input_, block_size) { -} +IstreamInputStream::IstreamInputStream(std::istream* input, int block_size) + : copying_input_(input), impl_(©ing_input_, block_size) {} IstreamInputStream::~IstreamInputStream() {} @@ -294,9 +292,8 @@ int64 IstreamInputStream::ByteCount() const { } IstreamInputStream::CopyingIstreamInputStream::CopyingIstreamInputStream( - istream* input) - : input_(input) { -} + std::istream* input) + : input_(input) {} IstreamInputStream::CopyingIstreamInputStream::~CopyingIstreamInputStream() {} @@ -312,10 +309,8 @@ int IstreamInputStream::CopyingIstreamInputStream::Read( // =================================================================== -OstreamOutputStream::OstreamOutputStream(ostream* output, int block_size) - : copying_output_(output), - impl_(©ing_output_, block_size) { -} +OstreamOutputStream::OstreamOutputStream(std::ostream* output, int block_size) + : copying_output_(output), impl_(©ing_output_, block_size) {} OstreamOutputStream::~OstreamOutputStream() { impl_.Flush(); @@ -334,9 +329,8 @@ int64 OstreamOutputStream::ByteCount() const { } OstreamOutputStream::CopyingOstreamOutputStream::CopyingOstreamOutputStream( - ostream* output) - : output_(output) { -} + std::ostream* output) + : output_(output) {} OstreamOutputStream::CopyingOstreamOutputStream::~CopyingOstreamOutputStream() { } diff --git a/src/google/protobuf/io/zero_copy_stream_unittest.cc b/src/google/protobuf/io/zero_copy_stream_unittest.cc index a9db8872..235cbca4 100644 --- a/src/google/protobuf/io/zero_copy_stream_unittest.cc +++ b/src/google/protobuf/io/zero_copy_stream_unittest.cc @@ -882,7 +882,7 @@ TEST_F(IoTest, IostreamIo) { for (int i = 0; i < kBlockSizeCount; i++) { for (int j = 0; j < kBlockSizeCount; j++) { { - stringstream stream; + std::stringstream stream; { OstreamOutputStream output(&stream, kBlockSizes[i]); @@ -898,7 +898,7 @@ TEST_F(IoTest, IostreamIo) { } { - stringstream stream; + std::stringstream stream; { OstreamOutputStream output(&stream, kBlockSizes[i]); diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 2d295510..6458714e 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) { @@ -615,7 +615,6 @@ class Map { #if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) && \ !defined(GOOGLE_PROTOBUF_OS_NACL) && \ - !defined(GOOGLE_PROTOBUF_OS_ANDROID) && \ !defined(GOOGLE_PROTOBUF_OS_EMSCRIPTEN) template<class NodeType, class... Args> void construct(NodeType* p, Args&&... args) { @@ -654,7 +653,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 +1084,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; } @@ -1532,8 +1533,9 @@ class Map { // Lookup size_type count(const key_type& key) const { - if (find(key) != end()) assert(key == find(key)->first); - return find(key) == end() ? 0 : 1; + const_iterator it = find(key); + GOOGLE_DCHECK(it == end() || key == it->first); + return it == end() ? 0 : 1; } const_iterator find(const key_type& key) const { return old_style_ ? const_iterator(deprecated_elements_->find(key)) diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h index abcd4529..d7db9b0f 100644 --- a/src/google/protobuf/map_entry.h +++ b/src/google/protobuf/map_entry.h @@ -244,14 +244,18 @@ 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, + -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 +282,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 +301,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..1243911b 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())) { @@ -221,9 +221,8 @@ class MapEntryLite : public MessageLite { deterministic, output); return output; } - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { - return InternalSerializeWithCachedSizesToArray(false, output); - } + + // Don't override SerializeWithCachedSizesToArray. Use MessageLite's. int GetCachedSize() const { int size = 0; @@ -333,7 +332,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 +356,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 +378,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 +399,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..43fe0f44 100644 --- a/src/google/protobuf/map_test.cc +++ b/src/google/protobuf/map_test.cc @@ -91,6 +91,10 @@ using google::protobuf::unittest::TestRecursiveMapMessage; namespace protobuf { namespace internal { +void MapTestForceDeterministic() { + ::google::protobuf::io::CodedOutputStream::SetDefaultSerializationDeterministic(); +} + // Map API Test ===================================================== // Parameterized tests on whether to use old style maps. @@ -298,7 +302,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 +338,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 +383,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 +510,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 +567,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 +2441,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); @@ -2844,7 +2848,7 @@ TEST(WireFormatForMapFieldTest, MapParseHelpers) { { // Test ParseFromIstream. protobuf_unittest::TestMap message; - stringstream stream(data); + std::stringstream stream(data); EXPECT_TRUE(message.ParseFromIstream(&stream)); EXPECT_TRUE(stream.eof()); MapTestUtil::ExpectMapFieldsSet(message); @@ -2873,6 +2877,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 +2913,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 +3017,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..b799dead 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, ", "); } @@ -130,12 +130,12 @@ bool Message::ParsePartialFromFileDescriptor(int file_descriptor) { return ParsePartialFromZeroCopyStream(&input) && input.GetErrno() == 0; } -bool Message::ParseFromIstream(istream* input) { +bool Message::ParseFromIstream(std::istream* input) { io::IstreamInputStream zero_copy_input(input); return ParseFromZeroCopyStream(&zero_copy_input) && input->eof(); } -bool Message::ParsePartialFromIstream(istream* input) { +bool Message::ParsePartialFromIstream(std::istream* input) { io::IstreamInputStream zero_copy_input(input); return ParsePartialFromZeroCopyStream(&zero_copy_input) && input->eof(); } @@ -172,7 +172,7 @@ bool Message::SerializePartialToFileDescriptor(int file_descriptor) const { return SerializePartialToZeroCopyStream(&output); } -bool Message::SerializeToOstream(ostream* output) const { +bool Message::SerializeToOstream(std::ostream* output) const { { io::OstreamOutputStream zero_copy_output(output); if (!SerializeToZeroCopyStream(&zero_copy_output)) return false; @@ -180,7 +180,7 @@ bool Message::SerializeToOstream(ostream* output) const { return output->good(); } -bool Message::SerializePartialToOstream(ostream* output) const { +bool Message::SerializePartialToOstream(std::ostream* output) const { io::OstreamOutputStream zero_copy_output(output); return SerializePartialToZeroCopyStream(&zero_copy_output); } @@ -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..4d14584d 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); + // FindValueByNumber(new_value) != NULL) { + // 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 9d6da264..b8cb3f4c 100644 --- a/src/google/protobuf/message_lite.cc +++ b/src/google/protobuf/message_lite.cc @@ -33,6 +33,8 @@ // Based on original Protocol Buffers design by // 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> @@ -227,6 +229,7 @@ uint8* MessageLite::InternalSerializeWithCachedSizesToArray( int size = GetCachedSize(); io::ArrayOutputStream out(target, size); io::CodedOutputStream coded_out(&out); + coded_out.SetSerializationDeterministic(deterministic); SerializeWithCachedSizes(&coded_out); GOOGLE_CHECK(!coded_out.HadError()); return target + size; @@ -237,21 +240,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); } @@ -294,7 +294,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..5e5ed306 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -39,7 +39,9 @@ #ifndef GOOGLE_PROTOBUF_MESSAGE_LITE_H__ #define GOOGLE_PROTOBUF_MESSAGE_LITE_H__ +#include <climits> #include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/logging.h> namespace google { @@ -239,17 +241,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..c1b05bc1 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> @@ -76,7 +77,7 @@ TEST(MessageTest, SerializeHelpers) { protobuf_unittest::TestAllTypes message; TestUtil::SetAllFields(&message); - stringstream stream; + std::stringstream stream; string str1("foo"); string str2("bar"); @@ -100,7 +101,7 @@ TEST(MessageTest, SerializeHelpers) { } TEST(MessageTest, SerializeToBrokenOstream) { - ofstream out; + std::ofstream out; protobuf_unittest::TestAllTypes message; message.set_optional_int32(123); @@ -154,7 +155,7 @@ TEST(MessageTest, ParseHelpers) { { // Test ParseFromIstream. protobuf_unittest::TestAllTypes message; - stringstream stream(data); + std::stringstream stream(data); EXPECT_TRUE(message.ParseFromIstream(&stream)); EXPECT_TRUE(stream.eof()); TestUtil::ExpectAllFieldsSet(message); @@ -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..dca1fa45 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,80 @@ 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<UnknownFieldSet, + InternalMetadataWithArena>(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<string, + InternalMetadataWithArenaLite>(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 0a41495f..4e5bcf51 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. @@ -418,6 +423,11 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase { void Delete(int index); template <typename TypeHandler> typename TypeHandler::Type* Add(typename TypeHandler::Type* prototype = NULL); +#if LANG_CXX11 + template <typename TypeHandler> + void Add(typename TypeHandler::Type&& value, + std::enable_if<TypeHandler::Moveable>* dummy = NULL); +#endif template <typename TypeHandler> void RemoveLast(); @@ -570,6 +580,9 @@ template <typename GenericType> class GenericTypeHandler { public: typedef GenericType Type; +#if LANG_CXX11 + static const bool Moveable = false; +#endif static inline GenericType* New(Arena* arena) { return ::google::protobuf::Arena::CreateMaybeMessage<Type>( arena, static_cast<GenericType*>(0)); @@ -682,22 +695,23 @@ inline const Message& GenericTypeHandler<Message>::default_instance() { } -// HACK: If a class is declared as DLL-exported in MSVC, it insists on -// generating copies of all its methods -- even inline ones -- to include -// in the DLL. But SpaceUsed() calls StringSpaceUsedExcludingSelf() which -// isn't in the lite library, therefore the lite library cannot link if -// StringTypeHandler is exported. So, we factor out StringTypeHandlerBase, -// export that, then make StringTypeHandler be a subclass which is NOT -// exported. -// TODO(kenton): Now that StringSpaceUsedExcludingSelf() is in the lite -// library, this can be cleaned up. -class LIBPROTOBUF_EXPORT StringTypeHandlerBase { +class StringTypeHandler { public: typedef string Type; +#if LANG_CXX11 + static const bool Moveable = + std::is_move_constructible<Type>::value && + std::is_move_assignable<Type>::value; +#endif static inline string* New(Arena* arena) { return Arena::Create<string>(arena); } +#if LANG_CXX11 + static inline string* New(Arena* arena, std::string&& value) { + return Arena::Create<string>(arena, std::move(value)); + } +#endif static inline string* NewFromPrototype(const string*, ::google::protobuf::Arena* arena) { return New(arena); @@ -718,10 +732,6 @@ class LIBPROTOBUF_EXPORT StringTypeHandlerBase { static inline const Type& default_instance() { return ::google::protobuf::internal::GetEmptyString(); } -}; - -class StringTypeHandler : public StringTypeHandlerBase { - public: static int SpaceUsed(const string& value) { return static_cast<int>(sizeof(value)) + StringSpaceUsedExcludingSelf(value); } @@ -733,7 +743,7 @@ class StringTypeHandler : public StringTypeHandlerBase { // 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); @@ -751,6 +761,9 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase { const Element& Get(int index) const; Element* Mutable(int index); Element* Add(); +#if LANG_CXX11 + void Add(Element&& value); +#endif const Element& operator[](int index) const { return Get(index); } Element& operator[](int index) { return *Mutable(index); } @@ -766,7 +779,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 @@ -873,10 +885,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. @@ -958,17 +970,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,13 +1005,13 @@ inline RepeatedField<Element>::RepeatedField(Arena* arena) : current_size_(0), total_size_(0), rep_(NULL) { - // In case arena is NULL, then we do not create rep_, as code has an invariant - // `rep_ == NULL then arena == NULL`. - if (arena != NULL) { - rep_ = reinterpret_cast<Rep*>( - ::google::protobuf::Arena::CreateArray<char>(arena, kRepHeaderSize)); - rep_->arena = arena; - } + // In case arena is NULL, then we do not create rep_, as code has an invariant + // `rep_ == NULL then arena == NULL`. + if (arena != NULL) { + rep_ = reinterpret_cast<Rep*>( + ::google::protobuf::Arena::CreateArray<char>(arena, kRepHeaderSize)); + rep_->arena = arena; + } } template <typename Element> @@ -1011,7 +1019,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> @@ -1152,7 +1165,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_, @@ -1162,12 +1176,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(); @@ -1306,7 +1314,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_); @@ -1464,6 +1472,25 @@ inline typename TypeHandler::Type* RepeatedPtrFieldBase::Add( return result; } +#if LANG_CXX11 +template <typename TypeHandler> +inline void RepeatedPtrFieldBase::Add( + typename TypeHandler::Type&& value, + std::enable_if<TypeHandler::Moveable>*) { + if (rep_ != NULL && current_size_ < rep_->allocated_size) { + cast<TypeHandler>(rep_->elements[current_size_++]) = std::move(value); + } + if (!rep_ || rep_->allocated_size == total_size_) { + Reserve(total_size_ + 1); + } + ++rep_->allocated_size; + typename TypeHandler::Type* result = + TypeHandler::New(arena_, std::move(value)); + rep_->elements[current_size_++] = result; + return result; +} +#endif + template <typename TypeHandler> inline void RepeatedPtrFieldBase::RemoveLast() { GOOGLE_DCHECK_GT(current_size_, 0); @@ -1806,7 +1833,7 @@ template <typename Element> inline RepeatedPtrField<Element>::RepeatedPtrField( const RepeatedPtrField& other) : RepeatedPtrFieldBase() { - CopyFrom(other); + MergeFrom(other); } template <typename Element> @@ -1861,6 +1888,13 @@ inline Element* RepeatedPtrField<Element>::Add() { return RepeatedPtrFieldBase::Add<TypeHandler>(); } +#if LANG_CXX11 +template <typename Element> +inline void RepeatedPtrField<Element>::Add(Element&& value) { + RepeatedPtrFieldBase::Add<TypeHandler>(std::move(value)); +} +#endif + template <typename Element> inline void RepeatedPtrField<Element>::RemoveLast() { RepeatedPtrFieldBase::RemoveLast<TypeHandler>(); @@ -2483,10 +2517,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..b6f5cfce 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -19,109 +19,103 @@ namespace google { namespace protobuf { +class SourceContextDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> { +} _SourceContext_default_instance_; + +namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto { + namespace { -const ::google::protobuf::Descriptor* SourceContext_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - SourceContext_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace +const ::google::protobuf::uint32 TableStruct::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_), +}; -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] = { - 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_)); -} +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(SourceContext)}, +}; + +static ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_SourceContext_default_instance_), +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/source_context.proto", schemas, file_default_instances, TableStruct::offsets, 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_; +void TableStruct::Shutdown() { + _SourceContext_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } -void protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() { +void TableStruct::InitDefaultsImpl() { 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); +void InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); } -void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); +void AddDescriptorsImpl() { + InitDefaults(); + 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); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_once_); -void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_once_, - &protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl); +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); } -} static_descriptor_initializer_google_2fprotobuf_2fsource_5fcontext_2eproto_; +} static_descriptor_initializer; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace +} // namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto // =================================================================== @@ -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_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults(); + } 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) } @@ -168,17 +164,15 @@ void SourceContext::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* SourceContext::descriptor() { - protobuf_AssignDescriptorsOnce(); - return SourceContext_descriptor_; + protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::file_level_metadata[0].descriptor; } const SourceContext& SourceContext::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); + protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults(); 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,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_file_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -214,7 +209,6 @@ bool SourceContext::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -242,7 +236,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(), @@ -257,9 +251,9 @@ void SourceContext::SerializeWithCachedSizes( ::google::protobuf::uint8* SourceContext::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +272,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 +288,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 +297,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 +322,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,34 +335,38 @@ 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; + protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::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) { file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name) } +#if LANG_CXX11 +void SourceContext::set_file_name(::std::string&& value) { + + file_name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceContext.file_name) +} +#endif void SourceContext::set_file_name(const char* value) { file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -408,9 +398,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..10888385 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -8,37 +8,48 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3001000 +#if GOOGLE_PROTOBUF_VERSION < 3002000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #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; +LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { +namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto { // 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; +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::uint32 offsets[]; + static void InitDefaultsImpl(); + static void Shutdown(); +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaults(); +} // namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto // =================================================================== @@ -57,59 +68,66 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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; void set_file_name(const ::std::string& value); + #if LANG_CXX11 + void set_file_name(::std::string&& value); + #endif void set_file_name(const char* value); void set_file_name(const char* value, size_t size); ::std::string* mutable_file_name(); @@ -122,15 +140,8 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::ArenaStringPtr file_name_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::TableStruct; }; -extern ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> SourceContext_default_instance_; - // =================================================================== @@ -139,19 +150,27 @@ 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) { file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name) } +#if LANG_CXX11 +inline void SourceContext::set_file_name(::std::string&& value) { + + file_name_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceContext.file_name) +} +#endif inline void SourceContext::set_file_name(const char* value) { file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); @@ -183,13 +202,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..1350085c 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -19,193 +19,174 @@ namespace google { namespace protobuf { - -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; -struct ValueOneofInstance { +class StructDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Struct> { +} _Struct_default_instance_; +class ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Value> { + public: int null_value_; double number_value_; ::google::protobuf::internal::ArenaStringPtr string_value_; 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_instance_; +class ListValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ListValue> { +} _ListValue_default_instance_; -} // namespace +namespace protobuf_google_2fprotobuf_2fstruct_2eproto { -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] = { - 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_), - 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] = { - 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); -} +namespace { + +::google::protobuf::Metadata file_level_metadata[4]; +const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[1]; + +} // namespace + +const ::google::protobuf::uint32 TableStruct::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_), + ~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_instance_), null_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), number_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), string_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), bool_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), struct_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), list_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, kind_), + ~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_), +}; + +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Struct)}, + { 5, -1, sizeof(Value)}, + { 16, -1, sizeof(ListValue)}, +}; + +static ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_Struct_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_Value_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_ListValue_default_instance_), +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/struct.proto", schemas, file_default_instances, TableStruct::offsets, 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 = protobuf_google_2fprotobuf_2fstruct_2eproto::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_; +void TableStruct::Shutdown() { + _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() { +void TableStruct::InitDefaultsImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::internal::GetEmptyString(); - Struct_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - Value_default_instance_.DefaultConstruct(); - Value_default_oneof_instance_ = new ValueOneofInstance(); - ListValue_default_instance_.DefaultConstruct(); - Struct_default_instance_.get_mutable()->InitAsDefaultInstance(); - Value_default_instance_.get_mutable()->InitAsDefaultInstance(); - ListValue_default_instance_.get_mutable()->InitAsDefaultInstance(); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_once_); -void protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl); + ::google::protobuf::internal::InitProtobufDefaults(); + _Struct_default_instance_.DefaultConstruct(); + _Value_default_instance_.DefaultConstruct(); + _ListValue_default_instance_.DefaultConstruct(); + _Value_default_instance_.null_value_ = 0; + _Value_default_instance_.number_value_ = 0; + _Value_default_instance_.string_value_.UnsafeSetDefault( + &::google::protobuf::internal::GetEmptyStringAlreadyInited()); + _Value_default_instance_.bool_value_ = false; + _Value_default_instance_.struct_value_ = const_cast< ::google::protobuf::Struct*>( + ::google::protobuf::Struct::internal_default_instance()); + _Value_default_instance_.list_value_ = const_cast< ::google::protobuf::ListValue*>( + ::google::protobuf::ListValue::internal_default_instance()); } -void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); +void InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); +} +void AddDescriptorsImpl() { + InitDefaults(); + 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); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_once_); -void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_once_, - &protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl); +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); } -} static_descriptor_initializer_google_2fprotobuf_2fstruct_2eproto_; +} static_descriptor_initializer; + +} // namespace protobuf_google_2fprotobuf_2fstruct_2eproto + const ::google::protobuf::EnumDescriptor* NullValue_descriptor() { - protobuf_AssignDescriptorsOnce(); - return NullValue_descriptor_; + protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_enum_descriptors[0]; } bool NullValue_IsValid(int value) { switch (value) { @@ -217,15 +198,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 +211,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_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Struct) } @@ -244,29 +222,32 @@ Struct::Struct(::google::protobuf::Arena* arena) _internal_metadata_(arena), fields_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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 = protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[0].descriptor; + fields_.SetAssignDescriptorCallback( + protobuf_google_2fprotobuf_2fstruct_2eproto::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 = protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[0].descriptor; fields_.SetAssignDescriptorCallback( - protobuf_AssignDescriptorsOnce); + protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce); fields_.SetEntryDescriptor( - &::google::protobuf::Struct_FieldsEntry_descriptor_); + &Struct_FieldsEntry_descriptor); _cached_size_ = 0; } @@ -295,17 +276,15 @@ void Struct::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Struct::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Struct_descriptor_; + protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[1].descriptor; } const Struct& Struct::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); 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 +300,15 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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()]); @@ -435,7 +412,7 @@ void Struct::SerializeWithCachedSizes( ::google::protobuf::uint8* Struct::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Struct) // map<string, .google.protobuf.Value> fields = 1; if (!this->fields().empty()) { @@ -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; + protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fstruct_2eproto::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_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Value) } @@ -656,29 +623,47 @@ Value::Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -715,17 +700,15 @@ void Value::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Value::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Value_descriptor_; + protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[2].descriptor; } const Value& Value::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); 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,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -796,13 +780,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(17u)) { clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -811,13 +795,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_string_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -827,13 +811,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(32u)) { clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -842,33 +826,30 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 +877,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 +898,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); @@ -939,20 +920,20 @@ void Value::SerializeWithCachedSizes( ::google::protobuf::uint8* Value::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +944,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 +972,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 +1022,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 +1031,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 +1081,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 +1093,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 +1110,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; + protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fstruct_2eproto::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 +1150,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 +1179,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 +1196,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 +1288,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 +1317,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 +1405,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 +1502,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 +1512,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_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ListValue) } @@ -1552,21 +1523,18 @@ ListValue::ListValue(::google::protobuf::Arena* arena) _internal_metadata_(arena), values_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -1599,17 +1567,15 @@ void ListValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* ListValue::descriptor() { - protobuf_AssignDescriptorsOnce(); - return ListValue_descriptor_; + protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[3].descriptor; } const ListValue& ListValue::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults(); 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 +1591,21 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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; } @@ -1680,7 +1644,7 @@ void ListValue::SerializeWithCachedSizes( ::google::protobuf::uint8* ListValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ListValue) // repeated .google.protobuf.Value values = 1; for (unsigned int i = 0, n = this->values_size(); i < n; i++) { @@ -1717,7 +1681,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 +1690,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 +1712,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 +1724,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 +1740,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; + protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[3]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -1826,9 +1781,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..043f0c32 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -8,42 +8,57 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3001000 +#if GOOGLE_PROTOBUF_VERSION < 3002000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #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 { - -// 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 ListValueDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern ListValueDefaultTypeInternal _ListValue_default_instance_; class Struct; +class StructDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern StructDefaultTypeInternal _Struct_default_instance_; class Value; +class ValueDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern ValueDefaultTypeInternal _Value_default_instance_; +} // namespace protobuf +} // namespace google + +namespace google { +namespace protobuf { + +namespace protobuf_google_2fprotobuf_2fstruct_2eproto { +// Internal implementation detail -- do not call these. +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::uint32 offsets[]; + static void InitDefaultsImpl(); + static void Shutdown(); +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaults(); +} // namespace protobuf_google_2fprotobuf_2fstruct_2eproto enum NullValue { NULL_VALUE = 0, @@ -67,6 +82,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 +97,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +158,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 ---------------------------------------------------- @@ -169,15 +193,8 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > fields_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl(); - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct; }; -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 +209,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 +228,44 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +280,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 +295,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 +304,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 +321,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 +330,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 +348,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 +369,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(); @@ -373,15 +396,8 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ mutable int _cached_size_; ::google::protobuf::uint32 _oneof_case_[1]; - friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl(); - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct; }; -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 +412,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +473,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 ---------------------------------------------------- @@ -478,21 +500,16 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value > values_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct; }; -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 +530,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 +563,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 +592,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 +609,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 +701,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 +730,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 +818,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 +915,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 +949,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/atomicops.h b/src/google/protobuf/stubs/atomicops.h index 10a71ed4..75aee306 100644 --- a/src/google/protobuf/stubs/atomicops.h +++ b/src/google/protobuf/stubs/atomicops.h @@ -123,8 +123,8 @@ Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, // ensure that no later memory access can be reordered ahead of the operation. // "Release" operations ensure that no previous memory access can be reordered // after the operation. "Barrier" operations have both "Acquire" and "Release" -// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory -// access. +// semantics. A MemoryBarrierInternal() has "Barrier" semantics, but does no +// memory access. Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value); @@ -132,10 +132,10 @@ Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value); -#if defined(__MINGW32__) && defined(MemoryBarrier) -#undef MemoryBarrier -#endif -void MemoryBarrier(); +// This function was renamed from MemoryBarrier to MemoryBarrierInternal +// because MemoryBarrier is a define in Windows ARM builds and we do not +// undefine it because we call it from this function. +void MemoryBarrierInternal(); void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value); void Acquire_Store(volatile Atomic32* ptr, Atomic32 value); void Release_Store(volatile Atomic32* ptr, Atomic32 value); @@ -180,7 +180,7 @@ Atomic64 Release_Load(volatile const Atomic64* ptr); #include <google/protobuf/stubs/atomicops_internals_tsan.h> // MSVC. #elif defined(_MSC_VER) -#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64) +#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64) || defined(GOOGLE_PROTOBUF_ARCH_ARM) #include <google/protobuf/stubs/atomicops_internals_x86_msvc.h> #else #error GOOGLE_PROTOBUF_ATOMICOPS_ERROR @@ -194,14 +194,6 @@ Atomic64 Release_Load(volatile const Atomic64* ptr); #elif defined(GOOGLE_PROTOBUF_OS_AIX) #include <google/protobuf/stubs/atomicops_internals_power.h> -// Apple. -#elif defined(GOOGLE_PROTOBUF_OS_APPLE) -#if __has_feature(cxx_atomic) || _GNUC_VER >= 407 -#include <google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h> -#else // __has_feature(cxx_atomic) || _GNUC_VER >= 407 -#include <google/protobuf/stubs/atomicops_internals_macosx.h> -#endif // __has_feature(cxx_atomic) || _GNUC_VER >= 407 - // GCC. #elif defined(__GNUC__) #if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64) @@ -221,6 +213,9 @@ Atomic64 Release_Load(volatile const Atomic64* ptr); #elif defined(GOOGLE_PROTOBUF_ARCH_POWER) #include <google/protobuf/stubs/atomicops_internals_power.h> #elif defined(__native_client__) +// The static_asserts in the C++11 atomics implementation cause it to fail +// with certain compilers, e.g. nvcc on macOS. Don't use elsewhere unless +// the TODO in that file is addressed. #include <google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h> #elif defined(GOOGLE_PROTOBUF_ARCH_PPC) #include <google/protobuf/stubs/atomicops_internals_ppc_gcc.h> diff --git a/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h b/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h index 0a2d2b89..9a69d21a 100644 --- a/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h @@ -37,7 +37,7 @@ namespace google { namespace protobuf { namespace internal { -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { __asm__ __volatile__ ("dmb ish" ::: "memory"); // NOLINT } @@ -117,9 +117,9 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic32 result = NoBarrier_AtomicIncrement(ptr, increment); - MemoryBarrier(); + MemoryBarrierInternal(); return result; } @@ -128,7 +128,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - MemoryBarrier(); + MemoryBarrierInternal(); return prev; } @@ -136,7 +136,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); return prev; @@ -148,7 +148,7 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { @@ -178,7 +178,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } @@ -253,9 +253,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic64 result = NoBarrier_AtomicIncrement(ptr, increment); - MemoryBarrier(); + MemoryBarrierInternal(); return result; } @@ -264,7 +264,7 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - MemoryBarrier(); + MemoryBarrierInternal(); return prev; } @@ -272,7 +272,7 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); return prev; @@ -284,7 +284,7 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { @@ -314,7 +314,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { } inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } diff --git a/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h b/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h index 90e727b0..6e2de67f 100644 --- a/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h @@ -115,17 +115,17 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; } -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { pLinuxKernelMemoryBarrier(); } inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - MemoryBarrier(); + MemoryBarrierInternal(); *ptr = value; } @@ -135,12 +135,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { Atomic32 value = *ptr; - MemoryBarrier(); + MemoryBarrierInternal(); return value; } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } diff --git a/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h b/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h index 17dfaa51..cd97e0c9 100644 --- a/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h +++ b/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h @@ -110,17 +110,17 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; } -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { __sync_synchronize(); } inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - MemoryBarrier(); + MemoryBarrierInternal(); *ptr = value; } @@ -130,12 +130,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { Atomic32 value = *ptr; - MemoryBarrier(); + MemoryBarrierInternal(); return value; } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } diff --git a/src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h b/src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h index 7bc584eb..44ef9c9e 100644 --- a/src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h +++ b/src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h @@ -52,7 +52,7 @@ typedef volatile std::atomic<Atomic32>* AtomicLocation32; static_assert(sizeof(*(AtomicLocation32) nullptr) == sizeof(Atomic32), "incompatible 32-bit atomic layout"); -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { #if defined(__GLIBCXX__) // Work around libstdc++ bug 51038 where atomic_thread_fence was declared but // not defined, leading to the linker complaining about undefined references. @@ -119,7 +119,7 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { ((AtomicLocation32)ptr)->store(value, std::memory_order_relaxed); - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { @@ -135,7 +135,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return ((AtomicLocation32)ptr)->load(std::memory_order_relaxed); } @@ -202,7 +202,7 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { ((AtomicLocation64)ptr)->store(value, std::memory_order_relaxed); - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { @@ -218,7 +218,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { } inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return ((AtomicLocation64)ptr)->load(std::memory_order_relaxed); } diff --git a/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h b/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h index 7f17b30d..0b0b06ce 100644 --- a/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h @@ -78,7 +78,7 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { __atomic_store_n(ptr, value, __ATOMIC_RELAXED); } -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { __sync_synchronize(); } diff --git a/src/google/protobuf/stubs/atomicops_internals_macosx.h b/src/google/protobuf/stubs/atomicops_internals_macosx.h deleted file mode 100644 index 79633241..00000000 --- a/src/google/protobuf/stubs/atomicops_internals_macosx.h +++ /dev/null @@ -1,225 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 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 file is an internal atomic implementation, use atomicops.h instead. - -#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_ -#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_ - -#include <libkern/OSAtomic.h> - -namespace google { -namespace protobuf { -namespace internal { - -inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - Atomic32 prev_value; - do { - if (OSAtomicCompareAndSwap32(old_value, new_value, - const_cast<Atomic32*>(ptr))) { - return old_value; - } - prev_value = *ptr; - } while (prev_value == old_value); - return prev_value; -} - -inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, - Atomic32 new_value) { - Atomic32 old_value; - do { - old_value = *ptr; - } while (!OSAtomicCompareAndSwap32(old_value, new_value, - const_cast<Atomic32*>(ptr))); - return old_value; -} - -inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - return OSAtomicAdd32(increment, const_cast<Atomic32*>(ptr)); -} - -inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - return OSAtomicAdd32Barrier(increment, const_cast<Atomic32*>(ptr)); -} - -inline void MemoryBarrier() { - OSMemoryBarrier(); -} - -inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - Atomic32 prev_value; - do { - if (OSAtomicCompareAndSwap32Barrier(old_value, new_value, - const_cast<Atomic32*>(ptr))) { - return old_value; - } - prev_value = *ptr; - } while (prev_value == old_value); - return prev_value; -} - -inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - return Acquire_CompareAndSwap(ptr, old_value, new_value); -} - -inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; -} - -inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; - MemoryBarrier(); -} - -inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - MemoryBarrier(); - *ptr = value; -} - -inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { - return *ptr; -} - -inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { - Atomic32 value = *ptr; - MemoryBarrier(); - return value; -} - -inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); - return *ptr; -} - -#ifdef __LP64__ - -// 64-bit implementation on 64-bit platform - -inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - Atomic64 prev_value; - do { - if (OSAtomicCompareAndSwap64(old_value, new_value, - reinterpret_cast<volatile int64_t*>(ptr))) { - return old_value; - } - prev_value = *ptr; - } while (prev_value == old_value); - return prev_value; -} - -inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, - Atomic64 new_value) { - Atomic64 old_value; - do { - old_value = *ptr; - } while (!OSAtomicCompareAndSwap64(old_value, new_value, - reinterpret_cast<volatile int64_t*>(ptr))); - return old_value; -} - -inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, - Atomic64 increment) { - return OSAtomicAdd64(increment, reinterpret_cast<volatile int64_t*>(ptr)); -} - -inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, - Atomic64 increment) { - return OSAtomicAdd64Barrier(increment, - reinterpret_cast<volatile int64_t*>(ptr)); -} - -inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - Atomic64 prev_value; - do { - if (OSAtomicCompareAndSwap64Barrier( - old_value, new_value, reinterpret_cast<volatile int64_t*>(ptr))) { - return old_value; - } - prev_value = *ptr; - } while (prev_value == old_value); - return prev_value; -} - -inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - // The lib kern interface does not distinguish between - // Acquire and Release memory barriers; they are equivalent. - return Acquire_CompareAndSwap(ptr, old_value, new_value); -} - -inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { - *ptr = value; -} - -inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { - *ptr = value; - MemoryBarrier(); -} - -inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { - MemoryBarrier(); - *ptr = value; -} - -inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { - return *ptr; -} - -inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { - Atomic64 value = *ptr; - MemoryBarrier(); - return value; -} - -inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); - return *ptr; -} - -#endif // defined(__LP64__) - -} // namespace internal -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_ diff --git a/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h b/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h index f5837c9e..6ce6820e 100644 --- a/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h @@ -125,8 +125,8 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, // ensure that no later memory access can be reordered ahead of the operation. // "Release" operations ensure that no previous memory access can be reordered // after the operation. "Barrier" operations have both "Acquire" and "Release" -// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory -// access. +// semantics. A MemoryBarrierInternal() has "Barrier" semantics, but does no +// memory access. inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { @@ -149,17 +149,17 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; } -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { __asm__ __volatile__("sync" : : : "memory"); } inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - MemoryBarrier(); + MemoryBarrierInternal(); *ptr = value; } @@ -169,12 +169,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { Atomic32 value = *ptr; - MemoryBarrier(); + MemoryBarrierInternal(); return value; } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } @@ -247,9 +247,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic64 res = NoBarrier_AtomicIncrement(ptr, increment); - MemoryBarrier(); + MemoryBarrierInternal(); return res; } @@ -257,20 +257,20 @@ inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, // ensure that no later memory access can be reordered ahead of the operation. // "Release" operations ensure that no previous memory access can be reordered // after the operation. "Barrier" operations have both "Acquire" and "Release" -// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory -// access. +// semantics. A MemoryBarrierInternal() has "Barrier" semantics, but does no +// memory access. inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { Atomic64 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - MemoryBarrier(); + MemoryBarrierInternal(); return res; } inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { - MemoryBarrier(); + MemoryBarrierInternal(); return NoBarrier_CompareAndSwap(ptr, old_value, new_value); } @@ -280,11 +280,11 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { - MemoryBarrier(); + MemoryBarrierInternal(); *ptr = value; } @@ -294,12 +294,12 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { Atomic64 value = *ptr; - MemoryBarrier(); + MemoryBarrierInternal(); return value; } inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } #endif diff --git a/src/google/protobuf/stubs/atomicops_internals_power.h b/src/google/protobuf/stubs/atomicops_internals_power.h index b8a42f21..cad9f1e3 100644 --- a/src/google/protobuf/stubs/atomicops_internals_power.h +++ b/src/google/protobuf/stubs/atomicops_internals_power.h @@ -93,7 +93,7 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, return result; } -inline void MemoryBarrier(void) { +inline void MemoryBarrierInternal(void) { asm volatile ( " lwsync \n\t" " isync \n\t" diff --git a/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h b/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h index 8231a578..d477dc6d 100644 --- a/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h @@ -97,22 +97,22 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32 *ptr, inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32 *ptr, Atomic32 increment) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic32 res = NoBarrier_AtomicIncrement(ptr, increment); - MemoryBarrier(); + MemoryBarrierInternal(); return res; } inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32 *ptr, Atomic32 old_value, Atomic32 new_value) { Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - MemoryBarrier(); + MemoryBarrierInternal(); return res; } inline Atomic32 Release_CompareAndSwap(volatile Atomic32 *ptr, Atomic32 old_value, Atomic32 new_value) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); return res; } @@ -121,15 +121,15 @@ inline void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value) { *ptr = value; } -inline void MemoryBarrier() { __asm__ __volatile__("sync" : : : "memory"); } +inline void MemoryBarrierInternal() { __asm__ __volatile__("sync" : : : "memory"); } inline void Acquire_Store(volatile Atomic32 *ptr, Atomic32 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic32 *ptr, Atomic32 value) { - MemoryBarrier(); + MemoryBarrierInternal(); *ptr = value; } @@ -137,12 +137,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32 *ptr) { return *ptr; } inline Atomic32 Acquire_Load(volatile const Atomic32 *ptr) { Atomic32 value = *ptr; - MemoryBarrier(); + MemoryBarrierInternal(); return value; } inline Atomic32 Release_Load(volatile const Atomic32 *ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } diff --git a/src/google/protobuf/stubs/atomicops_internals_solaris.h b/src/google/protobuf/stubs/atomicops_internals_solaris.h index d8057ecd..baecb993 100644 --- a/src/google/protobuf/stubs/atomicops_internals_solaris.h +++ b/src/google/protobuf/stubs/atomicops_internals_solaris.h @@ -54,16 +54,16 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, return (Atomic32)atomic_add_32_nv((volatile uint32_t*)ptr, (uint32_t)increment); } -inline void MemoryBarrier(void) { +inline void MemoryBarrierInternal(void) { membar_producer(); membar_consumer(); } inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic32 ret = NoBarrier_AtomicIncrement(ptr, increment); - MemoryBarrier(); + MemoryBarrierInternal(); return ret; } @@ -72,7 +72,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { Atomic32 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - MemoryBarrier(); + MemoryBarrierInternal(); return ret; } @@ -80,7 +80,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { - MemoryBarrier(); + MemoryBarrierInternal(); return NoBarrier_CompareAndSwap(ptr, old_value, new_value); } @@ -129,9 +129,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 incre } inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic64 ret = atomic_add_64_nv((volatile uint64_t*)ptr, increment); - MemoryBarrier(); + MemoryBarrierInternal(); return ret; } @@ -139,14 +139,14 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { Atomic64 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - MemoryBarrier(); + MemoryBarrierInternal(); return ret; } inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { - MemoryBarrier(); + MemoryBarrierInternal(); return NoBarrier_CompareAndSwap(ptr, old_value, new_value); } diff --git a/src/google/protobuf/stubs/atomicops_internals_tsan.h b/src/google/protobuf/stubs/atomicops_internals_tsan.h index 0c903545..676380b1 100644 --- a/src/google/protobuf/stubs/atomicops_internals_tsan.h +++ b/src/google/protobuf/stubs/atomicops_internals_tsan.h @@ -206,7 +206,7 @@ inline Atomic64 Release_CompareAndSwap(volatile Atomic64 *ptr, return cmp; } -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { __tsan_atomic_thread_fence(__tsan_memory_order_seq_cst); } diff --git a/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h b/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h index edccc59d..e80121fd 100644 --- a/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h @@ -119,18 +119,18 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { // 64-bit implementations of memory barrier can be simpler, because it // "mfence" is guaranteed to exist. -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { __asm__ __volatile__("mfence" : : : "memory"); } inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } #else -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { if (AtomicOps_Internalx86CPUFeatures.has_sse2) { __asm__ __volatile__("mfence" : : : "memory"); } else { // mfence is faster but not present on PIII @@ -168,7 +168,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } @@ -225,7 +225,7 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { @@ -262,7 +262,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { } inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } diff --git a/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc b/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc index 741b164f..74a1bd4e 100644 --- a/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc +++ b/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc @@ -44,9 +44,10 @@ namespace google { namespace protobuf { namespace internal { -inline void MemoryBarrier() { - // We use MemoryBarrier from WinNT.h - ::MemoryBarrier(); +inline void MemoryBarrierInternal() { + // On ARM this is a define while on x86/x64 this is + // a function declared in WinNT.h + MemoryBarrier(); } Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, diff --git a/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h b/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h index e53a641f..34d60d98 100644 --- a/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h +++ b/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h @@ -82,7 +82,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } @@ -125,7 +125,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { } inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } diff --git a/src/google/protobuf/stubs/callback.h b/src/google/protobuf/stubs/callback.h index bbd507a8..9ec04979 100644 --- a/src/google/protobuf/stubs/callback.h +++ b/src/google/protobuf/stubs/callback.h @@ -346,6 +346,29 @@ struct InternalConstRef { typedef const base_type& type; }; +template<typename R, typename T> +class MethodResultCallback_0_0 : public ResultCallback<R> { + public: + typedef R (T::*MethodType)(); + MethodResultCallback_0_0(T* object, MethodType method, bool self_deleting) + : object_(object), + method_(method), + self_deleting_(self_deleting) {} + ~MethodResultCallback_0_0() {} + + R Run() { + bool needs_delete = self_deleting_; + R result = (object_->*method_)(); + if (needs_delete) delete this; + return result; + } + + private: + T* object_; + MethodType method_; + bool self_deleting_; +}; + template <typename R, typename T, typename P1, typename P2, typename P3, typename P4, typename P5, typename A1, typename A2> class MethodResultCallback_5_2 : public ResultCallback2<R, A1, A2> { @@ -520,6 +543,13 @@ inline ResultCallback1<R, A1>* NewPermanentCallback( function, false, p1); } +// See MethodResultCallback_0_0 +template <typename R, typename T1, typename T2> +inline ResultCallback<R>* NewPermanentCallback( + T1* object, R (T2::*function)()) { + return new internal::MethodResultCallback_0_0<R, T1>(object, function, false); +} + // See MethodResultCallback_5_2 template <typename R, typename T, typename P1, typename P2, typename P3, typename P4, typename P5, typename A1, typename A2> diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc index 54dbafab..14655916 100644 --- a/src/google/protobuf/stubs/common.cc +++ b/src/google/protobuf/stubs/common.cc @@ -108,11 +108,17 @@ string VersionString(int version) { // =================================================================== // emulates google3/base/logging.cc +// If the minimum logging level is not set, we default to logging messages for +// all levels. +#ifndef GOOGLE_PROTOBUF_MIN_LOG_LEVEL +#define GOOGLE_PROTOBUF_MIN_LOG_LEVEL LOGLEVEL_INFO +#endif + namespace internal { + #if defined(__ANDROID__) inline void DefaultLogHandler(LogLevel level, const char* filename, int line, const string& message) { -#ifdef GOOGLE_PROTOBUF_MIN_LOG_LEVEL if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) { return; } @@ -143,11 +149,14 @@ inline void DefaultLogHandler(LogLevel level, const char* filename, int line, __android_log_write(ANDROID_LOG_FATAL, "libprotobuf-native", "terminating.\n"); } -#endif } + #else void DefaultLogHandler(LogLevel level, const char* filename, int line, const string& message) { + if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) { + return; + } static const char* level_names[] = { "INFO", "WARNING", "ERROR", "FATAL" }; // We use fprintf() instead of cerr because we want this to work at static diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 43e88ff2..d2611498 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -96,24 +96,27 @@ namespace internal { // The current version, represented as a single integer to make comparison // easier: major * 10^6 + minor * 10^3 + micro -#define GOOGLE_PROTOBUF_VERSION 3001000 +#define GOOGLE_PROTOBUF_VERSION 3002000 + +// A suffix string for alpha, beta or rc releases. Empty for stable releases. +#define GOOGLE_PROTOBUF_VERSION_SUFFIX "" // The minimum library version which works with the current version of the // headers. -#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3001000 +#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3002000 // The minimum header version which works with the current version of // the library. This constant should only be used by protoc's C++ code // generator. -static const int kMinHeaderVersionForLibrary = 3001000; +static const int kMinHeaderVersionForLibrary = 3002000; // The minimum protoc version which works with the current version of the // headers. -#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3001000 +#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3002000 // The minimum header version which works with the current version of // protoc. This constant should only be used in VerifyVersion(). -static const int kMinHeaderVersionForProtoc = 3001000; +static const int kMinHeaderVersionForProtoc = 3002000; // Verifies that the headers and libraries are compatible. Use the macro // below to call this. diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h index 4eac7d5d..bf0b88b4 100644 --- a/src/google/protobuf/stubs/hash.h +++ b/src/google/protobuf/stubs/hash.h @@ -41,15 +41,10 @@ #define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1 #define GOOGLE_PROTOBUF_HAVE_HASH_SET 1 -// Android -#if defined(__ANDROID__) -# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP -# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP - // Use C++11 unordered_{map|set} if available. -#elif ((_LIBCPP_STD_VER >= 11) || \ - (((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && \ - (__GLIBCXX__ > 20090421))) +#if ((_LIBCPP_STD_VER >= 11) || \ + (((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && \ + (__GLIBCXX__ > 20090421))) # define GOOGLE_PROTOBUF_HAS_CXX11_HASH // For XCode >= 4.6: the compiler is clang with libc++. 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/stubs/platform_macros.h b/src/google/protobuf/stubs/platform_macros.h index 8b7f224f..7a54060d 100644 --- a/src/google/protobuf/stubs/platform_macros.h +++ b/src/google/protobuf/stubs/platform_macros.h @@ -47,7 +47,7 @@ #elif defined(__QNX__) #define GOOGLE_PROTOBUF_ARCH_ARM_QNX 1 #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 -#elif defined(__ARMEL__) +#elif defined(_M_ARM) || defined(__ARMEL__) #define GOOGLE_PROTOBUF_ARCH_ARM 1 #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 #elif defined(__aarch64__) diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 376be5f7..d37e8130 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -60,8 +60,12 @@ #endif #else #include <sys/param.h> // __BYTE_ORDER + #if defined(__OpenBSD__) + #include <endian.h> + #endif #if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \ - (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)) && \ + (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || \ + (defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN)) && \ !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) #define PROTOBUF_LITTLE_ENDIAN 1 #endif @@ -93,6 +97,15 @@ // =================================================================== // from google3/base/port.h + +#if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || \ + (defined(_MSC_VER) && _MSC_VER >= 1900)) +// Define this to 1 if the code is compiled in C++11 mode; leave it +// undefined otherwise. Do NOT define it to 0 -- that causes +// '#ifdef LANG_CXX11' to behave differently from '#if LANG_CXX11'. +#define LANG_CXX11 1 +#endif + namespace google { namespace protobuf { @@ -441,7 +454,6 @@ class BigEndian { } }; - } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index 4fa8e99f..15b6e53f 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -981,7 +981,7 @@ static const char two_ASCII_digits[100][2] = { }; char* FastUInt32ToBufferLeft(uint32 u, char* buffer) { - int digits; + uint32 digits; const char *ASCII_digits = NULL; // The idea of this implementation is to trim the number of divides to as few // as possible by using multiplication and subtraction rather than mod (%), diff --git a/src/google/protobuf/test_messages_proto3.proto b/src/google/protobuf/test_messages_proto3.proto new file mode 100644 index 00000000..79230334 --- /dev/null +++ b/src/google/protobuf/test_messages_proto3.proto @@ -0,0 +1,227 @@ +// 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. +// +// Test schema for proto3 messages. This test schema is used by: +// +// - benchmarks +// - fuzz tests +// - conformance tests +// + +syntax = "proto3"; + +package protobuf_test_messages.proto3; +option java_package = "com.google.protobuf_test_messages.proto3"; + +// This is the default, but we specify it here explicitly. +option optimize_for = SPEED; + +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option cc_enable_arenas = true; + +// This proto includes every type of field in both singular and repeated +// forms. +// +// Also, crucially, all messages and enums in this file are eventually +// submessages of this message. So for example, a fuzz test of TestAllTypes +// could trigger bugs that occur in any message type in this file. We verify +// this stays true in a unit test. +message TestAllTypes { + message NestedMessage { + int32 a = 1; + TestAllTypes corecursive = 2; + } + + enum NestedEnum { + FOO = 0; + BAR = 1; + BAZ = 2; + NEG = -1; // Intentionally negative. + } + + // Singular + int32 optional_int32 = 1; + int64 optional_int64 = 2; + uint32 optional_uint32 = 3; + uint64 optional_uint64 = 4; + sint32 optional_sint32 = 5; + sint64 optional_sint64 = 6; + fixed32 optional_fixed32 = 7; + fixed64 optional_fixed64 = 8; + sfixed32 optional_sfixed32 = 9; + sfixed64 optional_sfixed64 = 10; + float optional_float = 11; + double optional_double = 12; + bool optional_bool = 13; + string optional_string = 14; + bytes optional_bytes = 15; + + NestedMessage optional_nested_message = 18; + ForeignMessage optional_foreign_message = 19; + + NestedEnum optional_nested_enum = 21; + ForeignEnum optional_foreign_enum = 22; + + string optional_string_piece = 24 [ctype=STRING_PIECE]; + string optional_cord = 25 [ctype=CORD]; + + TestAllTypes recursive_message = 27; + + // Repeated + repeated int32 repeated_int32 = 31; + repeated int64 repeated_int64 = 32; + repeated uint32 repeated_uint32 = 33; + repeated uint64 repeated_uint64 = 34; + repeated sint32 repeated_sint32 = 35; + repeated sint64 repeated_sint64 = 36; + repeated fixed32 repeated_fixed32 = 37; + repeated fixed64 repeated_fixed64 = 38; + repeated sfixed32 repeated_sfixed32 = 39; + repeated sfixed64 repeated_sfixed64 = 40; + repeated float repeated_float = 41; + repeated double repeated_double = 42; + repeated bool repeated_bool = 43; + repeated string repeated_string = 44; + repeated bytes repeated_bytes = 45; + + repeated NestedMessage repeated_nested_message = 48; + repeated ForeignMessage repeated_foreign_message = 49; + + repeated NestedEnum repeated_nested_enum = 51; + repeated ForeignEnum repeated_foreign_enum = 52; + + repeated string repeated_string_piece = 54 [ctype=STRING_PIECE]; + repeated string repeated_cord = 55 [ctype=CORD]; + + // Map + map < int32, int32> map_int32_int32 = 56; + map < int64, int64> map_int64_int64 = 57; + map < uint32, uint32> map_uint32_uint32 = 58; + map < uint64, uint64> map_uint64_uint64 = 59; + map < sint32, sint32> map_sint32_sint32 = 60; + map < sint64, sint64> map_sint64_sint64 = 61; + map < fixed32, fixed32> map_fixed32_fixed32 = 62; + map < fixed64, fixed64> map_fixed64_fixed64 = 63; + map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64; + map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65; + map < int32, float> map_int32_float = 66; + map < int32, double> map_int32_double = 67; + map < bool, bool> map_bool_bool = 68; + map < string, string> map_string_string = 69; + map < string, bytes> map_string_bytes = 70; + map < string, NestedMessage> map_string_nested_message = 71; + map < string, ForeignMessage> map_string_foreign_message = 72; + map < string, NestedEnum> map_string_nested_enum = 73; + map < string, ForeignEnum> map_string_foreign_enum = 74; + + oneof oneof_field { + uint32 oneof_uint32 = 111; + NestedMessage oneof_nested_message = 112; + string oneof_string = 113; + bytes oneof_bytes = 114; + bool oneof_bool = 115; + uint64 oneof_uint64 = 116; + float oneof_float = 117; + double oneof_double = 118; + NestedEnum oneof_enum = 119; + } + + // Well-known types + google.protobuf.BoolValue optional_bool_wrapper = 201; + google.protobuf.Int32Value optional_int32_wrapper = 202; + google.protobuf.Int64Value optional_int64_wrapper = 203; + google.protobuf.UInt32Value optional_uint32_wrapper = 204; + google.protobuf.UInt64Value optional_uint64_wrapper = 205; + google.protobuf.FloatValue optional_float_wrapper = 206; + google.protobuf.DoubleValue optional_double_wrapper = 207; + google.protobuf.StringValue optional_string_wrapper = 208; + google.protobuf.BytesValue optional_bytes_wrapper = 209; + + repeated google.protobuf.BoolValue repeated_bool_wrapper = 211; + repeated google.protobuf.Int32Value repeated_int32_wrapper = 212; + repeated google.protobuf.Int64Value repeated_int64_wrapper = 213; + repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214; + repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215; + repeated google.protobuf.FloatValue repeated_float_wrapper = 216; + repeated google.protobuf.DoubleValue repeated_double_wrapper = 217; + repeated google.protobuf.StringValue repeated_string_wrapper = 218; + repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219; + + google.protobuf.Duration optional_duration = 301; + google.protobuf.Timestamp optional_timestamp = 302; + google.protobuf.FieldMask optional_field_mask = 303; + google.protobuf.Struct optional_struct = 304; + google.protobuf.Any optional_any = 305; + google.protobuf.Value optional_value = 306; + + repeated google.protobuf.Duration repeated_duration = 311; + repeated google.protobuf.Timestamp repeated_timestamp = 312; + repeated google.protobuf.FieldMask repeated_fieldmask = 313; + repeated google.protobuf.Struct repeated_struct = 324; + repeated google.protobuf.Any repeated_any = 315; + repeated google.protobuf.Value repeated_value = 316; + + // Test field-name-to-JSON-name convention. + // (protobuf says names can be any valid C/C++ identifier.) + int32 fieldname1 = 401; + int32 field_name2 = 402; + int32 _field_name3 = 403; + int32 field__name4_ = 404; + int32 field0name5 = 405; + int32 field_0_name6 = 406; + int32 fieldName7 = 407; + int32 FieldName8 = 408; + int32 field_Name9 = 409; + int32 Field_Name10 = 410; + int32 FIELD_NAME11 = 411; + int32 FIELD_name12 = 412; + int32 __field_name13 = 413; + int32 __Field_name14 = 414; + int32 field__name15 = 415; + int32 field__Name16 = 416; + int32 field_name17__ = 417; + int32 Field_name18__ = 418; +} + +message ForeignMessage { + int32 c = 1; +} + +enum ForeignEnum { + FOREIGN_FOO = 0; + FOREIGN_BAR = 1; + FOREIGN_BAZ = 2; +} 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..778b878e 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()); @@ -1638,54 +1646,6 @@ void TextFormat::Printer::PrintFieldValueToString( PrintFieldValue(message, message.GetReflection(), field, index, generator); } -class MapEntryMessageComparator { - public: - explicit MapEntryMessageComparator(const Descriptor* descriptor) - : field_(descriptor->field(0)) {} - - bool operator()(const Message* a, const Message* b) { - const Reflection* reflection = a->GetReflection(); - switch (field_->cpp_type()) { - case FieldDescriptor::CPPTYPE_BOOL: { - bool first = reflection->GetBool(*a, field_); - bool second = reflection->GetBool(*b, field_); - return first < second; - } - case FieldDescriptor::CPPTYPE_INT32: { - int32 first = reflection->GetInt32(*a, field_); - int32 second = reflection->GetInt32(*b, field_); - return first < second; - } - case FieldDescriptor::CPPTYPE_INT64: { - int64 first = reflection->GetInt64(*a, field_); - int64 second = reflection->GetInt64(*b, field_); - return first < second; - } - case FieldDescriptor::CPPTYPE_UINT32: { - uint32 first = reflection->GetUInt32(*a, field_); - uint32 second = reflection->GetUInt32(*b, field_); - return first < second; - } - case FieldDescriptor::CPPTYPE_UINT64: { - uint64 first = reflection->GetUInt64(*a, field_); - uint64 second = reflection->GetUInt64(*b, field_); - return first < second; - } - case FieldDescriptor::CPPTYPE_STRING: { - string first = reflection->GetString(*a, field_); - string second = reflection->GetString(*b, field_); - return first < second; - } - default: - GOOGLE_LOG(DFATAL) << "Invalid key for map field."; - return true; - } - } - - private: - const FieldDescriptor* field_; -}; - void TextFormat::Printer::PrintField(const Message& message, const Reflection* reflection, const FieldDescriptor* field, @@ -1706,19 +1666,10 @@ void TextFormat::Printer::PrintField(const Message& message, count = 1; } - std::vector<const Message*> sorted_map_field; - if (field->is_map()) { - const RepeatedPtrField<Message>& map_field = - reflection->GetRepeatedPtrField<Message>(message, field); - for (RepeatedPtrField<Message>::const_pointer_iterator it = - map_field.pointer_begin(); - it != map_field.pointer_end(); ++it) { - sorted_map_field.push_back(*it); - } - - MapEntryMessageComparator comparator(field->message_type()); - std::stable_sort(sorted_map_field.begin(), sorted_map_field.end(), - comparator); + std::vector<const Message*> map_entries; + const bool is_map = field->is_map(); + if (is_map) { + map_entries = DynamicMapSorter::Sort(message, count, reflection, field); } for (int j = 0; j < count; ++j) { @@ -1731,9 +1682,8 @@ void TextFormat::Printer::PrintField(const Message& message, custom_printers_, field, default_field_value_printer_.get()); const Message& sub_message = field->is_repeated() - ? (field->is_map() - ? *sorted_map_field[j] - : reflection->GetRepeatedMessage(message, field, j)) + ? (is_map ? *map_entries[j] + : reflection->GetRepeatedMessage(message, field, j)) : reflection->GetMessage(message, field); generator.Print( printer->PrintMessageStart( 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..e21117b6 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -19,110 +19,103 @@ namespace google { namespace protobuf { +class TimestampDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> { +} _Timestamp_default_instance_; + +namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto { + namespace { -const ::google::protobuf::Descriptor* Timestamp_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Timestamp_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace +const ::google::protobuf::uint32 TableStruct::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_), +}; -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] = { - 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_)); -} +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Timestamp)}, +}; + +static ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_Timestamp_default_instance_), +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/timestamp.proto", schemas, file_default_instances, TableStruct::offsets, 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_; +void TableStruct::Shutdown() { + _Timestamp_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } -void protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl() { +void TableStruct::InitDefaultsImpl() { 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); +void InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); } -void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); +void AddDescriptorsImpl() { + InitDefaults(); + 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); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_once_); -void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_once_, - &protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl); +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto(); +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); } -} static_descriptor_initializer_google_2fprotobuf_2ftimestamp_2eproto_; +} static_descriptor_initializer; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace +} // namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto // =================================================================== @@ -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_google_2fprotobuf_2ftimestamp_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Timestamp) } @@ -142,21 +137,20 @@ Timestamp::Timestamp(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); + protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -191,44 +185,23 @@ void Timestamp::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Timestamp::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Timestamp_descriptor_; + protobuf_google_2fprotobuf_2ftimestamp_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftimestamp_2eproto::file_level_metadata[0].descriptor; } const Timestamp& Timestamp::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); + protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaults(); 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,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -251,14 +225,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(16u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -266,7 +239,6 @@ bool Timestamp::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -294,12 +266,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); } @@ -309,14 +281,14 @@ void Timestamp::SerializeWithCachedSizes( ::google::protobuf::uint8* Timestamp::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +301,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 +324,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 +333,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 +360,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 +372,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 +389,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; + protobuf_google_2fprotobuf_2ftimestamp_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftimestamp_2eproto::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 +414,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 +428,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..e6fc09a1 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -8,37 +8,48 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3001000 +#if GOOGLE_PROTOBUF_VERSION < 3002000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #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; +LIBPROTOBUF_EXPORT extern TimestampDefaultTypeInternal _Timestamp_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { +namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto { // 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; +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::uint32 offsets[]; + static void InitDefaultsImpl(); + static void Shutdown(); +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaults(); +} // namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto // =================================================================== @@ -54,47 +65,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +126,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; @@ -137,15 +154,8 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro ::google::protobuf::int64 seconds_; ::google::protobuf::int32 nanos_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftimestamp_2eproto::TableStruct; }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> Timestamp_default_instance_; - // =================================================================== @@ -154,7 +164,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 +178,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 +192,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..8bf57ecf 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -19,284 +19,310 @@ namespace google { namespace protobuf { +class TypeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Type> { +} _Type_default_instance_; +class FieldDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Field> { +} _Field_default_instance_; +class EnumDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Enum> { +} _Enum_default_instance_; +class EnumValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValue> { +} _EnumValue_default_instance_; +class OptionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Option> { +} _Option_default_instance_; + +namespace protobuf_google_2fprotobuf_2ftype_2eproto { + 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] = { - 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] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, kind_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, cardinality_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, number_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, type_url_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, oneof_index_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, packed_), - 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] = { - 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] = { - 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] = { - 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); -} +const ::google::protobuf::uint32 TableStruct::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_), + ~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_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, type_url_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, oneof_index_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, packed_), + 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_), + ~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_), + ~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_), + ~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_), +}; + +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 ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_Type_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_Field_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_Enum_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValue_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_Option_default_instance_), +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/type.proto", schemas, file_default_instances, TableStruct::offsets, 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_; +void TableStruct::Shutdown() { + _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() { +void TableStruct::InitDefaultsImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); - ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); - ::google::protobuf::internal::GetEmptyString(); - Type_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - Field_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - Enum_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - EnumValue_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - Option_default_instance_.DefaultConstruct(); - Type_default_instance_.get_mutable()->InitAsDefaultInstance(); - Field_default_instance_.get_mutable()->InitAsDefaultInstance(); - Enum_default_instance_.get_mutable()->InitAsDefaultInstance(); - EnumValue_default_instance_.get_mutable()->InitAsDefaultInstance(); - Option_default_instance_.get_mutable()->InitAsDefaultInstance(); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_once_); -void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl); -} -void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; + ::google::protobuf::internal::InitProtobufDefaults(); + ::google::protobuf::protobuf_google_2fprotobuf_2fany_2eproto::InitDefaults(); + ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults(); + _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()); +} - protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); +void InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); +} +void AddDescriptorsImpl() { + InitDefaults(); + 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(); - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto); + ::google::protobuf::protobuf_google_2fprotobuf_2fany_2eproto::AddDescriptors(); + ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::AddDescriptors(); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_once_); -void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_once_, - &protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl); +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); } -} static_descriptor_initializer_google_2fprotobuf_2ftype_2eproto_; -const ::google::protobuf::EnumDescriptor* Syntax_descriptor() { - protobuf_AssignDescriptorsOnce(); - return Syntax_descriptor_; +} static_descriptor_initializer; + +} // namespace protobuf_google_2fprotobuf_2ftype_2eproto + +const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor() { + protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftype_2eproto::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_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftype_2eproto::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_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftype_2eproto::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_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Type) } @@ -356,30 +384,38 @@ Type::Type(::google::protobuf::Arena* arena) oneofs_(arena), options_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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_; } } @@ -412,30 +448,30 @@ void Type::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Type::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Type_descriptor_; + protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[0].descriptor; } const Type& Type::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); 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,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -460,31 +497,27 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(26u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_oneofs())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -495,45 +528,39 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(48u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -542,7 +569,6 @@ bool Type::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -570,7 +596,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(), @@ -587,7 +613,7 @@ void Type::SerializeWithCachedSizes( } // repeated string oneofs = 3; - for (int i = 0; i < this->oneofs_size(); i++) { + for (int i = 0, n = this->oneofs_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->oneofs(i).data(), this->oneofs(i).length(), ::google::protobuf::internal::WireFormatLite::SERIALIZE, @@ -602,13 +628,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); @@ -619,9 +645,9 @@ void Type::SerializeWithCachedSizes( ::google::protobuf::uint8* Type::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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(), @@ -640,7 +666,7 @@ void Type::SerializeWithCachedSizes( } // repeated string oneofs = 3; - for (int i = 0; i < this->oneofs_size(); i++) { + for (int i = 0, n = this->oneofs_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->oneofs(i).data(), this->oneofs(i).length(), ::google::protobuf::internal::WireFormatLite::SERIALIZE, @@ -656,14 +682,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 +703,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(); @@ -711,7 +717,7 @@ size_t Type::ByteSizeLong() const { // repeated string oneofs = 3; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->oneofs_size()); - for (int i = 0; i < this->oneofs_size(); i++) { + for (int i = 0, n = this->oneofs_size(); i < n; i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->oneofs(i)); } @@ -727,6 +733,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 +762,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 +771,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 +804,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 +816,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 +831,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; + protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftype_2eproto::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) { @@ -946,6 +963,12 @@ void Type::set_oneofs(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) oneofs_.Mutable(index)->assign(value); } +#if LANG_CXX11 +void Type::set_oneofs(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) + oneofs_.Mutable(index)->assign(std::move(value)); +} +#endif void Type::set_oneofs(int index, const char* value) { oneofs_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.Type.oneofs) @@ -963,6 +986,12 @@ void Type::add_oneofs(const ::std::string& value) { oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) } +#if LANG_CXX11 +void Type::add_oneofs(::std::string&& value) { + oneofs_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) +} +#endif void Type::add_oneofs(const char* value) { oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.Type.oneofs) @@ -1012,7 +1041,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 +1092,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 +1106,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 +1125,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_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Field) } @@ -1188,21 +1136,41 @@ Field::Field(::google::protobuf::Arena* arena) _internal_metadata_(arena), options_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -1245,49 +1213,28 @@ void Field::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Field::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Field_descriptor_; + protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[1].descriptor; } const Field& Field::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); 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 +1243,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1311,14 +1259,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(16u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1327,14 +1274,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(24u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1342,14 +1288,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(34u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1359,14 +1304,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(50u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1376,14 +1320,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(56u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1391,14 +1334,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(64u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1406,31 +1348,27 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(82u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_json_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1440,14 +1378,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(90u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_default_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1457,7 +1394,6 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1485,24 +1421,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 +1448,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 +1458,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 +1474,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 +1484,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(), @@ -1563,26 +1499,26 @@ void Field::SerializeWithCachedSizes( ::google::protobuf::uint8* Field::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +1529,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 +1540,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 +1557,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 +1568,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 +1587,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 +1666,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 +1675,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 +1705,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 +1724,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 +1736,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 +1751,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; + protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftype_2eproto::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 +1786,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 +1800,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 +1814,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 +1880,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 +1946,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 +1960,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 +2004,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 +2070,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 +2136,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 +2183,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_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Enum) } @@ -2269,30 +2195,37 @@ Enum::Enum(::google::protobuf::Arena* arena) enumvalue_(arena), options_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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 +2241,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_; } } @@ -2325,29 +2258,29 @@ void Enum::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Enum::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Enum_descriptor_; + protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[2].descriptor; } const Enum& Enum::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); 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 +2289,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -2372,60 +2306,53 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(40u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -2434,7 +2361,6 @@ bool Enum::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2462,7 +2388,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 +2410,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); @@ -2501,9 +2427,9 @@ void Enum::SerializeWithCachedSizes( ::google::protobuf::uint8* Enum::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +2454,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 +2475,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 +2497,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 +2526,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 +2535,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 +2567,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 +2579,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 +2594,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; + protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftype_2eproto::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 +2736,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 +2787,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 +2801,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 +2813,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_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValue) } @@ -2908,21 +2824,24 @@ EnumValue::EnumValue(::google::protobuf::Arena* arena) _internal_metadata_(arena), options_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -2958,26 +2877,24 @@ void EnumValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* EnumValue::descriptor() { - protobuf_AssignDescriptorsOnce(); - return EnumValue_descriptor_; + protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[3].descriptor; } const EnumValue& EnumValue::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); 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 +2903,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -3002,14 +2920,13 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(16u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -3017,24 +2934,20 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(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 +2975,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 +2985,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); } @@ -3088,9 +3001,9 @@ void EnumValue::SerializeWithCachedSizes( ::google::protobuf::uint8* EnumValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +3014,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 +3034,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 +3068,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 +3077,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 +3105,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 +3117,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 +3132,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; + protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftype_2eproto::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 +3212,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 +3256,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 +3300,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_google_2fprotobuf_2ftype_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Option) } @@ -3407,23 +3310,27 @@ Option::Option(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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 +3352,7 @@ void Option::SharedDtor() { } name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); - if (this != &Option_default_instance_.get()) { + if (this != internal_default_instance()) { delete value_; } } @@ -3462,17 +3369,15 @@ void Option::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Option::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Option_descriptor_; + protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[4].descriptor; } const Option& Option::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults(); 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 +3385,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 +3397,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -3506,20 +3414,18 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(18u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_value())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -3547,7 +3453,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 +3463,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); @@ -3568,9 +3474,9 @@ void Option::SerializeWithCachedSizes( ::google::protobuf::uint8* Option::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +3487,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 +3502,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 +3525,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 +3534,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 +3561,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 +3573,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 +3590,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; + protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2ftype_2eproto::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 +3667,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 +3718,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..ae816008 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -8,44 +8,69 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3001000 +#if GOOGLE_PROTOBUF_VERSION < 3002000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #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; +LIBPROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_; class Enum; +class EnumDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern EnumDefaultTypeInternal _Enum_default_instance_; class EnumValue; +class EnumValueDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern EnumValueDefaultTypeInternal _EnumValue_default_instance_; class Field; +class FieldDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern FieldDefaultTypeInternal _Field_default_instance_; class Option; +class OptionDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern OptionDefaultTypeInternal _Option_default_instance_; +class SourceContext; +class SourceContextDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; class Type; +class TypeDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern TypeDefaultTypeInternal _Type_default_instance_; +} // namespace protobuf +} // namespace google + +namespace google { +namespace protobuf { + +namespace protobuf_google_2fprotobuf_2ftype_2eproto { +// Internal implementation detail -- do not call these. +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::uint32 offsets[]; + static void InitDefaultsImpl(); + static void Shutdown(); +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaults(); +} // namespace protobuf_google_2fprotobuf_2ftype_2eproto enum Field_Kind { Field_Kind_TYPE_UNKNOWN = 0, @@ -143,47 +168,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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,26 +229,12 @@ 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; - void clear_name(); - static const int kNameFieldNumber = 1; - const ::std::string& name() const; - void set_name(const ::std::string& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); - ::std::string* mutable_name(); - ::std::string* release_name(); - void set_allocated_name(::std::string* name); - ::std::string* unsafe_arena_release_name(); - void unsafe_arena_set_allocated_name( - ::std::string* name); - // repeated .google.protobuf.Field fields = 2; int fields_size() const; void clear_fields(); @@ -237,10 +254,16 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i const ::std::string& oneofs(int index) const; ::std::string* mutable_oneofs(int index); void set_oneofs(int index, const ::std::string& value); + #if LANG_CXX11 + void set_oneofs(int index, ::std::string&& value); + #endif void set_oneofs(int index, const char* value); void set_oneofs(int index, const char* value, size_t size); ::std::string* add_oneofs(); void add_oneofs(const ::std::string& value); + #if LANG_CXX11 + void add_oneofs(::std::string&& value); + #endif void add_oneofs(const char* value); void add_oneofs(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& oneofs() const; @@ -258,7 +281,21 @@ 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; + // string name = 1; + void clear_name(); + static const int kNameFieldNumber = 1; + const ::std::string& name() const; + void set_name(const ::std::string& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); + ::std::string* unsafe_arena_release_name(); + void unsafe_arena_set_allocated_name( + ::std::string* name); + + // .google.protobuf.SourceContext source_context = 5; bool has_source_context() const; void clear_source_context(); static const int kSourceContextFieldNumber = 5; @@ -274,7 +311,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; @@ -294,15 +331,8 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i ::google::protobuf::SourceContext* source_context_; int syntax_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; }; -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 +347,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +408,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 +504,19 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ // accessors ------------------------------------------------------- - // optional .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; - 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; - void clear_number(); - static const int kNumberFieldNumber = 3; - ::google::protobuf::int32 number() const; - void set_number(::google::protobuf::int32 value); + // repeated .google.protobuf.Option options = 9; + int options_size() const; + void clear_options(); + static const int kOptionsFieldNumber = 9; + const ::google::protobuf::Option& options(int index) const; + ::google::protobuf::Option* mutable_options(int index); + ::google::protobuf::Option* add_options(); + ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* + mutable_options(); + const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& + options() const; - // optional string name = 4; + // string name = 4; void clear_name(); static const int kNameFieldNumber = 4; const ::std::string& name() const; @@ -500,7 +530,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,31 +544,7 @@ 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; - 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; - void clear_packed(); - static const int kPackedFieldNumber = 8; - bool packed() const; - void set_packed(bool value); - - // repeated .google.protobuf.Option options = 9; - int options_size() const; - void clear_options(); - static const int kOptionsFieldNumber = 9; - const ::google::protobuf::Option& options(int index) const; - ::google::protobuf::Option* mutable_options(int index); - ::google::protobuf::Option* add_options(); - ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* - mutable_options(); - 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 +558,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; @@ -566,6 +572,36 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ void unsafe_arena_set_allocated_default_value( ::std::string* default_value); + // .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); + + // .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); + + // int32 number = 3; + void clear_number(); + static const int kNumberFieldNumber = 3; + ::google::protobuf::int32 number() const; + void set_number(::google::protobuf::int32 value); + + // 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); + + // bool packed = 8; + void clear_packed(); + static const int kPackedFieldNumber = 8; + bool packed() const; + void set_packed(bool value); + // @@protoc_insertion_point(class_scope:google.protobuf.Field) private: @@ -584,15 +620,8 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ ::google::protobuf::int32 oneof_index_; bool packed_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; }; -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 +636,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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,26 +697,12 @@ 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; - void clear_name(); - static const int kNameFieldNumber = 1; - const ::std::string& name() const; - void set_name(const ::std::string& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); - ::std::string* mutable_name(); - ::std::string* release_name(); - void set_allocated_name(::std::string* name); - ::std::string* unsafe_arena_release_name(); - void unsafe_arena_set_allocated_name( - ::std::string* name); - // repeated .google.protobuf.EnumValue enumvalue = 2; int enumvalue_size() const; void clear_enumvalue(); @@ -706,7 +727,21 @@ 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; + // string name = 1; + void clear_name(); + static const int kNameFieldNumber = 1; + const ::std::string& name() const; + void set_name(const ::std::string& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); + ::std::string* unsafe_arena_release_name(); + void unsafe_arena_set_allocated_name( + ::std::string* name); + + // .google.protobuf.SourceContext source_context = 4; bool has_source_context() const; void clear_source_context(); static const int kSourceContextFieldNumber = 4; @@ -722,7 +757,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; @@ -741,15 +776,8 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i ::google::protobuf::SourceContext* source_context_; int syntax_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; }; -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 +792,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +853,25 @@ 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; + // repeated .google.protobuf.Option options = 3; + int options_size() const; + void clear_options(); + static const int kOptionsFieldNumber = 3; + const ::google::protobuf::Option& options(int index) const; + ::google::protobuf::Option* mutable_options(int index); + ::google::protobuf::Option* add_options(); + ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* + mutable_options(); + const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& + options() const; + + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -839,24 +885,12 @@ 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; void set_number(::google::protobuf::int32 value); - // repeated .google.protobuf.Option options = 3; - int options_size() const; - void clear_options(); - static const int kOptionsFieldNumber = 3; - const ::google::protobuf::Option& options(int index) const; - ::google::protobuf::Option* mutable_options(int index); - ::google::protobuf::Option* add_options(); - ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* - mutable_options(); - const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& - options() const; - // @@protoc_insertion_point(class_scope:google.protobuf.EnumValue) private: @@ -868,15 +902,8 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::int32 number_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; }; -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 +918,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +979,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 +999,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; @@ -992,15 +1025,8 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::Any* value_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct; }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Option> Option_default_instance_; - // =================================================================== @@ -1009,13 +1035,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) { @@ -1124,6 +1150,12 @@ inline void Type::set_oneofs(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) oneofs_.Mutable(index)->assign(value); } +#if LANG_CXX11 +inline void Type::set_oneofs(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) + oneofs_.Mutable(index)->assign(std::move(value)); +} +#endif inline void Type::set_oneofs(int index, const char* value) { oneofs_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.Type.oneofs) @@ -1141,6 +1173,12 @@ inline void Type::add_oneofs(const ::std::string& value) { oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) } +#if LANG_CXX11 +inline void Type::add_oneofs(::std::string&& value) { + oneofs_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) +} +#endif inline void Type::add_oneofs(const char* value) { oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.Type.oneofs) @@ -1190,7 +1228,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 +1279,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 +1293,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 +1311,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 +1325,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 +1339,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 +1405,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 +1471,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 +1485,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 +1529,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 +1595,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 +1661,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 +1791,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 +1842,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 +1856,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 +1926,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 +1970,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 +2040,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 +2091,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 +2103,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..624c15ee 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 { @@ -165,9 +166,15 @@ message EnumValue { // A protocol buffer option, which can be attached to a message, field, // enumeration, etc. message Option { - // The option's name. For example, `"java_package"`. + // The option's name. For protobuf built-in options (options defined in + // descriptor.proto), this is the short name. For example, `"map_entry"`. + // For custom options, it should be the fully-qualified name. For example, + // `"google.api.http"`. string name = 1; - // The option's value. For example, `"com.google.protobuf"`. + // The option's value packed in an Any message. If the value is a primitive, + // the corresponding wrapper type defined in google/protobuf/wrappers.proto + // should be used. If the value is an enum, it should be stored as an int32 + // value using the google.protobuf.Int32Value type. Any value = 2; } 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..85cecec5 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; @@ -456,7 +463,8 @@ void FieldMaskTree::TrimMessage(const Node* node, Message* message) { const int32 field_count = descriptor->field_count(); for (int index = 0; index < field_count; ++index) { const FieldDescriptor* field = descriptor->field(index); - map<string, Node*>::const_iterator it = node->children.find(field->name()); + std::map<string, Node*>::const_iterator it = + node->children.find(field->name()); if (it == node->children.end()) { reflection->ClearField(message, field); } else { 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/constants.h b/src/google/protobuf/util/internal/constants.h index e556888c..a018a09e 100644 --- a/src/google/protobuf/util/internal/constants.h +++ b/src/google/protobuf/util/internal/constants.h @@ -50,16 +50,16 @@ const char kRfc3339TimeFormat[] = "%E4Y-%m-%dT%H:%M:%S"; const char kRfc3339TimeFormatNoPadding[] = "%Y-%m-%dT%H:%M:%S"; // Minimun seconds allowed in a google.protobuf.Timestamp value. -const int64 kTimestampMinSeconds = -62135596800; +const int64 kTimestampMinSeconds = -62135596800LL; // Maximum seconds allowed in a google.protobuf.Timestamp value. -const int64 kTimestampMaxSeconds = 253402300799; +const int64 kTimestampMaxSeconds = 253402300799LL; // Minimum seconds allowed in a google.protobuf.Duration value. -const int64 kDurationMinSeconds = -315576000000; +const int64 kDurationMinSeconds = -315576000000LL; // Maximum seconds allowed in a google.protobuf.Duration value. -const int64 kDurationMaxSeconds = 315576000000; +const int64 kDurationMaxSeconds = 315576000000LL; // Nano seconds in a second. const int32 kNanosPerSecond = 1000000000; 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_escaping.cc b/src/google/protobuf/util/internal/json_escaping.cc index 06d2791b..47e4dd6d 100644 --- a/src/google/protobuf/util/internal/json_escaping.cc +++ b/src/google/protobuf/util/internal/json_escaping.cc @@ -336,19 +336,19 @@ StringPiece EscapeCodePoint(uint32 cp, char* buffer, bool force_output) { cp >>= 6; if (cp <= 0x1f) { buffer[4] = cp | 0xc0; - sp.set(buffer + 4, 2); + sp = StringPiece(buffer + 4, 2); return sp; } buffer[4] = (cp & 0x3f) | 0x80; cp >>= 6; if (cp <= 0x0f) { buffer[3] = cp | 0xe0; - sp.set(buffer + 3, 3); + sp = StringPiece(buffer + 3, 3); return sp; } buffer[3] = (cp & 0x3f) | 0x80; buffer[2] = ((cp >> 6) & 0x07) | 0xf0; - sp.set(buffer + 2, 4); + sp = StringPiece(buffer + 2, 4); } return sp; } diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc index a8d48eff..b38030c3 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 { @@ -54,6 +56,7 @@ namespace util { // this file. using util::Status; namespace error { +using util::error::CANCELLED; using util::error::INTERNAL; using util::error::INVALID_ARGUMENT; } // namespace error @@ -108,7 +111,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); } @@ -243,7 +247,7 @@ util::Status JsonStreamParser::RunParser() { } if (!result.ok()) { // If we were cancelled, save our state and try again later. - if (!finishing_ && result == util::Status::CANCELLED) { + if (!finishing_ && result == util::Status(error::CANCELLED, "")) { stack_.push(type); // If we have a key we still need to render, make sure to save off the // contents in our own storage. @@ -287,7 +291,7 @@ util::Status JsonStreamParser::ParseValue(TokenType type) { // don't know if the next char would be e, completing it, or something // else, making it invalid. if (!finishing_ && p_.length() < false_len) { - return util::Status::CANCELLED; + return util::Status(error::CANCELLED, ""); } return ReportFailure("Unexpected token."); } @@ -325,7 +329,7 @@ util::Status JsonStreamParser::ParseStringHelper() { // depending on if we expect more data later. if (p_.length() == 1) { if (!finishing_) { - return util::Status::CANCELLED; + return util::Status(error::CANCELLED, ""); } return ReportFailure("Closing quote expected in string."); } @@ -393,7 +397,7 @@ util::Status JsonStreamParser::ParseStringHelper() { } // If we didn't find the closing quote but we expect more data, cancel for now if (!finishing_) { - return util::Status::CANCELLED; + return util::Status(error::CANCELLED, ""); } // End of string reached without a closing quote, report an error. string_open_ = 0; @@ -410,7 +414,7 @@ util::Status JsonStreamParser::ParseStringHelper() { util::Status JsonStreamParser::ParseUnicodeEscape() { if (p_.length() < kUnicodeEscapedLength) { if (!finishing_) { - return util::Status::CANCELLED; + return util::Status(error::CANCELLED, ""); } return ReportFailure("Illegal hex string."); } @@ -427,7 +431,7 @@ util::Status JsonStreamParser::ParseUnicodeEscape() { code <= JsonEscaping::kMaxHighSurrogate) { if (p_.length() < 2 * kUnicodeEscapedLength) { if (!finishing_) { - return util::Status::CANCELLED; + return util::Status(error::CANCELLED, ""); } if (!coerce_to_utf8_) { return ReportFailure("Missing low surrogate."); @@ -521,7 +525,7 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) { // If the entire input is a valid number, and we may have more content in the // future, we abort for now and resume when we know more. if (index == length && !finishing_) { - return util::Status::CANCELLED; + return util::Status(error::CANCELLED, ""); } // Create a string containing just the number, so we can use safe_strtoX @@ -532,6 +536,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; @@ -672,7 +680,7 @@ util::Status JsonStreamParser::ParseArrayValue(TokenType type) { // empty-null array value is relying on this ARRAY_MID token. stack_.push(ARRAY_MID); util::Status result = ParseValue(type); - if (result == util::Status::CANCELLED) { + if (result == util::Status(error::CANCELLED, "")) { // If we were cancelled, pop back off the ARRAY_MID so we don't try to // push it on again when we try over. stack_.pop(); @@ -751,7 +759,7 @@ util::Status JsonStreamParser::ReportFailure(StringPiece message) { util::Status JsonStreamParser::ReportUnknown(StringPiece message) { // If we aren't finishing the parse, cancel parsing and try later. if (!finishing_) { - return util::Status::CANCELLED; + return util::Status(error::CANCELLED, ""); } if (p_.empty()) { return ReportFailure(StrCat("Unexpected end of string. ", message)); @@ -781,7 +789,7 @@ util::Status JsonStreamParser::ParseKey() { // we can't know if the key was complete or not. if (!finishing_ && p_.empty()) { p_ = original; - return util::Status::CANCELLED; + return util::Status(error::CANCELLED, ""); } // Since we aren't using the key storage, clear it out. key_storage_.clear(); 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 150f3cf1..f9fd7b01 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) { @@ -120,9 +120,11 @@ ProtoStreamObjectSource::ProtoStreamObjectSource( own_typeinfo_(true), type_(type), use_lower_camel_for_enums_(false), + use_ints_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."; } @@ -134,9 +136,11 @@ ProtoStreamObjectSource::ProtoStreamObjectSource( own_typeinfo_(false), type_(type), use_lower_camel_for_enums_(false), + use_ints_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 +322,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 +346,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 +376,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; } @@ -854,6 +860,12 @@ Status ProtoStreamObjectSource::RenderNonMessageField( break; } + // No need to lookup enum type if we need to render int. + if (use_ints_for_enums_) { + ow->RenderInt32(field_name, buffer32); + break; + } + // Get the nested enum type for this field. // TODO(skarvaje): Avoid string manipulation. Find ways to speed this // up. @@ -1020,12 +1032,8 @@ bool ProtoStreamObjectSource::IsMap( const google::protobuf::Field& field) const { const google::protobuf::Type* field_type = typeinfo_->GetTypeByTypeUrl(field.type_url()); - - // TODO(xiaofeng): Unify option names. return field.kind() == google::protobuf::Field_Kind_TYPE_MESSAGE && - (GetBoolOptionOrDefault(field_type->options(), - "google.protobuf.MessageOptions.map_entry", false) || - GetBoolOptionOrDefault(field_type->options(), "map_entry", false)); + google::protobuf::util::converter::IsMap(field, *field_type); } std::pair<int64, int32> ProtoStreamObjectSource::ReadSecondsAndNanos( @@ -1103,8 +1111,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..63d5f455 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.h +++ b/src/google/protobuf/util/internal/protostream_objectsource.h @@ -110,6 +110,12 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { use_lower_camel_for_enums_ = value; } + // Sets whether to always output enums as ints, by default this is off, and + // enums are rendered as strings. + void set_use_ints_for_enums(bool value) { + use_ints_for_enums_ = value; + } + // Sets the max recursion depth of proto message to be deserialized. Proto // messages over this depth will fail to be deserialized. // Default value is 64. @@ -285,6 +291,9 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { // Whether to render enums using lowerCamelCase. Defaults to false. bool use_lower_camel_for_enums_; + // Whether to render enums as ints always. Defaults to false. + bool use_ints_for_enums_; + // Tracks current recursion depth. mutable int recursion_depth_; @@ -294,6 +303,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..e215c4ab 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource_test.cc @@ -101,7 +101,9 @@ class ProtostreamObjectSourceTest : helper_(GetParam()), mock_(), ow_(&mock_), - use_lower_camel_for_enums_(false) { + use_lower_camel_for_enums_(false), + use_ints_for_enums_(false), + add_trailing_zeros_(false) { helper_.ResetTypeInfo(Book::descriptor(), Proto3Message::descriptor()); } @@ -113,7 +115,7 @@ class ProtostreamObjectSourceTest } Status ExecuteTest(const Message& msg, const Descriptor* descriptor) { - ostringstream oss; + std::ostringstream oss; msg.SerializePartialToOstream(&oss); string proto = oss.str(); ArrayInputStream arr_stream(proto.data(), proto.size()); @@ -122,6 +124,7 @@ class ProtostreamObjectSourceTest google::protobuf::scoped_ptr<ProtoStreamObjectSource> os( helper_.NewProtoSource(&in_stream, GetTypeUrl(descriptor))); if (use_lower_camel_for_enums_) os->set_use_lower_camel_for_enums(true); + if (use_ints_for_enums_) os->set_use_ints_for_enums(true); os->set_max_recursion_depth(64); return os->WriteTo(&mock_); } @@ -269,11 +272,17 @@ class ProtostreamObjectSourceTest void UseLowerCamelForEnums() { use_lower_camel_for_enums_ = true; } + void UseIntsForEnums() { use_ints_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 use_ints_for_enums_; + bool add_trailing_zeros_; }; INSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest, @@ -494,6 +503,18 @@ TEST_P(ProtostreamObjectSourceTest, EnumCaseIsUnchangedByDefault) { DoTest(book, Book::descriptor()); } +TEST_P(ProtostreamObjectSourceTest, UseIntsForEnumsTest) { + Book book; + book.set_type(Book::ACTION_AND_ADVENTURE); + + UseIntsForEnums(); + + ow_.StartObject("") + ->RenderInt32("type", 3) + ->EndObject(); + DoTest(book, Book::descriptor()); +} + TEST_P(ProtostreamObjectSourceTest, UnknownEnum) { Proto3Message message; message.set_enum_value(static_cast<Proto3Message::NestedEnum>(1234)); @@ -1023,6 +1044,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.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc index 6c15e862..6c9bc30e 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc @@ -1238,10 +1238,7 @@ bool ProtoStreamObjectWriter::IsMap(const google::protobuf::Field& field) { const google::protobuf::Type* field_type = typeinfo()->GetTypeByTypeUrl(field.type_url()); - // TODO(xiaofeng): Unify option names. - return GetBoolOptionOrDefault(field_type->options(), - "google.protobuf.MessageOptions.map_entry", false) || - GetBoolOptionOrDefault(field_type->options(), "map_entry", false); + return google::protobuf::util::converter::IsMap(field, *field_type); } bool ProtoStreamObjectWriter::IsAny(const google::protobuf::Field& field) { 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 9aab3481..6daf24eb 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]); } @@ -356,15 +356,25 @@ bool IsValidBoolString(const string& bool_string) { bool IsMap(const google::protobuf::Field& field, const google::protobuf::Type& type) { - return (field.cardinality() == - google::protobuf::Field_Cardinality_CARDINALITY_REPEATED && + return field.cardinality() == + google::protobuf::Field_Cardinality_CARDINALITY_REPEATED && + (GetBoolOptionOrDefault(type.options(), "map_entry", false) || + GetBoolOptionOrDefault(type.options(), + "google.protobuf.MessageOptions.map_entry", false) || GetBoolOptionOrDefault(type.options(), - "google.protobuf.MessageOptions.map_entry", false)); + "google.protobuf.MessageOptions.map_entry", + false)); } bool IsMessageSetWireFormat(const google::protobuf::Type& type) { - return GetBoolOptionOrDefault( - type.options(), "google.protobuf.MessageOptions.message_set_wire_format", false); + return GetBoolOptionOrDefault(type.options(), "message_set_wire_format", + false) || + GetBoolOptionOrDefault(type.options(), + "google.protobuf.MessageOptions.message_set_wire_format", + false) || + GetBoolOptionOrDefault( + type.options(), + "google.protobuf.MessageOptions.message_set_wire_format", false); } string DoubleAsString(double value) { diff --git a/src/google/protobuf/util/json_format_proto3.proto b/src/google/protobuf/util/json_format_proto3.proto index 3835b30e..8a0441c8 100644 --- a/src/google/protobuf/util/json_format_proto3.proto +++ b/src/google/protobuf/util/json_format_proto3.proto @@ -32,6 +32,8 @@ syntax = "proto3"; package proto3; +option java_package = "com.google.protobuf.util"; +option java_outer_classname = "JsonFormatProto3"; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc index 5974cc4a..129b6eaf 100644 --- a/src/google/protobuf/util/json_util.cc +++ b/src/google/protobuf/util/json_util.cc @@ -82,6 +82,7 @@ util::Status BinaryToJsonStream(TypeResolver* resolver, google::protobuf::Type type; RETURN_IF_ERROR(resolver->ResolveMessageType(type_url, &type)); converter::ProtoStreamObjectSource proto_source(&in_stream, resolver, type); + proto_source.set_use_ints_for_enums(options.always_print_enums_as_ints); io::CodedOutputStream out_stream(json_output); converter::JsonObjectWriter json_writer(options.add_whitespace ? " " : "", &out_stream); diff --git a/src/google/protobuf/util/json_util.h b/src/google/protobuf/util/json_util.h index 0e45ef81..53b1d1ba 100644 --- a/src/google/protobuf/util/json_util.h +++ b/src/google/protobuf/util/json_util.h @@ -61,9 +61,13 @@ struct JsonPrintOptions { // set to 0 will be omitted. Set this flag to true will override the default // behavior and print primitive fields regardless of their values. bool always_print_primitive_fields; + // Whether to always print enums as ints. By default they are rendered as + // strings. + bool always_print_enums_as_ints; JsonPrintOptions() : add_whitespace(false), - always_print_primitive_fields(false) { + always_print_primitive_fields(false), + always_print_enums_as_ints(false) { } }; diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index 24ff5fd6..796718d5 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc @@ -36,6 +36,7 @@ #include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/descriptor_database.h> #include <google/protobuf/dynamic_message.h> +#include <google/protobuf/util/internal/testdata/maps.pb.h> #include <google/protobuf/util/json_format_proto3.pb.h> #include <google/protobuf/util/type_resolver.h> #include <google/protobuf/util/type_resolver_util.h> @@ -50,6 +51,7 @@ using proto3::FOO; using proto3::BAR; using proto3::TestMessage; using proto3::TestMap; +using testing::MapIn; static const char kTypeUrlPrefix[] = "type.googleapis.com"; @@ -62,7 +64,7 @@ static string GetTypeUrl(const Descriptor* message) { // only cover some very basic cases to make sure the wrappers have forwarded // parameters to the underlying implementation correctly. More detailed // tests are contained in the //net/proto2/util/converter directory. -class JsonUtilTest : public testing::Test { +class JsonUtilTest : public ::testing::Test { protected: JsonUtilTest() { } @@ -158,6 +160,29 @@ TEST_F(JsonUtilTest, TestDefaultValues) { ToJson(m, options)); } +TEST_F(JsonUtilTest, TestAlwaysPrintEnumsAsInts) { + TestMessage orig; + orig.set_enum_value(proto3::EnumType::BAR); + orig.add_repeated_enum_value(proto3::EnumType::FOO); + orig.add_repeated_enum_value(proto3::EnumType::BAR); + + JsonPrintOptions print_options; + print_options.always_print_enums_as_ints = true; + + string expected_json = + "{\"enumValue\":1,\"repeatedEnumValue\":[0,1]}"; + EXPECT_EQ(expected_json, ToJson(orig, print_options)); + + TestMessage parsed; + JsonParseOptions parse_options; + ASSERT_TRUE(FromJson(expected_json, &parsed, parse_options)); + + EXPECT_EQ(proto3::EnumType::BAR, parsed.enum_value()); + EXPECT_EQ(2, parsed.repeated_enum_value_size()); + EXPECT_EQ(proto3::EnumType::FOO, parsed.repeated_enum_value(0)); + EXPECT_EQ(proto3::EnumType::BAR, parsed.repeated_enum_value(1)); +} + TEST_F(JsonUtilTest, ParseMessage) { // Some random message but good enough to verify that the parsing warpper // functions are working properly. @@ -196,6 +221,17 @@ TEST_F(JsonUtilTest, ParseMap) { EXPECT_EQ(message.DebugString(), other.DebugString()); } +TEST_F(JsonUtilTest, ParsePrimitiveMapIn) { + MapIn message; + JsonPrintOptions print_options; + print_options.always_print_primitive_fields = true; + JsonParseOptions parse_options; + EXPECT_EQ("{\"other\":\"\",\"things\":[],\"mapInput\":{}}", ToJson(message, print_options)); + MapIn other; + ASSERT_TRUE(FromJson(ToJson(message, print_options), &other, parse_options)); + EXPECT_EQ(message.DebugString(), other.DebugString()); +} + TEST_F(JsonUtilTest, TestParseIgnoreUnknownFields) { TestMessage m; JsonParseOptions options; @@ -251,11 +287,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 +317,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 +335,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/time_util.h b/src/google/protobuf/util/time_util.h index 432c9f0a..b8846935 100644 --- a/src/google/protobuf/util/time_util.h +++ b/src/google/protobuf/util/time_util.h @@ -237,7 +237,7 @@ inline Duration operator%(const Duration& d1, const Duration& d2) { return result %= d2; } -inline ostream& operator<<(ostream& out, const Duration& d) { +inline std::ostream& operator<<(std::ostream& out, const Duration& d) { out << google::protobuf::util::TimeUtil::ToString(d); return out; } @@ -284,7 +284,7 @@ inline Timestamp operator-(const Timestamp& t, const Duration& d) { } LIBPROTOBUF_EXPORT Duration operator-(const Timestamp& t1, const Timestamp& t2); -inline ostream& operator<<(ostream& out, const Timestamp& t) { +inline std::ostream& operator<<(std::ostream& out, const Timestamp& t) { out << google::protobuf::util::TimeUtil::ToString(t); return out; } 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..bd5b2489 100644 --- a/src/google/protobuf/wire_format.cc +++ b/src/google/protobuf/wire_format.cc @@ -42,6 +42,8 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/stringprintf.h> #include <google/protobuf/descriptor.h> +#include <google/protobuf/dynamic_message.h> +#include <google/protobuf/map_field.h> #include <google/protobuf/wire_format_lite_inl.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/io/coded_stream.h> @@ -792,7 +794,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); @@ -834,6 +836,13 @@ void WireFormat::SerializeFieldWithCachedSizes( count = 1; } + // map_entries is for maps that'll be deterministically serialized. + std::vector<const Message*> map_entries; + if (count > 1 && field->is_map() && output->IsSerializationDeterministic()) { + map_entries = + DynamicMapSorter::Sort(message, count, message_reflection, field); + } + const bool is_packed = field->is_packed(); if (is_packed && count > 0) { WireFormatLite::WriteTag(field->number(), @@ -877,15 +886,17 @@ void WireFormat::SerializeFieldWithCachedSizes( HANDLE_PRIMITIVE_TYPE(BOOL, bool, Bool, Bool) #undef HANDLE_PRIMITIVE_TYPE -#define HANDLE_TYPE(TYPE, TYPE_METHOD, CPPTYPE_METHOD) \ - case FieldDescriptor::TYPE_##TYPE: \ - WireFormatLite::Write##TYPE_METHOD( \ - field->number(), \ - field->is_repeated() ? \ - message_reflection->GetRepeated##CPPTYPE_METHOD( \ - message, field, j) : \ - message_reflection->Get##CPPTYPE_METHOD(message, field), \ - output); \ +#define HANDLE_TYPE(TYPE, TYPE_METHOD, CPPTYPE_METHOD) \ + case FieldDescriptor::TYPE_##TYPE: \ + WireFormatLite::Write##TYPE_METHOD( \ + field->number(), \ + field->is_repeated() ? \ + (map_entries.empty() ? \ + message_reflection->GetRepeated##CPPTYPE_METHOD( \ + message, field, j) : \ + *map_entries[j]) : \ + message_reflection->Get##CPPTYPE_METHOD(message, field), \ + output); \ break; HANDLE_TYPE(GROUP , Group , Message) @@ -970,7 +981,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.h b/src/google/protobuf/wire_format.h index de8ea574..5e9aca52 100644 --- a/src/google/protobuf/wire_format.h +++ b/src/google/protobuf/wire_format.h @@ -327,6 +327,9 @@ inline void WireFormat::VerifyUTF8StringNamedField( #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED WireFormatLite::VerifyUtf8String( data, size, static_cast<WireFormatLite::Operation>(op), field_name); +#else + // Avoid the compiler warning about unused variables. + (void)data; (void)size; (void)op; (void)field_name; #endif } diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc index 5bed7af4..e46ac400 100644 --- a/src/google/protobuf/wire_format_lite.cc +++ b/src/google/protobuf/wire_format_lite.cc @@ -34,6 +34,9 @@ #include <google/protobuf/wire_format_lite_inl.h> +#ifdef __SSE_4_1__ +#include <immintrin.h> +#endif #include <stack> #include <string> #include <vector> @@ -337,6 +340,90 @@ bool WireFormatLite::ReadPackedEnumPreserveUnknowns( return true; } +namespace { +void EncodeFixedSizeValue(float v, uint8* dest) { + WireFormatLite::WriteFloatNoTagToArray(v, dest); +} + +void EncodeFixedSizeValue(double v, uint8* dest) { + WireFormatLite::WriteDoubleNoTagToArray(v, dest); +} + +void EncodeFixedSizeValue(uint32 v, uint8* dest) { + WireFormatLite::WriteFixed32NoTagToArray(v, dest); +} + +void EncodeFixedSizeValue(uint64 v, uint8* dest) { + WireFormatLite::WriteFixed64NoTagToArray(v, dest); +} + +void EncodeFixedSizeValue(int32 v, uint8* dest) { + WireFormatLite::WriteSFixed32NoTagToArray(v, dest); +} + +void EncodeFixedSizeValue(int64 v, uint8* dest) { + WireFormatLite::WriteSFixed64NoTagToArray(v, dest); +} + +void EncodeFixedSizeValue(bool v, uint8* dest) { + WireFormatLite::WriteBoolNoTagToArray(v, dest); +} +} // anonymous namespace + +template <typename CType> +static void WriteArray(const CType* a, int n, io::CodedOutputStream* output) { +#if defined(PROTOBUF_LITTLE_ENDIAN) + output->WriteRaw(reinterpret_cast<const char*>(a), n * sizeof(a[0])); +#else + const int kAtATime = 128; + uint8 buf[sizeof(CType) * kAtATime]; + for (int i = 0; i < n; i += kAtATime) { + int to_do = min(kAtATime, n - i); + uint8* ptr = buf; + for (int j = 0; j < to_do; j++) { + EncodeFixedSizeValue(a[i+j], ptr); + ptr += sizeof(a[0]); + } + output->WriteRaw(buf, to_do * sizeof(a[0])); + } +#endif +} + +void WireFormatLite::WriteFloatArray(const float* a, int n, + io::CodedOutputStream* output) { + WriteArray<float>(a, n, output); +} + +void WireFormatLite::WriteDoubleArray(const double* a, int n, + io::CodedOutputStream* output) { + WriteArray<double>(a, n, output); +} + +void WireFormatLite::WriteFixed32Array(const uint32* a, int n, + io::CodedOutputStream* output) { + WriteArray<uint32>(a, n, output); +} + +void WireFormatLite::WriteFixed64Array(const uint64* a, int n, + io::CodedOutputStream* output) { + WriteArray<uint64>(a, n, output); +} + +void WireFormatLite::WriteSFixed32Array(const int32* a, int n, + io::CodedOutputStream* output) { + WriteArray<int32>(a, n, output); +} + +void WireFormatLite::WriteSFixed64Array(const int64* a, int n, + io::CodedOutputStream* output) { + WriteArray<int64>(a, n, output); +} + +void WireFormatLite::WriteBoolArray(const bool* a, int n, + io::CodedOutputStream* output) { + WriteArray<bool>(a, n, output); +} + void WireFormatLite::WriteInt32(int field_number, int32 value, io::CodedOutputStream* output) { WriteTag(field_number, WIRETYPE_VARINT, output); @@ -467,7 +554,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 +571,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); @@ -540,6 +627,152 @@ bool WireFormatLite::VerifyUtf8String(const char* data, return true; } +#ifdef __SSE_4_1__ +template<typename T, bool ZigZag, bool SignExtended> +static size_t VarintSize( + const T* data, const int n, + const internal::enable_if<sizeof(T) == 4>::type* = NULL) { +#if __cplusplus >= 201103L + // is_unsigned<T> => !ZigZag + static_assert((std::is_unsigned<T>::value ^ ZigZag) || + std::is_signed<T>::value, + "Cannot ZigZag encode unsigned types"); + // is_unsigned<T> => !SignExtended + static_assert((std::is_unsigned<T>::value ^ SignExtended) || + std::is_signed<T>::value, + "Cannot SignExtended unsigned types"); +#endif + + union vus32 { + uint32 u[4]; + int32 s[4]; + __m128i v; + }; + + static const vus32 ones = {{1, 1, 1, 1}}; + + // CodedOutputStream::VarintSize32SignExtended returns 10 for negative + // numbers. We can apply the UInt32Size algorithm, and simultaneously logical + // shift the MSB into the LSB to determine if it is negative. + static const vus32 fives = {{5, 5, 5, 5}}; + + // sum is the vectorized-output of calling CodedOutputStream::VarintSize32 on + // the processed elements. + // + // msb_sum is the count of set most-significant bits. When computing the + // vectorized CodedOutputStream::VarintSize32SignExtended, negative values + // have the most significant bit set. VarintSize32SignExtended returns 10 and + // VarintSize32 returns 5. msb_sum allows us to compute: + // VarintSize32SignExtended = msb_sum * 5 + VarintSize32 + vus32 sum, v, msb_sum; + sum.v = _mm_setzero_si128(); + msb_sum.v = _mm_setzero_si128(); + + int rounded = n & ~(3); + int i; + for (i = 0; i < rounded; i += 4) { + v.v = _mm_loadu_si128(reinterpret_cast<const __m128i*>(&data[i])); + + if (ZigZag) { + // Note: the right-shift must be arithmetic + v.v = _mm_xor_si128(_mm_slli_epi32(v.v, 1), _mm_srai_epi32(v.v, 31)); + } + + sum.v = _mm_add_epi32(sum.v, ones.v); + if (SignExtended) { + msb_sum.v = _mm_add_epi32(msb_sum.v, _mm_srli_epi32(v.v, 31)); + } + + v.v = _mm_srli_epi32(v.v, 7); + + for (int j = 0; j < 4; j++) { + __m128i min = _mm_min_epi32(v.v, ones.v); + + sum.v = _mm_add_epi32(sum.v, min); + v.v = _mm_srli_epi32(v.v, 7); + } + } + + if (SignExtended) { + vus32 extensions; + extensions.v = _mm_mullo_epi32(msb_sum.v, fives.v); + + sum.v = _mm_add_epi32(sum.v, extensions.v); + } + + // TODO(ckennelly): Can we avoid the sign conversion? + size_t out = _mm_cvtsi128_si32( + _mm_hadd_epi32(_mm_hadd_epi32(sum.v, ones.v), ones.v)); + + // Finish tail. + for (; i < n; i++) { + if (ZigZag) { + out += WireFormatLite::SInt32Size(data[i]); + } else if (SignExtended) { + out += WireFormatLite::Int32Size(data[i]); + } else { + out += WireFormatLite::UInt32Size(data[i]); + } + } + + return out; +} + +size_t WireFormatLite::Int32Size(const RepeatedField<int32>& value) { + return VarintSize<int32, false, true>(value.data(), value.size()); +} + +size_t WireFormatLite::UInt32Size(const RepeatedField<uint32>& value) { + return VarintSize<uint32, false, false>(value.data(), value.size()); +} + +size_t WireFormatLite::SInt32Size(const RepeatedField<int32>& value) { + return VarintSize<int32, true, true>(value.data(), value.size()); +} + +size_t WireFormatLite::EnumSize(const RepeatedField<int>& value) { + // On ILP64, sizeof(int) == 8, which would require a different template. + return VarintSize<int, false, true>(value.data(), value.size()); +} + +#else // !__SSE_4_1__ +size_t WireFormatLite::Int32Size(const RepeatedField<int32>& value) { + size_t out = 0; + const int n = value.size(); + for (int i = 0; i < n; i++) { + out += Int32Size(value.Get(i)); + } + return out; +} + +size_t WireFormatLite::UInt32Size(const RepeatedField<uint32>& value) { + size_t out = 0; + const int n = value.size(); + for (int i = 0; i < n; i++) { + out += UInt32Size(value.Get(i)); + } + return out; +} + +size_t WireFormatLite::SInt32Size(const RepeatedField<int32>& value) { + size_t out = 0; + const int n = value.size(); + for (int i = 0; i < n; i++) { + out += SInt32Size(value.Get(i)); + } + return out; +} + +size_t WireFormatLite::EnumSize(const RepeatedField<int>& value) { + size_t out = 0; + const int n = value.size(); + for (int i = 0; i < n; i++) { + out += EnumSize(value.Get(i)); + } + return out; +} +#endif + } // namespace internal } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index eeb3650f..60355144 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -42,9 +42,20 @@ #include <string> #include <google/protobuf/stubs/common.h> +#include <google/protobuf/repeated_field.h> #include <google/protobuf/message_lite.h> #include <google/protobuf/io/coded_stream.h> // for CodedOutputStream::Varint32Size +// Avoid conflict with iOS where <ConditionalMacros.h> #defines TYPE_BOOL. +// +// If some one needs the macro TYPE_BOOL in a file that includes this header, it's +// possible to bring it back using push/pop_macro as follows. +// +// #pragma push_macro("TYPE_BOOL") +// #include this header and/or all headers that need the macro to be undefined. +// #pragma pop_macro("TYPE_BOOL") +#undef TYPE_BOOL + namespace google { namespace protobuf { @@ -243,7 +254,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. @@ -371,6 +390,15 @@ class LIBPROTOBUF_EXPORT WireFormatLite { INL static void WriteBoolNoTag (bool value, output); INL static void WriteEnumNoTag (int value, output); + // Write array of primitive fields, without tags + static void WriteFloatArray (const float* a, int n, output); + static void WriteDoubleArray (const double* a, int n, output); + static void WriteFixed32Array (const uint32* a, int n, output); + static void WriteFixed64Array (const uint64* a, int n, output); + static void WriteSFixed32Array(const int32* a, int n, output); + static void WriteSFixed64Array(const int64* a, int n, output); + static void WriteBoolArray (const bool* a, int n, output); + // Write fields, including tags. static void WriteInt32 (field_number, int32 value, output); static void WriteInt64 (field_number, int64 value, output); @@ -519,6 +547,14 @@ class LIBPROTOBUF_EXPORT WireFormatLite { static inline size_t SInt64Size ( int64 value); static inline size_t EnumSize ( int value); + static size_t Int32Size (const RepeatedField< int32>& value); + static inline size_t Int64Size (const RepeatedField< int64>& value); + static size_t UInt32Size(const RepeatedField<uint32>& value); + static inline size_t UInt64Size(const RepeatedField<uint64>& value); + static size_t SInt32Size(const RepeatedField< int32>& value); + static inline size_t SInt64Size(const RepeatedField< int64>& value); + static size_t EnumSize (const RepeatedField< int>& value); + // These types always have the same size. static const size_t kFixed32Size = 4; static const size_t kFixed64Size = 8; diff --git a/src/google/protobuf/wire_format_lite_inl.h b/src/google/protobuf/wire_format_lite_inl.h index 1963fac8..aa3bb3a6 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,39 @@ 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)); +} + +size_t WireFormatLite::Int64Size (const RepeatedField< int64>& value) { + size_t out = 0; + const int n = value.size(); + for (int i = 0; i < n; i++) { + out += Int64Size(value.Get(i)); + } + return out; +} + +size_t WireFormatLite::UInt64Size(const RepeatedField<uint64>& value) { + size_t out = 0; + const int n = value.size(); + for (int i = 0; i < n; i++) { + out += UInt64Size(value.Get(i)); + } + return out; +} + +size_t WireFormatLite::SInt64Size(const RepeatedField< int64>& value) { + size_t out = 0; + const int n = value.size(); + for (int i = 0; i < n; i++) { + out += SInt64Size(value.Get(i)); + } + return out; } } // namespace internal diff --git a/src/google/protobuf/wire_format_unittest.cc b/src/google/protobuf/wire_format_unittest.cc index 4e4add66..897fec00 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(), @@ -1283,6 +1283,136 @@ TEST_F(Utf8ValidationTest, OldVerifyUTF8String) { } +TEST(RepeatedVarint, Int32) { + RepeatedField<int32> v; + + // Insert -2^n, 2^n and 2^n-1. + for (int n = 0; n < 10; n++) { + v.Add(-(1 << n)); + v.Add(1 << n); + v.Add((1 << n) - 1); + } + + // Check consistency with the scalar Int32Size. + size_t expected = 0; + for (int i = 0; i < v.size(); i++) { + expected += WireFormatLite::Int32Size(v[i]); + } + + EXPECT_EQ(expected, WireFormatLite::Int32Size(v)); +} + +TEST(RepeatedVarint, Int64) { + RepeatedField<int64> v; + + // Insert -2^n, 2^n and 2^n-1. + for (int n = 0; n < 10; n++) { + v.Add(-(1 << n)); + v.Add(1 << n); + v.Add((1 << n) - 1); + } + + // Check consistency with the scalar Int64Size. + size_t expected = 0; + for (int i = 0; i < v.size(); i++) { + expected += WireFormatLite::Int64Size(v[i]); + } + + EXPECT_EQ(expected, WireFormatLite::Int64Size(v)); +} + +TEST(RepeatedVarint, SInt32) { + RepeatedField<int32> v; + + // Insert -2^n, 2^n and 2^n-1. + for (int n = 0; n < 10; n++) { + v.Add(-(1 << n)); + v.Add(1 << n); + v.Add((1 << n) - 1); + } + + // Check consistency with the scalar SInt32Size. + size_t expected = 0; + for (int i = 0; i < v.size(); i++) { + expected += WireFormatLite::SInt32Size(v[i]); + } + + EXPECT_EQ(expected, WireFormatLite::SInt32Size(v)); +} + +TEST(RepeatedVarint, SInt64) { + RepeatedField<int64> v; + + // Insert -2^n, 2^n and 2^n-1. + for (int n = 0; n < 10; n++) { + v.Add(-(1 << n)); + v.Add(1 << n); + v.Add((1 << n) - 1); + } + + // Check consistency with the scalar SInt64Size. + size_t expected = 0; + for (int i = 0; i < v.size(); i++) { + expected += WireFormatLite::SInt64Size(v[i]); + } + + EXPECT_EQ(expected, WireFormatLite::SInt64Size(v)); +} + +TEST(RepeatedVarint, UInt32) { + RepeatedField<uint32> v; + + // Insert 2^n and 2^n-1. + for (int n = 0; n < 10; n++) { + v.Add(1 << n); + v.Add((1 << n) - 1); + } + + // Check consistency with the scalar UInt32Size. + size_t expected = 0; + for (int i = 0; i < v.size(); i++) { + expected += WireFormatLite::UInt32Size(v[i]); + } + + EXPECT_EQ(expected, WireFormatLite::UInt32Size(v)); +} + +TEST(RepeatedVarint, UInt64) { + RepeatedField<uint64> v; + + // Insert 2^n and 2^n-1. + for (int n = 0; n < 10; n++) { + v.Add(1 << n); + v.Add((1 << n) - 1); + } + + // Check consistency with the scalar UInt64Size. + size_t expected = 0; + for (int i = 0; i < v.size(); i++) { + expected += WireFormatLite::UInt64Size(v[i]); + } + + EXPECT_EQ(expected, WireFormatLite::UInt64Size(v)); +} + +TEST(RepeatedVarint, Enum) { + RepeatedField<int> v; + + // Insert 2^n and 2^n-1. + for (int n = 0; n < 10; n++) { + v.Add(1 << n); + v.Add((1 << n) - 1); + } + + // Check consistency with the scalar EnumSize. + size_t expected = 0; + for (int i = 0; i < v.size(); i++) { + expected += WireFormatLite::EnumSize(v[i]); + } + + EXPECT_EQ(expected, WireFormatLite::EnumSize(v)); +} + } // namespace } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index 35364066..0dad64a4 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -19,301 +19,204 @@ namespace google { namespace protobuf { +class DoubleValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> { +} _DoubleValue_default_instance_; +class FloatValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FloatValue> { +} _FloatValue_default_instance_; +class Int64ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Int64Value> { +} _Int64Value_default_instance_; +class UInt64ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> { +} _UInt64Value_default_instance_; +class Int32ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Int32Value> { +} _Int32Value_default_instance_; +class UInt32ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> { +} _UInt32Value_default_instance_; +class BoolValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<BoolValue> { +} _BoolValue_default_instance_; +class StringValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<StringValue> { +} _StringValue_default_instance_; +class BytesValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> { +} _BytesValue_default_instance_; + +namespace protobuf_google_2fprotobuf_2fwrappers_2eproto { + 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] = { - 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] = { - 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] = { - 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] = { - 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] = { - 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] = { - 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] = { - 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] = { - 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] = { - 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_)); -} +const ::google::protobuf::uint32 TableStruct::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_), + ~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_), + ~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_), + ~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_), + ~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_), + ~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_), + ~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_), + ~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_), + ~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_), +}; + +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 ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_DoubleValue_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_FloatValue_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_Int64Value_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_UInt64Value_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_Int32Value_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_UInt32Value_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_BoolValue_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_StringValue_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_BytesValue_default_instance_), +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/wrappers.proto", schemas, file_default_instances, TableStruct::offsets, 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_; -} - -void protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl() { +void TableStruct::Shutdown() { + _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 TableStruct::InitDefaultsImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - DoubleValue_default_instance_.DefaultConstruct(); - FloatValue_default_instance_.DefaultConstruct(); - Int64Value_default_instance_.DefaultConstruct(); - UInt64Value_default_instance_.DefaultConstruct(); - Int32Value_default_instance_.DefaultConstruct(); - UInt32Value_default_instance_.DefaultConstruct(); - BoolValue_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - StringValue_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - BytesValue_default_instance_.DefaultConstruct(); - DoubleValue_default_instance_.get_mutable()->InitAsDefaultInstance(); - FloatValue_default_instance_.get_mutable()->InitAsDefaultInstance(); - Int64Value_default_instance_.get_mutable()->InitAsDefaultInstance(); - UInt64Value_default_instance_.get_mutable()->InitAsDefaultInstance(); - Int32Value_default_instance_.get_mutable()->InitAsDefaultInstance(); - UInt32Value_default_instance_.get_mutable()->InitAsDefaultInstance(); - BoolValue_default_instance_.get_mutable()->InitAsDefaultInstance(); - StringValue_default_instance_.get_mutable()->InitAsDefaultInstance(); - BytesValue_default_instance_.get_mutable()->InitAsDefaultInstance(); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_once_); -void protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl); -} -void protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + ::google::protobuf::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 InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); +} +void AddDescriptorsImpl() { + InitDefaults(); + 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); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_once_); -void protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_once_, - &protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl); +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2fwrappers_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2fwrappers_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); } -} static_descriptor_initializer_google_2fprotobuf_2fwrappers_2eproto_; +} static_descriptor_initializer; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace +} // namespace protobuf_google_2fprotobuf_2fwrappers_2eproto // =================================================================== @@ -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_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DoubleValue) } @@ -332,21 +237,18 @@ DoubleValue::DoubleValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -380,17 +282,15 @@ void DoubleValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* DoubleValue::descriptor() { - protobuf_AssignDescriptorsOnce(); - return DoubleValue_descriptor_; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[0].descriptor; } const DoubleValue& DoubleValue::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); 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,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(9u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -420,7 +321,6 @@ bool DoubleValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -448,7 +348,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); } @@ -458,9 +358,9 @@ void DoubleValue::SerializeWithCachedSizes( ::google::protobuf::uint8* DoubleValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +373,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 +387,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 +396,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 +420,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 +432,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 +448,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; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::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 +473,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 +483,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_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FloatValue) } @@ -603,21 +493,18 @@ FloatValue::FloatValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -651,17 +538,15 @@ void FloatValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* FloatValue::descriptor() { - protobuf_AssignDescriptorsOnce(); - return FloatValue_descriptor_; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[1].descriptor; } const FloatValue& FloatValue::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); 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 +562,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(13u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( @@ -691,7 +577,6 @@ bool FloatValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -719,7 +604,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); } @@ -729,9 +614,9 @@ void FloatValue::SerializeWithCachedSizes( ::google::protobuf::uint8* FloatValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +629,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 +643,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 +652,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 +676,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 +688,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 +704,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; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::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 +729,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 +739,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_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Int64Value) } @@ -874,21 +749,18 @@ Int64Value::Int64Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -922,17 +794,15 @@ void Int64Value::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Int64Value::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Int64Value_descriptor_; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[2].descriptor; } const Int64Value& Int64Value::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); 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 +818,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -962,7 +833,6 @@ bool Int64Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -990,7 +860,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); } @@ -1000,9 +870,9 @@ void Int64Value::SerializeWithCachedSizes( ::google::protobuf::uint8* Int64Value::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +885,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 +901,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 +910,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 +934,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 +946,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 +962,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; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::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 +987,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 +997,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_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UInt64Value) } @@ -1147,21 +1007,18 @@ UInt64Value::UInt64Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -1195,17 +1052,15 @@ void UInt64Value::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* UInt64Value::descriptor() { - protobuf_AssignDescriptorsOnce(); - return UInt64Value_descriptor_; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[3].descriptor; } const UInt64Value& UInt64Value::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); 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 +1076,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( @@ -1235,7 +1091,6 @@ bool UInt64Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1263,7 +1118,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); } @@ -1273,9 +1128,9 @@ void UInt64Value::SerializeWithCachedSizes( ::google::protobuf::uint8* UInt64Value::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +1143,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 +1159,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 +1168,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 +1192,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 +1204,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 +1220,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; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::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 +1245,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 +1255,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_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Int32Value) } @@ -1420,21 +1265,18 @@ Int32Value::Int32Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -1468,17 +1310,15 @@ void Int32Value::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Int32Value::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Int32Value_descriptor_; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[4].descriptor; } const Int32Value& Int32Value::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); 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 +1334,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1508,7 +1349,6 @@ bool Int32Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1536,7 +1376,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); } @@ -1546,9 +1386,9 @@ void Int32Value::SerializeWithCachedSizes( ::google::protobuf::uint8* Int32Value::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +1401,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 +1417,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 +1426,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 +1450,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 +1462,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 +1478,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; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::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 +1503,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 +1513,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_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UInt32Value) } @@ -1693,21 +1523,18 @@ UInt32Value::UInt32Value(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -1741,17 +1568,15 @@ void UInt32Value::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* UInt32Value::descriptor() { - protobuf_AssignDescriptorsOnce(); - return UInt32Value_descriptor_; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[5].descriptor; } const UInt32Value& UInt32Value::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); 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 +1592,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( @@ -1781,7 +1607,6 @@ bool UInt32Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1809,7 +1634,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); } @@ -1819,9 +1644,9 @@ void UInt32Value::SerializeWithCachedSizes( ::google::protobuf::uint8* UInt32Value::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +1659,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 +1675,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 +1684,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 +1708,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 +1720,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 +1736,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; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::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 +1761,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 +1771,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_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.BoolValue) } @@ -1966,21 +1781,18 @@ BoolValue::BoolValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -2014,17 +1826,15 @@ void BoolValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* BoolValue::descriptor() { - protobuf_AssignDescriptorsOnce(); - return BoolValue_descriptor_; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[6].descriptor; } const BoolValue& BoolValue::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); 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 +1850,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(8u)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -2054,7 +1865,6 @@ bool BoolValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2082,7 +1892,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); } @@ -2092,9 +1902,9 @@ void BoolValue::SerializeWithCachedSizes( ::google::protobuf::uint8* BoolValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +1917,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 +1931,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 +1940,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 +1964,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 +1976,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 +1992,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; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::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 +2017,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 +2027,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_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.StringValue) } @@ -2237,21 +2037,22 @@ StringValue::StringValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -2286,17 +2087,15 @@ void StringValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* StringValue::descriptor() { - protobuf_AssignDescriptorsOnce(); - return StringValue_descriptor_; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[7].descriptor; } const StringValue& StringValue::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); 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 +2111,14 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -2328,7 +2128,6 @@ bool StringValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2356,7 +2155,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(), @@ -2371,9 +2170,9 @@ void StringValue::SerializeWithCachedSizes( ::google::protobuf::uint8* StringValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +2191,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 +2207,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 +2216,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 +2240,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 +2252,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 +2268,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; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::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 +2345,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 +2355,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_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.BytesValue) } @@ -2576,21 +2365,22 @@ BytesValue::BytesValue(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); #endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); 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) } @@ -2625,17 +2415,15 @@ void BytesValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* BytesValue::descriptor() { - protobuf_AssignDescriptorsOnce(); - return BytesValue_descriptor_; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[8].descriptor; } const BytesValue& BytesValue::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults(); 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 +2439,19 @@ 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 (static_cast<::google::protobuf::uint8>(tag) == + static_cast<::google::protobuf::uint8>(10u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_value())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2691,7 +2479,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); @@ -2702,9 +2490,9 @@ void BytesValue::SerializeWithCachedSizes( ::google::protobuf::uint8* BytesValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (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 +2507,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 +2523,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 +2532,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 +2556,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 +2568,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 +2584,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; + protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fwrappers_2eproto::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 +2661,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..61b0510d 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -8,45 +8,72 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3001000 +#if GOOGLE_PROTOBUF_VERSION < 3002000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif +#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #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; +LIBPROTOBUF_EXPORT extern BoolValueDefaultTypeInternal _BoolValue_default_instance_; class BytesValue; +class BytesValueDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern BytesValueDefaultTypeInternal _BytesValue_default_instance_; class DoubleValue; +class DoubleValueDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern DoubleValueDefaultTypeInternal _DoubleValue_default_instance_; class FloatValue; +class FloatValueDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern FloatValueDefaultTypeInternal _FloatValue_default_instance_; class Int32Value; +class Int32ValueDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern Int32ValueDefaultTypeInternal _Int32Value_default_instance_; class Int64Value; +class Int64ValueDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern Int64ValueDefaultTypeInternal _Int64Value_default_instance_; class StringValue; +class StringValueDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern StringValueDefaultTypeInternal _StringValue_default_instance_; class UInt32Value; +class UInt32ValueDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_; class UInt64Value; +class UInt64ValueDefaultTypeInternal; +LIBPROTOBUF_EXPORT extern UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_; +} // namespace protobuf +} // namespace google + +namespace google { +namespace protobuf { + +namespace protobuf_google_2fprotobuf_2fwrappers_2eproto { +// Internal implementation detail -- do not call these. +struct LIBPROTOBUF_EXPORT TableStruct { + static const ::google::protobuf::uint32 offsets[]; + static void InitDefaultsImpl(); + static void Shutdown(); +}; +void LIBPROTOBUF_EXPORT AddDescriptors(); +void LIBPROTOBUF_EXPORT InitDefaults(); +} // namespace protobuf_google_2fprotobuf_2fwrappers_2eproto // =================================================================== @@ -62,47 +89,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +150,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; @@ -138,15 +171,8 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p typedef void DestructorSkippable_; double value_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; }; -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 +187,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +248,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; @@ -237,15 +269,8 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr typedef void DestructorSkippable_; float value_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; }; -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 +285,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +346,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; @@ -336,15 +367,8 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr typedef void DestructorSkippable_; ::google::protobuf::int64 value_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; }; -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 +383,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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; @@ -435,15 +465,8 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p typedef void DestructorSkippable_; ::google::protobuf::uint64 value_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; }; -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 +481,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +542,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; @@ -534,15 +563,8 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr typedef void DestructorSkippable_; ::google::protobuf::int32 value_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; }; -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 +579,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +640,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; @@ -633,15 +661,8 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p typedef void DestructorSkippable_; ::google::protobuf::uint32 value_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; }; -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 +677,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +738,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; @@ -732,15 +759,8 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro typedef void DestructorSkippable_; bool value_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; }; -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 +775,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +836,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; @@ -839,15 +865,8 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p typedef void DestructorSkippable_; ::google::protobuf::internal::ArenaStringPtr value_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; }; -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 +881,53 @@ 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 { - return InternalSerializeWithCachedSizesToArray(false, output); + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), 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 +942,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; @@ -946,15 +971,8 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr typedef void DestructorSkippable_; ::google::protobuf::internal::ArenaStringPtr value_; 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 void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - - void InitAsDefaultInstance(); + friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct; }; -extern ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> BytesValue_default_instance_; - // =================================================================== @@ -963,7 +981,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 +995,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 +1013,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 +1031,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 +1049,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 +1067,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 +1085,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 +1103,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 +1173,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 +1243,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 +1263,7 @@ inline const BytesValue* BytesValue::internal_default_instance() { // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google |