From cc8ca5b6a5478b40546d4206392eb1471454460d Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Mon, 19 Sep 2016 13:45:07 -0700 Subject: Integrate internal changes --- src/google/protobuf/any.pb.cc | 126 +- src/google/protobuf/any.pb.h | 14 +- src/google/protobuf/any.proto | 1 - src/google/protobuf/api.pb.cc | 399 +-- src/google/protobuf/api.pb.h | 51 +- src/google/protobuf/api.proto | 1 - src/google/protobuf/arena.cc | 10 +- src/google/protobuf/arena.h | 13 +- src/google/protobuf/arena_unittest.cc | 46 +- src/google/protobuf/compiler/code_generator.cc | 28 + src/google/protobuf/compiler/code_generator.h | 41 +- .../protobuf/compiler/command_line_interface.cc | 59 +- .../protobuf/compiler/command_line_interface.h | 5 + .../compiler/command_line_interface_unittest.cc | 86 + .../compiler/cpp/cpp_bootstrap_unittest.cc | 1 - src/google/protobuf/compiler/cpp/cpp_enum.cc | 2 +- src/google/protobuf/compiler/cpp/cpp_enum_field.cc | 39 +- src/google/protobuf/compiler/cpp/cpp_enum_field.h | 1 + src/google/protobuf/compiler/cpp/cpp_extension.cc | 30 +- src/google/protobuf/compiler/cpp/cpp_field.h | 7 + src/google/protobuf/compiler/cpp/cpp_file.cc | 163 +- src/google/protobuf/compiler/cpp/cpp_helpers.cc | 41 +- src/google/protobuf/compiler/cpp/cpp_helpers.h | 19 +- src/google/protobuf/compiler/cpp/cpp_map_field.cc | 3 +- src/google/protobuf/compiler/cpp/cpp_message.cc | 855 ++++-- src/google/protobuf/compiler/cpp/cpp_message.h | 10 + .../protobuf/compiler/cpp/cpp_message_field.cc | 49 +- .../protobuf/compiler/cpp/cpp_primitive_field.cc | 47 +- .../protobuf/compiler/cpp/cpp_primitive_field.h | 1 + .../protobuf/compiler/cpp/cpp_string_field.cc | 104 +- .../protobuf/compiler/cpp/cpp_string_field.h | 1 + src/google/protobuf/compiler/cpp/cpp_unittest.cc | 6 +- src/google/protobuf/compiler/java/java_file.cc | 2 - .../protobuf/compiler/java/java_map_field.cc | 38 +- .../protobuf/compiler/java/java_map_field_lite.cc | 6 +- src/google/protobuf/compiler/java/java_message.cc | 2 +- .../protobuf/compiler/java/java_message_builder.cc | 13 +- .../compiler/java/java_message_field_lite.cc | 1 + .../protobuf/compiler/java/java_message_lite.cc | 4 +- src/google/protobuf/compiler/java/java_service.cc | 20 +- src/google/protobuf/compiler/java/java_service.h | 3 + .../compiler/java/java_shared_code_generator.cc | 2 - src/google/protobuf/compiler/js/js_generator.cc | 777 +++-- src/google/protobuf/compiler/js/js_generator.h | 87 +- src/google/protobuf/compiler/main.cc | 10 + src/google/protobuf/compiler/plugin.cc | 39 +- src/google/protobuf/compiler/plugin.pb.cc | 340 ++- src/google/protobuf/compiler/plugin.pb.h | 47 +- .../protobuf/compiler/python/python_generator.cc | 19 +- src/google/protobuf/descriptor.cc | 198 +- src/google/protobuf/descriptor.h | 9 +- src/google/protobuf/descriptor.pb.cc | 3118 ++++++++++---------- src/google/protobuf/descriptor.pb.h | 516 ++-- src/google/protobuf/descriptor.proto | 25 +- src/google/protobuf/descriptor_unittest.cc | 76 +- src/google/protobuf/duration.pb.cc | 141 +- src/google/protobuf/duration.pb.h | 27 +- src/google/protobuf/duration.proto | 8 +- src/google/protobuf/dynamic_message.cc | 62 +- src/google/protobuf/empty.pb.cc | 101 +- src/google/protobuf/empty.pb.h | 14 +- src/google/protobuf/empty.proto | 1 - src/google/protobuf/extension_set.cc | 21 +- src/google/protobuf/extension_set.h | 8 +- src/google/protobuf/extension_set_heavy.cc | 10 +- src/google/protobuf/extension_set_unittest.cc | 2 +- src/google/protobuf/field_mask.pb.cc | 121 +- src/google/protobuf/field_mask.pb.h | 14 +- src/google/protobuf/field_mask.proto | 7 +- .../protobuf/generated_message_reflection.cc | 165 +- src/google/protobuf/generated_message_reflection.h | 34 +- src/google/protobuf/generated_message_util.cc | 6 +- src/google/protobuf/generated_message_util.h | 64 +- src/google/protobuf/has_bits.h | 72 + src/google/protobuf/io/coded_stream.cc | 45 +- src/google/protobuf/io/coded_stream.h | 14 +- src/google/protobuf/io/coded_stream_unittest.cc | 1 + src/google/protobuf/io/zero_copy_stream_impl.h | 12 +- src/google/protobuf/map.h | 12 +- src/google/protobuf/map_entry.h | 4 +- src/google/protobuf/map_entry_lite.h | 6 +- src/google/protobuf/map_type_handler.h | 4 +- src/google/protobuf/message.cc | 10 +- src/google/protobuf/message.h | 10 +- src/google/protobuf/message_lite.cc | 39 +- src/google/protobuf/message_lite.h | 7 +- src/google/protobuf/message_unittest.cc | 36 + src/google/protobuf/metadata.h | 4 - src/google/protobuf/reflection.h | 29 +- src/google/protobuf/reflection_ops.h | 2 +- src/google/protobuf/repeated_field.cc | 18 +- src/google/protobuf/repeated_field.h | 39 +- src/google/protobuf/repeated_field_unittest.cc | 46 +- src/google/protobuf/source_context.pb.cc | 110 +- src/google/protobuf/source_context.pb.h | 14 +- src/google/protobuf/source_context.proto | 1 - src/google/protobuf/struct.pb.cc | 559 +++- src/google/protobuf/struct.pb.h | 250 +- src/google/protobuf/struct.proto | 2 +- src/google/protobuf/stubs/port.h | 55 + src/google/protobuf/stubs/strutil.cc | 15 + src/google/protobuf/stubs/strutil.h | 4 +- src/google/protobuf/text_format.cc | 35 +- src/google/protobuf/text_format.h | 12 +- src/google/protobuf/text_format_unittest.cc | 99 +- src/google/protobuf/timestamp.pb.cc | 119 +- src/google/protobuf/timestamp.pb.h | 14 +- src/google/protobuf/timestamp.proto | 9 +- src/google/protobuf/type.pb.cc | 1365 ++++++--- src/google/protobuf/type.pb.h | 615 +++- src/google/protobuf/type.proto | 2 +- src/google/protobuf/unittest.proto | 8 + src/google/protobuf/unknown_field_set.cc | 7 + src/google/protobuf/unknown_field_set.h | 16 +- src/google/protobuf/util/field_comparator.h | 2 +- src/google/protobuf/util/internal/datapiece.cc | 32 +- src/google/protobuf/util/internal/datapiece.h | 33 +- .../util/internal/default_value_objectwriter.cc | 41 +- src/google/protobuf/util/internal/error_listener.h | 4 +- .../protobuf/util/internal/json_objectwriter.cc | 21 +- .../protobuf/util/internal/json_objectwriter.h | 20 +- .../util/internal/json_objectwriter_test.cc | 4 +- .../protobuf/util/internal/json_stream_parser.cc | 44 +- .../protobuf/util/internal/json_stream_parser.h | 8 + .../util/internal/json_stream_parser_test.cc | 18 +- src/google/protobuf/util/internal/object_writer.h | 7 + src/google/protobuf/util/internal/proto_writer.cc | 9 +- src/google/protobuf/util/internal/proto_writer.h | 8 + .../util/internal/protostream_objectsource.cc | 11 +- .../util/internal/protostream_objectsource.h | 43 +- .../util/internal/protostream_objectsource_test.cc | 66 +- .../util/internal/protostream_objectwriter.cc | 131 +- .../util/internal/protostream_objectwriter.h | 62 +- .../util/internal/protostream_objectwriter_test.cc | 459 ++- .../protobuf/util/internal/testdata/anys.proto | 69 +- .../protobuf/util/internal/testdata/books.proto | 5 + .../protobuf/util/internal/testdata/maps.proto | 76 +- .../protobuf/util/internal/testdata/oneofs.proto | 31 +- .../protobuf/util/internal/testdata/proto3.proto | 42 + .../protobuf/util/internal/testdata/struct.proto | 86 +- .../internal/testdata/timestamp_duration.proto | 47 +- src/google/protobuf/util/internal/utility.cc | 41 + src/google/protobuf/util/internal/utility.h | 11 + src/google/protobuf/util/message_differencer.h | 126 +- src/google/protobuf/wire_format.cc | 39 +- src/google/protobuf/wire_format.h | 17 +- src/google/protobuf/wire_format_lite.cc | 2 +- src/google/protobuf/wire_format_lite.h | 53 +- src/google/protobuf/wire_format_lite_inl.h | 44 +- src/google/protobuf/wrappers.pb.cc | 695 +++-- src/google/protobuf/wrappers.pb.h | 118 +- src/google/protobuf/wrappers.proto | 1 - 152 files changed, 9431 insertions(+), 5233 deletions(-) create mode 100644 src/google/protobuf/has_bits.h create mode 100644 src/google/protobuf/util/internal/testdata/proto3.proto (limited to 'src/google/protobuf') diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index 80e96528..fa9d18a2 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -44,20 +44,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto() { Any_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Any_descriptor_, - Any::default_instance_, + Any::internal_default_instance(), Any_offsets_, -1, -1, -1, sizeof(Any), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_)); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { +void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto); } @@ -66,37 +65,49 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Any_descriptor_, &Any::default_instance()); + Any_descriptor_, Any::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto() { - delete Any::default_instance_; delete Any_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::internal::GetEmptyString(); + Any::default_instance_.DefaultConstruct(); + Any::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\031google/protobuf/any.proto\022\017google.prot" "obuf\"&\n\003Any\022\020\n\010type_url\030\001 \001(\t\022\r\n\005value\030\002" - " \001(\014Br\n\023com.google.protobufB\010AnyProtoP\001Z" - "%github.com/golang/protobuf/ptypes/any\240\001" - "\001\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypes" - "b\006proto3", 208); + " \001(\014Bo\n\023com.google.protobufB\010AnyProtoP\001Z" + "%github.com/golang/protobuf/ptypes/any\242\002" + "\003GPB\252\002\036Google.Protobuf.WellKnownTypesb\006p" + "roto3", 205); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/any.proto", &protobuf_RegisterTypes); - Any::default_instance_ = new Any(); - Any::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto() { @@ -104,6 +115,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fany_2eproto_; +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; +static void MergeFromFail(int line) { + ::google::protobuf::internal::MergeFromFail(__FILE__, line); +} + +} // namespace + + // =================================================================== void Any::PackFrom(const ::google::protobuf::Message& message) { @@ -126,12 +147,12 @@ const int Any::kValueFieldNumber; Any::Any() : ::google::protobuf::Message(), _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Any) } void Any::InitAsDefaultInstance() { - _is_default_instance_ = true; } Any::Any(const Any& from) @@ -139,16 +160,14 @@ Any::Any(const Any& from) _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Any) } void Any::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + _cached_size_ = 0; } Any::~Any() { @@ -159,8 +178,6 @@ Any::~Any() { void Any::SharedDtor() { type_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void Any::SetCachedSize(int size) const { @@ -174,11 +191,11 @@ const ::google::protobuf::Descriptor* Any::descriptor() { } const Any& Any::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); + return *internal_default_instance(); } -Any* Any::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Any::default_instance_; Any* Any::New(::google::protobuf::Arena* arena) const { Any* n = new Any; @@ -302,9 +319,9 @@ void Any::SerializeWithCachedSizes( return target; } -int Any::ByteSize() const { +size_t Any::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Any) - int total_size = 0; + size_t total_size = 0; // optional string type_url = 1; if (this->type_url().size() > 0) { @@ -320,18 +337,17 @@ int Any::ByteSize() const { this->value()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Any::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Any) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Any* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Any* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -339,15 +355,21 @@ void Any::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Any) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Any::MergeFrom(const Any& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Any::UnsafeMergeFrom(const Any& from) { + GOOGLE_DCHECK(&from != this); if (from.type_url().size() > 0) { type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_); @@ -369,7 +391,7 @@ void Any::CopyFrom(const Any& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Any) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Any::IsInitialized() const { @@ -403,37 +425,37 @@ void Any::InternalSwap(Any* other) { void Any::clear_type_url() { type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Any::type_url() const { +const ::std::string& Any::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.type_url) return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Any::set_type_url(const ::std::string& value) { +void Any::set_type_url(const ::std::string& value) { type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url) } - void Any::set_type_url(const char* value) { +void Any::set_type_url(const char* value) { type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Any.type_url) } - void Any::set_type_url(const char* value, size_t size) { +void Any::set_type_url(const char* value, size_t size) { type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.type_url) } - ::std::string* Any::mutable_type_url() { +::std::string* Any::mutable_type_url() { // @@protoc_insertion_point(field_mutable:google.protobuf.Any.type_url) return type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Any::release_type_url() { +::std::string* Any::release_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Any.type_url) return type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Any::set_allocated_type_url(::std::string* type_url) { +void Any::set_allocated_type_url(::std::string* type_url) { if (type_url != NULL) { } else { @@ -447,37 +469,37 @@ void Any::clear_type_url() { void Any::clear_value() { value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Any::value() const { +const ::std::string& Any::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.value) return value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Any::set_value(const ::std::string& value) { +void Any::set_value(const ::std::string& value) { value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Any.value) } - void Any::set_value(const char* value) { +void Any::set_value(const char* value) { value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Any.value) } - void Any::set_value(const void* value, size_t size) { +void Any::set_value(const void* value, size_t size) { value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.value) } - ::std::string* Any::mutable_value() { +::std::string* Any::mutable_value() { // @@protoc_insertion_point(field_mutable:google.protobuf.Any.value) return value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Any::release_value() { +::std::string* Any::release_value() { // @@protoc_insertion_point(field_release:google.protobuf.Any.value) return value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Any::set_allocated_value(::std::string* value) { +void Any::set_allocated_value(::std::string* value) { if (value != NULL) { } else { diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 4ccdfb24..e4061bc7 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -35,6 +35,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto(); @@ -57,6 +58,10 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in static const ::google::protobuf::Descriptor* descriptor(); static const Any& default_instance(); + static inline const Any* internal_default_instance() { + return &default_instance_.get(); + } + // implements Any ----------------------------------------------- void PackFrom(const ::google::protobuf::Message& message); @@ -81,7 +86,7 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -97,6 +102,7 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Any* other); + void UnsafeMergeFrom(const Any& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -138,17 +144,17 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; ::google::protobuf::internal::ArenaStringPtr type_url_; ::google::protobuf::internal::ArenaStringPtr value_; mutable int _cached_size_; ::google::protobuf::internal::AnyMetadata _any_metadata_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto(); void InitAsDefaultInstance(); - static Any* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/any.proto b/src/google/protobuf/any.proto index 81dcf46c..9bd3f50a 100644 --- a/src/google/protobuf/any.proto +++ b/src/google/protobuf/any.proto @@ -37,7 +37,6 @@ option go_package = "github.com/golang/protobuf/ptypes/any"; option java_package = "com.google.protobuf"; option java_outer_classname = "AnyProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; // `Any` contains an arbitrary serialized protocol buffer message along with a diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index d7fb644c..bd85bbdb 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -55,14 +55,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() { Api_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Api_descriptor_, - Api::default_instance_, + Api::internal_default_instance(), Api_offsets_, -1, -1, -1, sizeof(Api), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_)); Method_descriptor_ = file->message_type(1); static const int Method_offsets_[7] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, name_), @@ -76,14 +75,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() { Method_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Method_descriptor_, - Method::default_instance_, + Method::internal_default_instance(), Method_offsets_, -1, -1, -1, sizeof(Method), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_)); Mixin_descriptor_ = file->message_type(2); static const int Mixin_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, name_), @@ -92,20 +90,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() { Mixin_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Mixin_descriptor_, - Mixin::default_instance_, + Mixin::internal_default_instance(), Mixin_offsets_, -1, -1, -1, sizeof(Mixin), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_)); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { +void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto); } @@ -114,33 +111,46 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Api_descriptor_, &Api::default_instance()); + Api_descriptor_, Api::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Method_descriptor_, &Method::default_instance()); + Method_descriptor_, Method::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Mixin_descriptor_, &Mixin::default_instance()); + Mixin_descriptor_, Mixin::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto() { - delete Api::default_instance_; delete Api_reflection_; - delete Method::default_instance_; delete Method_reflection_; - delete Mixin::default_instance_; delete Mixin_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); + ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); + ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + ::google::protobuf::internal::GetEmptyString(); + Api::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + Method::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + Mixin::default_instance_.DefaultConstruct(); + Api::default_instance_.get_mutable()->InitAsDefaultInstance(); + Method::default_instance_.get_mutable()->InitAsDefaultInstance(); + Mixin::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\031google/protobuf/api.proto\022\017google.prot" "obuf\032$google/protobuf/source_context.pro" @@ -157,20 +167,21 @@ void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() { "esponse_streaming\030\005 \001(\010\022(\n\007options\030\006 \003(\013" "2\027.google.protobuf.Option\022\'\n\006syntax\030\007 \001(" "\0162\027.google.protobuf.Syntax\"#\n\005Mixin\022\014\n\004n" - "ame\030\001 \001(\t\022\014\n\004root\030\002 \001(\tBK\n\023com.google.pr" - "otobufB\010ApiProtoP\001\240\001\001\242\002\003GPB\252\002\036Google.Pro" - "tobuf.WellKnownTypesb\006proto3", 708); + "ame\030\001 \001(\t\022\014\n\004root\030\002 \001(\tBH\n\023com.google.pr" + "otobufB\010ApiProtoP\001\242\002\003GPB\252\002\036Google.Protob" + "uf.WellKnownTypesb\006proto3", 705); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/api.proto", &protobuf_RegisterTypes); - Api::default_instance_ = new Api(); - Method::default_instance_ = new Method(); - Mixin::default_instance_ = new Mixin(); - Api::default_instance_->InitAsDefaultInstance(); - Method::default_instance_->InitAsDefaultInstance(); - Mixin::default_instance_->InitAsDefaultInstance(); + ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); + ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto() { @@ -178,6 +189,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fapi_2eproto_; +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; +static void MergeFromFail(int line) { + ::google::protobuf::internal::MergeFromFail(__FILE__, line); +} + +} // namespace + + // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -192,31 +213,30 @@ const int Api::kSyntaxFieldNumber; Api::Api() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Api) } void Api::InitAsDefaultInstance() { - _is_default_instance_ = true; - source_context_ = const_cast< ::google::protobuf::SourceContext*>(&::google::protobuf::SourceContext::default_instance()); + source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); } Api::Api(const Api& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Api) } void Api::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); version_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); source_context_ = NULL; syntax_ = 0; + _cached_size_ = 0; } Api::~Api() { @@ -227,9 +247,7 @@ Api::~Api() { void Api::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); version_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete source_context_; - } + delete source_context_; } void Api::SetCachedSize(int size) const { @@ -243,11 +261,11 @@ const ::google::protobuf::Descriptor* Api::descriptor() { } const Api& Api::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + return *internal_default_instance(); } -Api* Api::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Api::default_instance_; Api* Api::New(::google::protobuf::Arena* arena) const { Api* n = new Api; @@ -532,9 +550,9 @@ void Api::SerializeWithCachedSizes( return target; } -int Api::ByteSize() const { +size_t Api::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Api) - int total_size = 0; + size_t total_size = 0; // optional string name = 1; if (this->name().size() > 0) { @@ -564,41 +582,49 @@ int Api::ByteSize() const { } // repeated .google.protobuf.Method methods = 2; - total_size += 1 * this->methods_size(); - for (int i = 0; i < this->methods_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->methods(i)); + { + unsigned int count = this->methods_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->methods(i)); + } } // repeated .google.protobuf.Option options = 3; - total_size += 1 * this->options_size(); - for (int i = 0; i < this->options_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(i)); + } } // repeated .google.protobuf.Mixin mixins = 6; - total_size += 1 * this->mixins_size(); - for (int i = 0; i < this->mixins_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->mixins(i)); + { + unsigned int count = this->mixins_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->mixins(i)); + } } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Api::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Api) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Api* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Api* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -606,15 +632,21 @@ void Api::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Api) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Api::MergeFrom(const Api& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Api) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Api::UnsafeMergeFrom(const Api& from) { + GOOGLE_DCHECK(&from != this); methods_.MergeFrom(from.methods_); options_.MergeFrom(from.options_); mixins_.MergeFrom(from.mixins_); @@ -645,7 +677,7 @@ void Api::CopyFrom(const Api& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Api) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Api::IsInitialized() const { @@ -684,37 +716,37 @@ void Api::InternalSwap(Api* other) { void Api::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Api::name() const { +const ::std::string& Api::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Api::set_name(const ::std::string& value) { +void Api::set_name(const ::std::string& value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Api.name) } - void Api::set_name(const char* value) { +void Api::set_name(const char* value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Api.name) } - void Api::set_name(const char* value, size_t size) { +void Api::set_name(const char* value, size_t size) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.name) } - ::std::string* Api::mutable_name() { +::std::string* Api::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Api.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Api::release_name() { +::std::string* Api::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Api.name) return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Api::set_allocated_name(::std::string* name) { +void Api::set_allocated_name(::std::string* name) { if (name != NULL) { } else { @@ -788,37 +820,37 @@ Api::options() const { void Api::clear_version() { version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Api::version() const { +const ::std::string& Api::version() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.version) return version_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Api::set_version(const ::std::string& value) { +void Api::set_version(const ::std::string& value) { version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Api.version) } - void Api::set_version(const char* value) { +void Api::set_version(const char* value) { version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Api.version) } - void Api::set_version(const char* value, size_t size) { +void Api::set_version(const char* value, size_t size) { version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.version) } - ::std::string* Api::mutable_version() { +::std::string* Api::mutable_version() { // @@protoc_insertion_point(field_mutable:google.protobuf.Api.version) return version_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Api::release_version() { +::std::string* Api::release_version() { // @@protoc_insertion_point(field_release:google.protobuf.Api.version) return version_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Api::set_allocated_version(::std::string* version) { +void Api::set_allocated_version(::std::string* version) { if (version != NULL) { } else { @@ -830,7 +862,7 @@ void Api::clear_version() { // optional .google.protobuf.SourceContext source_context = 5; bool Api::has_source_context() const { - return !_is_default_instance_ && source_context_ != NULL; + return this != internal_default_instance() && source_context_ != NULL; } void Api::clear_source_context() { if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; @@ -838,7 +870,8 @@ void Api::clear_source_context() { } const ::google::protobuf::SourceContext& Api::source_context() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.source_context) - return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_; + return source_context_ != NULL ? *source_context_ + : *::google::protobuf::SourceContext::internal_default_instance(); } ::google::protobuf::SourceContext* Api::mutable_source_context() { @@ -900,11 +933,11 @@ Api::mixins() const { void Api::clear_syntax() { syntax_ = 0; } - ::google::protobuf::Syntax Api::syntax() const { +::google::protobuf::Syntax Api::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.syntax) return static_cast< ::google::protobuf::Syntax >(syntax_); } - void Api::set_syntax(::google::protobuf::Syntax value) { +void Api::set_syntax(::google::protobuf::Syntax value) { syntax_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Api.syntax) @@ -926,32 +959,29 @@ const int Method::kSyntaxFieldNumber; Method::Method() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Method) } void Method::InitAsDefaultInstance() { - _is_default_instance_ = true; } Method::Method(const Method& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Method) } void Method::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); request_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - request_streaming_ = false; response_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - response_streaming_ = false; - syntax_ = 0; + ::memset(&request_streaming_, 0, reinterpret_cast(&syntax_) - + reinterpret_cast(&request_streaming_) + sizeof(syntax_)); + _cached_size_ = 0; } Method::~Method() { @@ -963,8 +993,6 @@ void Method::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); request_type_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); response_type_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void Method::SetCachedSize(int size) const { @@ -978,11 +1006,11 @@ const ::google::protobuf::Descriptor* Method::descriptor() { } const Method& Method::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + return *internal_default_instance(); } -Method* Method::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Method::default_instance_; Method* Method::New(::google::protobuf::Arena* arena) const { Method* n = new Method; @@ -1068,10 +1096,10 @@ bool Method::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_request_streaming: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &request_streaming_))); - } else { goto handle_unusual; } @@ -1100,10 +1128,10 @@ bool Method::MergePartialFromCodedStream( case 5: { if (tag == 40) { parse_response_streaming: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &response_streaming_))); - } else { goto handle_unusual; } @@ -1287,9 +1315,9 @@ void Method::SerializeWithCachedSizes( return target; } -int Method::ByteSize() const { +size_t Method::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Method) - int total_size = 0; + size_t total_size = 0; // optional string name = 1; if (this->name().size() > 0) { @@ -1329,25 +1357,27 @@ int Method::ByteSize() const { } // repeated .google.protobuf.Option options = 6; - total_size += 1 * this->options_size(); - for (int i = 0; i < this->options_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(i)); + } } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Method::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Method) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Method* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Method* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -1355,15 +1385,21 @@ void Method::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Method) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Method::MergeFrom(const Method& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Method) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Method::UnsafeMergeFrom(const Method& from) { + GOOGLE_DCHECK(&from != this); options_.MergeFrom(from.options_); if (from.name().size() > 0) { @@ -1399,7 +1435,7 @@ void Method::CopyFrom(const Method& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Method) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Method::IsInitialized() const { @@ -1438,37 +1474,37 @@ void Method::InternalSwap(Method* other) { void Method::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Method::name() const { +const ::std::string& Method::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Method::set_name(const ::std::string& value) { +void Method::set_name(const ::std::string& value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Method.name) } - void Method::set_name(const char* value) { +void Method::set_name(const char* value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Method.name) } - void Method::set_name(const char* value, size_t size) { +void Method::set_name(const char* value, size_t size) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.name) } - ::std::string* Method::mutable_name() { +::std::string* Method::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Method.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Method::release_name() { +::std::string* Method::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Method.name) return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Method::set_allocated_name(::std::string* name) { +void Method::set_allocated_name(::std::string* name) { if (name != NULL) { } else { @@ -1482,37 +1518,37 @@ void Method::clear_name() { void Method::clear_request_type_url() { request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Method::request_type_url() const { +const ::std::string& Method::request_type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url) return request_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Method::set_request_type_url(const ::std::string& value) { +void Method::set_request_type_url(const ::std::string& value) { request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url) } - void Method::set_request_type_url(const char* value) { +void Method::set_request_type_url(const char* value) { request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Method.request_type_url) } - void Method::set_request_type_url(const char* value, size_t size) { +void Method::set_request_type_url(const char* value, size_t size) { request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.request_type_url) } - ::std::string* Method::mutable_request_type_url() { +::std::string* Method::mutable_request_type_url() { // @@protoc_insertion_point(field_mutable:google.protobuf.Method.request_type_url) return request_type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Method::release_request_type_url() { +::std::string* Method::release_request_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Method.request_type_url) return request_type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Method::set_allocated_request_type_url(::std::string* request_type_url) { +void Method::set_allocated_request_type_url(::std::string* request_type_url) { if (request_type_url != NULL) { } else { @@ -1526,11 +1562,11 @@ void Method::clear_request_type_url() { void Method::clear_request_streaming() { request_streaming_ = false; } - bool Method::request_streaming() const { +bool Method::request_streaming() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.request_streaming) return request_streaming_; } - void Method::set_request_streaming(bool value) { +void Method::set_request_streaming(bool value) { request_streaming_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming) @@ -1540,37 +1576,37 @@ void Method::clear_request_streaming() { void Method::clear_response_type_url() { response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Method::response_type_url() const { +const ::std::string& Method::response_type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url) return response_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Method::set_response_type_url(const ::std::string& value) { +void Method::set_response_type_url(const ::std::string& value) { response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url) } - void Method::set_response_type_url(const char* value) { +void Method::set_response_type_url(const char* value) { response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Method.response_type_url) } - void Method::set_response_type_url(const char* value, size_t size) { +void Method::set_response_type_url(const char* value, size_t size) { response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.response_type_url) } - ::std::string* Method::mutable_response_type_url() { +::std::string* Method::mutable_response_type_url() { // @@protoc_insertion_point(field_mutable:google.protobuf.Method.response_type_url) return response_type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Method::release_response_type_url() { +::std::string* Method::release_response_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Method.response_type_url) return response_type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Method::set_allocated_response_type_url(::std::string* response_type_url) { +void Method::set_allocated_response_type_url(::std::string* response_type_url) { if (response_type_url != NULL) { } else { @@ -1584,11 +1620,11 @@ void Method::clear_response_type_url() { void Method::clear_response_streaming() { response_streaming_ = false; } - bool Method::response_streaming() const { +bool Method::response_streaming() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.response_streaming) return response_streaming_; } - void Method::set_response_streaming(bool value) { +void Method::set_response_streaming(bool value) { response_streaming_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Method.response_streaming) @@ -1628,11 +1664,11 @@ Method::options() const { void Method::clear_syntax() { syntax_ = 0; } - ::google::protobuf::Syntax Method::syntax() const { +::google::protobuf::Syntax Method::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.syntax) return static_cast< ::google::protobuf::Syntax >(syntax_); } - void Method::set_syntax(::google::protobuf::Syntax value) { +void Method::set_syntax(::google::protobuf::Syntax value) { syntax_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Method.syntax) @@ -1649,28 +1685,26 @@ const int Mixin::kRootFieldNumber; Mixin::Mixin() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Mixin) } void Mixin::InitAsDefaultInstance() { - _is_default_instance_ = true; } Mixin::Mixin(const Mixin& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin) } void Mixin::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); root_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + _cached_size_ = 0; } Mixin::~Mixin() { @@ -1681,8 +1715,6 @@ Mixin::~Mixin() { void Mixin::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); root_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void Mixin::SetCachedSize(int size) const { @@ -1696,11 +1728,11 @@ const ::google::protobuf::Descriptor* Mixin::descriptor() { } const Mixin& Mixin::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + return *internal_default_instance(); } -Mixin* Mixin::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Mixin::default_instance_; Mixin* Mixin::New(::google::protobuf::Arena* arena) const { Mixin* n = new Mixin; @@ -1836,9 +1868,9 @@ void Mixin::SerializeWithCachedSizes( return target; } -int Mixin::ByteSize() const { +size_t Mixin::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Mixin) - int total_size = 0; + size_t total_size = 0; // optional string name = 1; if (this->name().size() > 0) { @@ -1854,18 +1886,17 @@ int Mixin::ByteSize() const { this->root()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Mixin::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Mixin) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Mixin* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Mixin* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -1873,15 +1904,21 @@ void Mixin::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Mixin) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Mixin::MergeFrom(const Mixin& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Mixin) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Mixin::UnsafeMergeFrom(const Mixin& from) { + GOOGLE_DCHECK(&from != this); if (from.name().size() > 0) { name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -1903,7 +1940,7 @@ void Mixin::CopyFrom(const Mixin& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Mixin) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Mixin::IsInitialized() const { @@ -1937,37 +1974,37 @@ void Mixin::InternalSwap(Mixin* other) { void Mixin::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Mixin::name() const { +const ::std::string& Mixin::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Mixin::set_name(const ::std::string& value) { +void Mixin::set_name(const ::std::string& value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name) } - void Mixin::set_name(const char* value) { +void Mixin::set_name(const char* value) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.name) } - void Mixin::set_name(const char* value, size_t size) { +void Mixin::set_name(const char* value, size_t size) { name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.name) } - ::std::string* Mixin::mutable_name() { +::std::string* Mixin::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Mixin::release_name() { +::std::string* Mixin::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Mixin.name) return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Mixin::set_allocated_name(::std::string* name) { +void Mixin::set_allocated_name(::std::string* name) { if (name != NULL) { } else { @@ -1981,37 +2018,37 @@ void Mixin::clear_name() { void Mixin::clear_root() { root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& Mixin::root() const { +const ::std::string& Mixin::root() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root) return root_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Mixin::set_root(const ::std::string& value) { +void Mixin::set_root(const ::std::string& value) { root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root) } - void Mixin::set_root(const char* value) { +void Mixin::set_root(const char* value) { root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.root) } - void Mixin::set_root(const char* value, size_t size) { +void Mixin::set_root(const char* value, size_t size) { root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.root) } - ::std::string* Mixin::mutable_root() { +::std::string* Mixin::mutable_root() { // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.root) return root_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Mixin::release_root() { +::std::string* Mixin::release_root() { // @@protoc_insertion_point(field_release:google.protobuf.Mixin.root) return root_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Mixin::set_allocated_root(::std::string* root) { +void Mixin::set_allocated_root(::std::string* root) { if (root != NULL) { } else { diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 917f888b..ac18055d 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -36,6 +36,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); @@ -60,6 +61,10 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in static const ::google::protobuf::Descriptor* descriptor(); static const Api& default_instance(); + static inline const Api* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(Api* other); // implements Message ---------------------------------------------- @@ -74,7 +79,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -90,6 +95,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Api* other); + void UnsafeMergeFrom(const Api& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -182,21 +188,21 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; - ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method > methods_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin > mixins_; + ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr version_; ::google::protobuf::SourceContext* source_context_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin > mixins_; int syntax_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); void InitAsDefaultInstance(); - static Api* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -215,6 +221,10 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc static const ::google::protobuf::Descriptor* descriptor(); static const Method& default_instance(); + static inline const Method* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(Method* other); // implements Message ---------------------------------------------- @@ -229,7 +239,7 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -245,6 +255,7 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Method* other); + void UnsafeMergeFrom(const Method& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -327,21 +338,21 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr request_type_url_; ::google::protobuf::internal::ArenaStringPtr response_type_url_; bool request_streaming_; bool response_streaming_; int syntax_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); void InitAsDefaultInstance(); - static Method* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -360,6 +371,10 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ static const ::google::protobuf::Descriptor* descriptor(); static const Mixin& default_instance(); + static inline const Mixin* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(Mixin* other); // implements Message ---------------------------------------------- @@ -374,7 +389,7 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -390,6 +405,7 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Mixin* other); + void UnsafeMergeFrom(const Mixin& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -431,16 +447,16 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr root_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); void InitAsDefaultInstance(); - static Mixin* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // =================================================================== @@ -600,7 +616,7 @@ inline void Api::set_allocated_version(::std::string* version) { // optional .google.protobuf.SourceContext source_context = 5; inline bool Api::has_source_context() const { - return !_is_default_instance_ && source_context_ != NULL; + return this != internal_default_instance() && source_context_ != NULL; } inline void Api::clear_source_context() { if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; @@ -608,7 +624,8 @@ inline void Api::clear_source_context() { } inline const ::google::protobuf::SourceContext& Api::source_context() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.source_context) - return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_; + return source_context_ != NULL ? *source_context_ + : *::google::protobuf::SourceContext::internal_default_instance(); } inline ::google::protobuf::SourceContext* Api::mutable_source_context() { diff --git a/src/google/protobuf/api.proto b/src/google/protobuf/api.proto index dbe87b8f..bbbe9833 100644 --- a/src/google/protobuf/api.proto +++ b/src/google/protobuf/api.proto @@ -39,7 +39,6 @@ option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option java_package = "com.google.protobuf"; option java_outer_classname = "ApiProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; // Api is a light-weight descriptor for a protocol buffer service. diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index 78e20946..aa4e587c 100755 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc @@ -30,6 +30,9 @@ #include +#include +#include + #ifdef ADDRESS_SANITIZER #include @@ -125,10 +128,9 @@ Arena::Block* Arena::NewBlock(void* me, Block* my_last_block, size_t n, } else { size = start_block_size; } - if (n > size - kHeaderSize) { - // TODO(sanjay): Check if n + kHeaderSize would overflow - size = kHeaderSize + n; - } + // Verify that n + kHeaderSize won't overflow. + GOOGLE_CHECK_LE(n, std::numeric_limits::max() - kHeaderSize); + size = std::max(size, kHeaderSize + n); Block* b = reinterpret_cast(options_.block_alloc(size)); b->pos = kHeaderSize + n; diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 0a5eacee..f05277ed 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -79,8 +79,12 @@ template void arena_destruct_object(void* object) { template void arena_delete_object(void* object) { delete reinterpret_cast(object); } -inline void arena_free(void* object, size_t /* size */) { - free(object); +inline void arena_free(void* object, size_t size) { +#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) + ::operator delete(object, size); +#else + ::operator delete(object); +#endif } } // namespace internal @@ -144,7 +148,7 @@ struct ArenaOptions { max_block_size(kDefaultMaxBlockSize), initial_block(NULL), initial_block_size(0), - block_alloc(&malloc), + block_alloc(&::operator new), block_dealloc(&internal::arena_free), on_arena_init(NULL), on_arena_reset(NULL), @@ -454,7 +458,7 @@ class LIBPROTOBUF_EXPORT Arena { // Combines SpaceAllocated and SpaceUsed. Returns a pair of // . - GOOGLE_ATTRIBUTE_NOINLINE pair SpaceAllocatedAndUsed() const; + GOOGLE_ATTRIBUTE_NOINLINE std::pair SpaceAllocatedAndUsed() const; // Frees all storage allocated by this arena after calling destructors // registered with OwnDestructor() and freeing objects registered with Own(). @@ -608,6 +612,7 @@ class LIBPROTOBUF_EXPORT Arena { const T>(static_cast(0))) == sizeof(char) || google::protobuf::internal::has_trivial_destructor::value> {}; + private: // CreateMessage requires that T supports arenas, but this private method // works whether or not T supports arenas. These are not exposed to user code // as it can cause confusing API usages, and end up having double free in diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc index 5f33e939..35d00463 100644 --- a/src/google/protobuf/arena_unittest.cc +++ b/src/google/protobuf/arena_unittest.cc @@ -151,8 +151,6 @@ class MustBeConstructedWithOneThroughEight { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MustBeConstructedWithOneThroughEight); }; -} // namespace - TEST(ArenaTest, ArenaConstructable) { EXPECT_TRUE(Arena::is_arena_constructable::type::value); EXPECT_TRUE(Arena::is_arena_constructable::type::value); @@ -893,6 +891,24 @@ TEST(ArenaTest, UnsafeArenaRelease) { delete s; } +TEST(ArenaTest, OneofMerge) { + Arena arena; + TestAllTypes* message0 = Arena::CreateMessage(&arena); + TestAllTypes* message1 = Arena::CreateMessage(&arena); + + message0->unsafe_arena_set_allocated_oneof_string(new string("x")); + ASSERT_TRUE(message0->has_oneof_string()); + message1->unsafe_arena_set_allocated_oneof_string(new string("y")); + ASSERT_TRUE(message1->has_oneof_string()); + EXPECT_EQ("x", message0->oneof_string()); + EXPECT_EQ("y", message1->oneof_string()); + message0->MergeFrom(*message1); + EXPECT_EQ("y", message0->oneof_string()); + EXPECT_EQ("y", message1->oneof_string()); + delete message0->unsafe_arena_release_oneof_string(); + delete message1->unsafe_arena_release_oneof_string(); +} + TEST(ArenaTest, ArenaOneofReflection) { Arena arena; TestAllTypes* message = Arena::CreateMessage(&arena); @@ -923,7 +939,6 @@ TEST(ArenaTest, ArenaOneofReflection) { delete submsg; } -namespace { void TestSwapRepeatedField(Arena* arena1, Arena* arena2) { // Test "safe" (copying) semantics for direct Swap() on RepeatedPtrField // between arenas. @@ -962,7 +977,6 @@ void TestSwapRepeatedField(Arena* arena1, Arena* arena2) { EXPECT_EQ(i, field2.Get(i).optional_int32()); } } -} // namespace TEST(ArenaTest, SwapRepeatedField) { Arena arena; @@ -1104,8 +1118,6 @@ TEST(ArenaTest, MutableMessageReflection) { #endif // !GOOGLE_PROTOBUF_NO_RTTI -namespace { - void FillArenaAwareFields(TestAllTypes* message) { string test_string = "hello world"; message->set_optional_int32(42); @@ -1124,8 +1136,6 @@ void FillArenaAwareFields(TestAllTypes* message) { message->mutable_optional_lazy_message()->set_bb(42); } -} - // Test: no allocations occur on heap while touching all supported field types. TEST(ArenaTest, NoHeapAllocationsTest) { // Allocate a large initial block to avoid mallocs during hooked test. @@ -1196,9 +1206,7 @@ TEST(ArenaTest, RepeatedFieldWithNonPODType) { } // Align n to next multiple of 8 -namespace { uint64 Align8(uint64 n) { return (n + 7) & -8; } -} // namespace TEST(ArenaTest, SpaceAllocated_and_Used) { ArenaOptions options; @@ -1249,6 +1257,22 @@ TEST(ArenaTest, Alignment) { } } +TEST(ArenaTest, BlockSizeSmallerThanAllocation) { + for (size_t i = 0; i <= 8; ++i) { + ::google::protobuf::ArenaOptions opt; + opt.start_block_size = opt.max_block_size = i; + ::google::protobuf::Arena arena(opt); + + *::google::protobuf::Arena::Create(&arena) = 42; + EXPECT_GE(arena.SpaceAllocated(), 8); + EXPECT_EQ(8, arena.SpaceUsed()); + + *::google::protobuf::Arena::Create(&arena) = 42; + EXPECT_GE(arena.SpaceAllocated(), 16); + EXPECT_EQ(16, arena.SpaceUsed()); + } +} + TEST(ArenaTest, GetArenaShouldReturnTheArenaForArenaAllocatedMessages) { ::google::protobuf::Arena arena; ArenaMessage* message = Arena::CreateMessage(&arena); @@ -1349,5 +1373,7 @@ TEST(ArenaTest, ArenaHooksSanity) { EXPECT_EQ(1, ArenaHooksTestUtil::num_destruct); } + +} // namespace } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/compiler/code_generator.cc b/src/google/protobuf/compiler/code_generator.cc index 473eb4e6..f6ff1e5d 100644 --- a/src/google/protobuf/compiler/code_generator.cc +++ b/src/google/protobuf/compiler/code_generator.cc @@ -36,6 +36,7 @@ #include #include +#include #include namespace google { @@ -43,6 +44,33 @@ namespace protobuf { namespace compiler { CodeGenerator::~CodeGenerator() {} + +bool CodeGenerator::GenerateAll( + const vector& files, + const string& parameter, + GeneratorContext* generator_context, + string* error) const { + // Default implemenation is just to call the per file method, and prefix any + // error string with the file to provide context. + bool succeeded = true; + for (int i = 0; i < files.size(); i++) { + const FileDescriptor* file = files[i]; + succeeded = Generate(file, parameter, generator_context, error); + if (!succeeded && error && error->empty()) { + *error = "Code generator returned false but provided no error " + "description."; + } + if (error && !error->empty()) { + *error = file->name() + ": " + *error; + break; + } + if (!succeeded) { + break; + } + } + return succeeded; +} + GeneratorContext::~GeneratorContext() {} io::ZeroCopyOutputStream* diff --git a/src/google/protobuf/compiler/code_generator.h b/src/google/protobuf/compiler/code_generator.h index b989f151..642bbfad 100644 --- a/src/google/protobuf/compiler/code_generator.h +++ b/src/google/protobuf/compiler/code_generator.h @@ -66,11 +66,11 @@ class LIBPROTOC_EXPORT CodeGenerator { // Generates code for the given proto file, generating one or more files in // the given output directory. // - // A parameter to be passed to the generator can be specified on the - // command line. This is intended to be used by Java and similar languages - // to specify which specific class from the proto file is to be generated, - // though it could have other uses as well. It is empty if no parameter was - // given. + // A parameter to be passed to the generator can be specified on the command + // line. This is intended to be used to pass generator specific parameters. + // It is empty if no parameter was given. ParseGeneratorParameter (below), + // can be used to accept multiple parameters within the single parameter + // command line flag. // // Returns true if successful. Otherwise, sets *error to a description of // the problem (e.g. "invalid parameter") and returns false. @@ -79,18 +79,11 @@ class LIBPROTOC_EXPORT CodeGenerator { GeneratorContext* generator_context, string* error) const = 0; - // Generates code for all given proto files, generating one or more files in - // the given output directory. - // - // This method should be called instead of |Generate()| when - // |HasGenerateAll()| returns |true|. It is used to emulate legacy semantics - // when more than one `.proto` file is specified on one compiler invocation. + // Generates code for all given proto files. // - // WARNING: Please do not use unless legacy semantics force the code generator - // to produce a single output file for all input files, or otherwise require - // an examination of all input files first. The canonical code generator - // design produces one output file per input .proto file, and we do not wish - // to encourage alternate designs. + // WARNING: The canonical code generator design produces one or two output + // files per input .proto file, and we do not wish to encourage alternate + // designs. // // A parameter is given as passed on the command line, as in |Generate()| // above. @@ -100,15 +93,13 @@ class LIBPROTOC_EXPORT CodeGenerator { virtual bool GenerateAll(const vector& files, const string& parameter, GeneratorContext* generator_context, - string* error) const { - *error = "Unimplemented GenerateAll() method."; - return false; - } - - // Returns true if the code generator expects to receive all FileDescriptors - // at once (via |GenerateAll()|), rather than one at a time (via - // |Generate()|). This is required to implement legacy semantics. - virtual bool HasGenerateAll() const { return false; } + string* error) const; + + // This is no longer used, but this class is part of the opensource protobuf + // library, so it has to remain to keep vtables the same for the current + // version of the library. When protobufs does a api breaking change, the + // method can be removed. + virtual bool HasGenerateAll() const { return true; } private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodeGenerator); diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index bb781b0a..0d1c30ce 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -704,6 +704,7 @@ CommandLineInterface::CommandLineInterface() : mode_(MODE_COMPILE), print_mode_(PRINT_NONE), error_format_(ERROR_FORMAT_GCC), + direct_dependencies_explicitly_set_(false), imports_in_descriptor_set_(false), source_info_in_descriptor_set_(false), disallow_services_(false), @@ -784,6 +785,24 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { "--disallow_services was used." << endl; return 1; } + + // Enforce --direct_dependencies + if (direct_dependencies_explicitly_set_) { + bool indirect_imports = false; + for (int i = 0; i < parsed_file->dependency_count(); i++) { + if (direct_dependencies_.find(parsed_file->dependency(i)->name()) == + direct_dependencies_.end()) { + indirect_imports = true; + cerr << parsed_file->name() + << ": File is imported but not declared in " + << "--direct_dependencies: " + << parsed_file->dependency(i)->name() << std::endl; + } + } + if (indirect_imports) { + return 1; + } + } } // We construct a separate GeneratorContext for each output location. Note @@ -897,6 +916,7 @@ void CommandLineInterface::Clear() { executable_name_.clear(); proto_path_.clear(); input_files_.clear(); + direct_dependencies_.clear(); output_directives_.clear(); codec_type_.clear(); descriptor_set_name_.clear(); @@ -907,6 +927,7 @@ void CommandLineInterface::Clear() { imports_in_descriptor_set_ = false; source_info_in_descriptor_set_ = false; disallow_services_ = false; + direct_dependencies_explicitly_set_ = false; } bool CommandLineInterface::MakeInputsBeProtoPathRelative( @@ -1154,6 +1175,21 @@ CommandLineInterface::InterpretArgument(const string& name, proto_path_.push_back(pair(virtual_path, disk_path)); } + } else if (name == "--direct_dependencies") { + if (direct_dependencies_explicitly_set_) { + std::cerr << name << " may only be passed once. To specify multiple " + "direct dependencies, pass them all as a single " + "parameter separated by '" + << kPathSeparator << "'." << std::endl; + return PARSE_ARGUMENT_FAIL; + } + + direct_dependencies_explicitly_set_ = true; + vector direct = Split( + value, kPathSeparator, true); + GOOGLE_DCHECK(direct_dependencies_.empty()); + direct_dependencies_.insert(direct.begin(), direct.end()); + } else if (name == "-o" || name == "--descriptor_set_out") { if (!descriptor_set_name_.empty()) { std::cerr << name << " may only be passed once." << std::endl; @@ -1447,24 +1483,11 @@ bool CommandLineInterface::GenerateOutput( } parameters.append(generator_parameters_[output_directive.name]); } - if (output_directive.generator->HasGenerateAll()) { - if (!output_directive.generator->GenerateAll( - parsed_files, parameters, generator_context, &error)) { - // Generator returned an error. - std::cerr << output_directive.name << ": " - << ": " << error << std::endl; - return false; - } - } else { - for (int i = 0; i < parsed_files.size(); i++) { - if (!output_directive.generator->Generate(parsed_files[i], parameters, - generator_context, &error)) { - // Generator returned an error. - std::cerr << output_directive.name << ": " << parsed_files[i]->name() - << ": " << error << std::endl; - return false; - } - } + if (!output_directive.generator->GenerateAll( + parsed_files, parameters, generator_context, &error)) { + // Generator returned an error. + std::cerr << output_directive.name << ": " << error << std::endl; + return false; } } diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h index 32084567..c38e65a3 100644 --- a/src/google/protobuf/compiler/command_line_interface.h +++ b/src/google/protobuf/compiler/command_line_interface.h @@ -352,6 +352,11 @@ class LIBPROTOC_EXPORT CommandLineInterface { vector > proto_path_; // Search path for proto files. vector 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 direct_dependencies_; + bool direct_dependencies_explicitly_set_; + // output_directives_ lists all the files we are supposed to output and what // generator to use for each. struct OutputDirective { diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index dee438c6..56a07dbf 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -871,6 +871,92 @@ TEST_F(CommandLineInterfaceTest, AllowServicesHasService) { ExpectGenerated("test_generator", "", "foo.proto", "Foo"); } +TEST_F(CommandLineInterfaceTest, DirectDependencies_Missing_EmptyList) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"bar.proto\";\n" + "message Foo { optional Bar bar = 1; }"); + CreateTempFile("bar.proto", + "syntax = \"proto2\";\n" + "message Bar { optional string text = 1; }"); + + Run("protocol_compiler --test_out=$tmpdir --proto_path=$tmpdir " + "--direct_dependencies= foo.proto"); + + ExpectErrorText( + "foo.proto: File is imported but not declared in --direct_dependencies: " + "bar.proto\n"); +} + +TEST_F(CommandLineInterfaceTest, DirectDependencies_Missing) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"bar.proto\";\n" + "import \"bla.proto\";\n" + "message Foo { optional Bar bar = 1; optional Bla bla = 2; }"); + CreateTempFile("bar.proto", + "syntax = \"proto2\";\n" + "message Bar { optional string text = 1; }"); + CreateTempFile("bla.proto", + "syntax = \"proto2\";\n" + "message Bla { optional int64 number = 1; }"); + + Run("protocol_compiler --test_out=$tmpdir --proto_path=$tmpdir " + "--direct_dependencies=bla.proto foo.proto"); + + ExpectErrorText( + "foo.proto: File is imported but not declared in --direct_dependencies: " + "bar.proto\n"); +} + +TEST_F(CommandLineInterfaceTest, DirectDependencies_NoViolation) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"bar.proto\";\n" + "message Foo { optional Bar bar = 1; }"); + CreateTempFile("bar.proto", + "syntax = \"proto2\";\n" + "message Bar { optional string text = 1; }"); + + Run("protocol_compiler --test_out=$tmpdir --proto_path=$tmpdir " + "--direct_dependencies=bar.proto foo.proto"); + + ExpectNoErrors(); +} + +TEST_F(CommandLineInterfaceTest, DirectDependencies_NoViolation_MultiImports) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"bar.proto\";\n" + "import \"bla.proto\";\n" + "message Foo { optional Bar bar = 1; optional Bla bla = 2; }"); + CreateTempFile("bar.proto", + "syntax = \"proto2\";\n" + "message Bar { optional string text = 1; }"); + CreateTempFile("bla.proto", + "syntax = \"proto2\";\n" + "message Bla { optional int64 number = 1; }"); + + Run("protocol_compiler --test_out=$tmpdir --proto_path=$tmpdir " + "--direct_dependencies=bar.proto:bla.proto foo.proto"); + + ExpectNoErrors(); +} + +TEST_F(CommandLineInterfaceTest, DirectDependencies_ProvidedMultipleTimes) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n"); + + Run("protocol_compiler --test_out=$tmpdir --proto_path=$tmpdir " + "--direct_dependencies=bar.proto --direct_dependencies=bla.proto " + "foo.proto"); + + ExpectErrorText( + "--direct_dependencies may only be passed once. To specify multiple " + "direct dependencies, pass them all as a single parameter separated by " + "':'.\n"); +} + TEST_F(CommandLineInterfaceTest, CwdRelativeInputs) { // Test that we can accept working-directory-relative input files. diff --git a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc index 77451ab1..deef290b 100644 --- a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc @@ -99,7 +99,6 @@ class MockGeneratorContext : public GeneratorContext { &actual_contents, true)); EXPECT_TRUE(actual_contents == *expected_contents) << physical_filename << " needs to be regenerated. Please run " - "google/protobuf/compiler/release_compiler.sh and " "generate_descriptor_proto.sh. Then add this file " "to your CL."; } diff --git a/src/google/protobuf/compiler/cpp/cpp_enum.cc b/src/google/protobuf/compiler/cpp/cpp_enum.cc index 62b7ed4e..6ced26bc 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum.cc @@ -260,7 +260,7 @@ void EnumGenerator::GenerateMethods(io::Printer* printer) { printer->Print(vars, "bool $classname$_IsValid(int value) {\n" - " switch(value) {\n"); + " switch (value) {\n"); // Multiple values may have the same number. Make sure we only cover // each number once by first constructing a set containing all valid diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc index ffd81529..c3dfa817 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc @@ -83,13 +83,13 @@ void EnumFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ $type$ $classname$::$name$() const {\n" + "$inline$$type$ $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return static_cast< $type$ >($name$_);\n" "}\n" - "$inline$ void $classname$::set_$name$($type$ value) {\n"); + "$inline$void $classname$::set_$name$($type$ value) {\n"); if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) { printer->Print(variables, " assert($type$_IsValid(value));\n"); @@ -187,16 +187,16 @@ void EnumOneofFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ $type$ $classname$::$name$() const {\n" + "$inline$$type$ $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " if (has_$name$()) {\n" " return static_cast< $type$ >($oneof_prefix$$name$_);\n" " }\n" " return static_cast< $type$ >($default$);\n" "}\n" - "$inline$ void $classname$::set_$name$($type$ value) {\n"); + "$inline$void $classname$::set_$name$($type$ value) {\n"); if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) { printer->Print(variables, " assert($type$_IsValid(value));\n"); @@ -263,13 +263,13 @@ void RepeatedEnumFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ $type$ $classname$::$name$(int index) const {\n" + "$inline$$type$ $classname$::$name$(int index) const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return static_cast< $type$ >($name$_.Get(index));\n" "}\n" - "$inline$ void $classname$::set_$name$(int index, $type$ value) {\n"); + "$inline$void $classname$::set_$name$(int index, $type$ value) {\n"); if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) { printer->Print(variables, " assert($type$_IsValid(value));\n"); @@ -278,7 +278,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " $name$_.Set(index, value);\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$ void $classname$::add_$name$($type$ value) {\n"); + "$inline$void $classname$::add_$name$($type$ value) {\n"); if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) { printer->Print(variables, " assert($type$_IsValid(value));\n"); @@ -288,12 +288,12 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " // @@protoc_insertion_point(field_add:$full_name$)\n" "}\n"); printer->Print(variables, - "$inline$ const ::google::protobuf::RepeatedField&\n" + "$inline$const ::google::protobuf::RepeatedField&\n" "$classname$::$name$() const {\n" " // @@protoc_insertion_point(field_list:$full_name$)\n" " return $name$_;\n" "}\n" - "$inline$ ::google::protobuf::RepeatedField*\n" + "$inline$::google::protobuf::RepeatedField*\n" "$classname$::mutable_$name$() {\n" " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" " return &$name$_;\n" @@ -310,6 +310,11 @@ GenerateMergingCode(io::Printer* printer) const { printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n"); } +void RepeatedEnumFieldGenerator:: +GenerateUnsafeMergingCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_.UnsafeMergeFrom(from.$name$_);\n"); +} + void RepeatedEnumFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n"); @@ -475,10 +480,11 @@ void RepeatedEnumFieldGenerator:: GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, "{\n" - " int data_size = 0;\n"); + " size_t data_size = 0;\n" + " unsigned int count = this->$name$_size();"); printer->Indent(); printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n" + "for (unsigned int i = 0; i < count; i++) {\n" " data_size += ::google::protobuf::internal::WireFormatLite::EnumSize(\n" " this->$name$(i));\n" "}\n"); @@ -489,13 +495,14 @@ GenerateByteSize(io::Printer* printer) const { " total_size += $tag_size$ +\n" " ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n" "}\n" + "int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n" "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" - "_$name$_cached_byte_size_ = data_size;\n" + "_$name$_cached_byte_size_ = cached_size;\n" "GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" "total_size += data_size;\n"); } else { printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size() + data_size;\n"); + "total_size += ($tag_size$UL * count) + data_size;\n"); } printer->Outdent(); printer->Print("}\n"); diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.h b/src/google/protobuf/compiler/cpp/cpp_enum_field.h index fe21c575..57ffeec5 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.h @@ -101,6 +101,7 @@ class RepeatedEnumFieldGenerator : public FieldGenerator { bool is_inline) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; + void GenerateUnsafeMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; diff --git a/src/google/protobuf/compiler/cpp/cpp_extension.cc b/src/google/protobuf/compiler/cpp/cpp_extension.cc index c42f1627..4554c72c 100644 --- a/src/google/protobuf/compiler/cpp/cpp_extension.cc +++ b/src/google/protobuf/compiler/cpp/cpp_extension.cc @@ -178,28 +178,30 @@ void ExtensionGenerator::GenerateRegistration(io::Printer* printer) { switch (descriptor_->cpp_type()) { case FieldDescriptor::CPPTYPE_ENUM: - printer->Print(vars, - "::google::protobuf::internal::ExtensionSet::RegisterEnumExtension(\n" - " &$extendee$::default_instance(),\n" - " $number$, $field_type$, $is_repeated$, $is_packed$,\n"); + printer->Print( + vars, + "::google::protobuf::internal::ExtensionSet::RegisterEnumExtension(\n" + " $extendee$::internal_default_instance(),\n" + " $number$, $field_type$, $is_repeated$, $is_packed$,\n"); printer->Print( " &$type$_IsValid);\n", "type", ClassName(descriptor_->enum_type(), true)); break; case FieldDescriptor::CPPTYPE_MESSAGE: - printer->Print(vars, - "::google::protobuf::internal::ExtensionSet::RegisterMessageExtension(\n" - " &$extendee$::default_instance(),\n" - " $number$, $field_type$, $is_repeated$, $is_packed$,\n"); printer->Print( - " &$type$::default_instance());\n", - "type", ClassName(descriptor_->message_type(), true)); + vars, + "::google::protobuf::internal::ExtensionSet::RegisterMessageExtension(\n" + " $extendee$::internal_default_instance(),\n" + " $number$, $field_type$, $is_repeated$, $is_packed$,\n"); + printer->Print(" $type$::internal_default_instance());\n", "type", + ClassName(descriptor_->message_type(), true)); break; default: - printer->Print(vars, - "::google::protobuf::internal::ExtensionSet::RegisterExtension(\n" - " &$extendee$::default_instance(),\n" - " $number$, $field_type$, $is_repeated$, $is_packed$);\n"); + printer->Print( + vars, + "::google::protobuf::internal::ExtensionSet::RegisterExtension(\n" + " $extendee$::internal_default_instance(),\n" + " $number$, $field_type$, $is_repeated$, $is_packed$);\n"); break; } } diff --git a/src/google/protobuf/compiler/cpp/cpp_field.h b/src/google/protobuf/compiler/cpp/cpp_field.h index 3b012527..fdd338a6 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_field.h @@ -136,6 +136,13 @@ class FieldGenerator { // GenerateMergeFrom method. virtual void GenerateMergingCode(io::Printer* printer) const = 0; + // The same, but the generated code may or may not check the possibility that + // the two objects being merged have the same address. To be safe, callers + // should avoid calling this unless they know the objects are different. + virtual void GenerateUnsafeMergingCode(io::Printer* printer) const { + GenerateMergingCode(printer); + } + // Generate lines of code (statements, not declarations) which swaps // this field and the corresponding field of another message, which // is stored in the generated code variable "other". This is used to diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index b3eca660..369497ce 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -89,7 +89,7 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) new ExtensionGenerator(file->extension(i), options)); } - SplitStringUsing(file_->package(), ".", &package_parts_); + package_parts_ = Split(file_->package(), ".", true); } FileGenerator::~FileGenerator() {} @@ -336,6 +336,20 @@ void FileGenerator::GenerateSource(io::Printer* printer) { // Generate classes. for (int i = 0; i < file_->message_type_count(); i++) { + if (i == 0 && HasGeneratedMethods(file_, options_)) { + printer->Print( + "\n" + "namespace {\n" + "\n" + "static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD" + " GOOGLE_ATTRIBUTE_NORETURN;\n" + "static void MergeFromFail(int line) {\n" + " ::google::protobuf::internal::MergeFromFail(__FILE__, line);\n" + "}\n" + "\n" + "} // namespace\n" + "\n"); + } printer->Print("\n"); printer->Print(kThickSeparator); printer->Print("\n"); @@ -449,6 +463,7 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // In optimize_for = LITE_RUNTIME mode, we don't generate AssignDescriptors() // and we only use AddDescriptors() to allocate default instances. + if (HasDescriptorMethods(file_, options_)) { printer->Print( "\n" @@ -500,15 +515,15 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // AssignDescriptors(). All later times, waits for the first call to // complete and then returns. printer->Print( - "namespace {\n" - "\n" - "GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\n" - "inline void protobuf_AssignDescriptorsOnce() {\n" - " ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n" - " &$assigndescriptorsname$);\n" - "}\n" - "\n", - "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name())); + "namespace {\n" + "\n" + "GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\n" + "void protobuf_AssignDescriptorsOnce() {\n" + " ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n" + " &$assigndescriptorsname$);\n" + "}\n" + "\n", + "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name())); // protobuf_RegisterTypes(): Calls // MessageFactory::InternalRegisterGeneratedType() for each message type. @@ -548,44 +563,68 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // ----------------------------------------------------------------- - // Now generate the AddDescriptors() function. - PrintHandlingOptionalStaticInitializers( - file_, options_, printer, - // With static initializers. - // Note that we don't need any special synchronization in the following - // code - // because it is called at static init time before any threads exist. - "void $adddescriptorsname$() GOOGLE_ATTRIBUTE_COLD;\n" - "void $adddescriptorsname$() {\n" - " static bool already_here = false;\n" - " if (already_here) return;\n" - " already_here = true;\n" - " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" - "\n", - // Without. - "void $adddescriptorsname$_impl() {\n" + // Now generate the InitDefaults() function. + printer->Print( + "void $initdefaultsname$_impl() {\n" " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" "\n", // Vars. - "adddescriptorsname", GlobalAddDescriptorsName(file_->name())); + "initdefaultsname", GlobalInitDefaultsName(file_->name())); printer->Indent(); - // Call the AddDescriptors() methods for all of our dependencies, to make + // Call the InitDefaults() methods for all of our dependencies, to make // sure they get added first. for (int i = 0; i < file_->dependency_count(); i++) { const FileDescriptor* dependency = file_->dependency(i); // Print the namespace prefix for the dependency. string add_desc_name = QualifiedFileLevelSymbol( - dependency->package(), GlobalAddDescriptorsName(dependency->name())); + dependency->package(), GlobalInitDefaultsName(dependency->name())); // Call its AddDescriptors function. printer->Print( "$name$();\n", "name", add_desc_name); } + // Allocate and initialize default instances. This can't be done lazily + // since default instances are returned by simple accessors and are used with + // extensions. Speaking of which, we also register extensions at this time. + for (int i = 0; i < file_->message_type_count(); i++) { + message_generators_[i]->GenerateDefaultInstanceAllocator(printer); + } + for (int i = 0; i < file_->extension_count(); i++) { + extension_generators_[i]->GenerateRegistration(printer); + } + for (int i = 0; i < file_->message_type_count(); i++) { + message_generators_[i]->GenerateDefaultInstanceInitializer(printer); + } + printer->Outdent(); + printer->Print( + "}\n" + "\n" + "GOOGLE_PROTOBUF_DECLARE_ONCE($initdefaultsname$_once_);\n" + "void $initdefaultsname$() {\n" + " ::google::protobuf::GoogleOnceInit(&$initdefaultsname$_once_,\n" + " &$initdefaultsname$_impl);\n" + "}\n", + "initdefaultsname", GlobalInitDefaultsName(file_->name())); + + // ----------------------------------------------------------------- + + // Now generate the AddDescriptors() function. + printer->Print( + "void $adddescriptorsname$_impl() {\n" + " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" + "\n" + " $initdefaultsname$();\n", + // Vars. + "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), + "initdefaultsname", GlobalInitDefaultsName(file_->name())); + + printer->Indent(); if (HasDescriptorMethods(file_, options_)) { - // Embed the descriptor. We simply serialize the entire FileDescriptorProto + // Embed the descriptor. We simply serialize the entire + // FileDescriptorProto // and embed it as a string literal, which is parsed and built into real // descriptors at initialization time. FileDescriptorProto file_proto; @@ -655,30 +694,37 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { "filename", file_->name()); } - // Allocate and initialize default instances. This can't be done lazily - // since default instances are returned by simple accessors and are used with - // extensions. Speaking of which, we also register extensions at this time. - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateDefaultInstanceAllocator(printer); - } - for (int i = 0; i < file_->extension_count(); i++) { - extension_generators_[i]->GenerateRegistration(printer); - } - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateDefaultInstanceInitializer(printer); + // Call the AddDescriptors() methods for all of our dependencies, to make + // sure they get added first. + for (int i = 0; i < file_->dependency_count(); i++) { + const FileDescriptor* dependency = file_->dependency(i); + // Print the namespace prefix for the dependency. + string add_desc_name = QualifiedFileLevelSymbol( + dependency->package(), GlobalAddDescriptorsName(dependency->name())); + // Call its AddDescriptors function. + printer->Print("$adddescriptorsname$();\n", "adddescriptorsname", + add_desc_name); } printer->Print( - "::google::protobuf::internal::OnShutdown(&$shutdownfilename$);\n", - "shutdownfilename", GlobalShutdownFileName(file_->name())); + "::google::protobuf::internal::OnShutdown(&$shutdownfilename$);\n", + "shutdownfilename", GlobalShutdownFileName(file_->name())); printer->Outdent(); printer->Print( - "}\n" - "\n"); + "}\n" + "\n" + "GOOGLE_PROTOBUF_DECLARE_ONCE($adddescriptorsname$_once_);\n" + "void $adddescriptorsname$() {\n" + " ::google::protobuf::GoogleOnceInit(&$adddescriptorsname$_once_,\n" + " &$adddescriptorsname$_impl);\n" + "}\n", + "adddescriptorsname", GlobalAddDescriptorsName(file_->name())); - PrintHandlingOptionalStaticInitializers( - file_, options_, printer, + if (!StaticInitializersForced(file_, options_)) { + printer->Print("#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); + } + printer->Print( // With static initializers. "// Force AddDescriptors() to be called at static initialization time.\n" "struct StaticDescriptorInitializer_$filename$ {\n" @@ -686,15 +732,12 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { " $adddescriptorsname$();\n" " }\n" "} static_descriptor_initializer_$filename$_;\n", - // Without. - "GOOGLE_PROTOBUF_DECLARE_ONCE($adddescriptorsname$_once_);\n" - "void $adddescriptorsname$() {\n" - " ::google::protobuf::GoogleOnceInit(&$adddescriptorsname$_once_,\n" - " &$adddescriptorsname$_impl);\n" - "}\n", // Vars. "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), "filename", FilenameIdentifier(file_->name())); + if (!StaticInitializersForced(file_, options_)) { + printer->Print("#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); + } } void FileGenerator::GenerateNamespaceOpeners(io::Printer* printer) { @@ -892,12 +935,14 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations( // Forward-declare the AddDescriptors, AssignDescriptors, and ShutdownFile // functions, so that we can declare them to be friends of each class. printer->Print( - "\n" - "// Internal implementation detail -- do not call these.\n" - "void $dllexport_decl$$adddescriptorsname$();\n", - "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), - "dllexport_decl", - options_.dllexport_decl.empty() ? "" : options_.dllexport_decl + " "); + "\n" + "// Internal implementation detail -- do not call these.\n" + "void $dllexport_decl$$adddescriptorsname$();\n" + "void $dllexport_decl$$initdefaultsname$();\n", + "initdefaultsname", GlobalInitDefaultsName(file_->name()), + "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), + "dllexport_decl", + options_.dllexport_decl.empty() ? "" : options_.dllexport_decl + " "); printer->Print( // Note that we don't put dllexport_decl on these because they are only diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 2ad4d36a..6d844cc2 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -415,7 +415,8 @@ string DefaultValue(const FieldDescriptor* field) { CEscape(field->default_value_string())) + "\""; case FieldDescriptor::CPPTYPE_MESSAGE: - return FieldMessageTypeName(field) + "::default_instance()"; + return "*" + FieldMessageTypeName(field) + + "::internal_default_instance()"; } // Can't actually get here; make compiler happy. (We could add a default // case above but then we wouldn't get the nice compiler warning when a @@ -444,6 +445,10 @@ string GlobalAddDescriptorsName(const string& filename) { return "protobuf_AddDesc_" + FilenameIdentifier(filename); } +string GlobalInitDefaultsName(const string& filename) { + return "protobuf_InitDefaults_" + FilenameIdentifier(filename); +} + // Return the name of the AssignDescriptors() function for a given file. string GlobalAssignDescriptorsName(const string& filename) { return "protobuf_AssignDesc_" + FilenameIdentifier(filename); @@ -500,40 +505,6 @@ bool StaticInitializersForced(const FileDescriptor* file, return false; } -void PrintHandlingOptionalStaticInitializers( - const FileDescriptor* file, const Options& options, io::Printer* printer, - const char* with_static_init, const char* without_static_init, - const char* var1, const string& val1, const char* var2, - const string& val2) { - map vars; - if (var1) { - vars[var1] = val1; - } - if (var2) { - vars[var2] = val2; - } - PrintHandlingOptionalStaticInitializers( - vars, file, options, printer, with_static_init, without_static_init); -} - -void PrintHandlingOptionalStaticInitializers(const map& vars, - const FileDescriptor* file, - const Options& options, - io::Printer* printer, - const char* with_static_init, - const char* without_static_init) { - if (StaticInitializersForced(file, options)) { - printer->Print(vars, with_static_init); - } else { - printer->Print(vars, (string( - "#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n") + - without_static_init + - "#else\n" + - with_static_init + - "#endif\n").c_str()); - } -} - static bool HasMapFields(const Descriptor* descriptor) { for (int i = 0; i < descriptor->field_count(); ++i) { diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h index 018acfca..3a0c0388 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -147,6 +147,9 @@ string FilenameIdentifier(const string& filename); // Return the name of the AddDescriptors() function for a given file. string GlobalAddDescriptorsName(const string& filename); +// Return the name of the InitDefaults() function for a given file. +string GlobalInitDefaultsName(const string& filename); + // Return the name of the AssignDescriptors() function for a given file. string GlobalAssignDescriptorsName(const string& filename); @@ -223,22 +226,6 @@ inline bool HasFastArraySerialization(const FileDescriptor* file, bool StaticInitializersForced(const FileDescriptor* file, const Options& options); -// Prints 'with_static_init' if static initializers have to be used for the -// provided file. Otherwise emits both 'with_static_init' and -// 'without_static_init' using #ifdef. -void PrintHandlingOptionalStaticInitializers( - const FileDescriptor* file, const Options& options, io::Printer* printer, - const char* with_static_init, const char* without_static_init, - const char* var1 = NULL, const string& val1 = "", const char* var2 = NULL, - const string& val2 = ""); - -void PrintHandlingOptionalStaticInitializers(const map& vars, - const FileDescriptor* file, - const Options& options, - io::Printer* printer, - const char* with_static_init, - const char* without_static_init); - inline bool IsMapEntryMessage(const Descriptor* descriptor) { return descriptor->options().map_entry(); diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc index 0588e34e..31ac9ca7 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc @@ -399,7 +399,8 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizes( void MapFieldGenerator:: GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size();\n" + "total_size += $tag_size$ *\n" + " ::google::protobuf::internal::FromIntSize(this->$name$_size());\n" "{\n" " ::google::protobuf::scoped_ptr<$map_classname$> entry;\n" " for (::google::protobuf::Map< $key_cpp$, $val_cpp$ >::const_iterator\n" diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 1f1a0f1c..f5648663 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -85,14 +85,13 @@ struct FieldOrderingByNumber { // Sort the fields of the given Descriptor by number into a new[]'d array // and return it. -const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) { - const FieldDescriptor** fields = - new const FieldDescriptor*[descriptor->field_count()]; +std::vector SortFieldsByNumber( + const Descriptor* descriptor) { + std::vector fields(descriptor->field_count()); for (int i = 0; i < descriptor->field_count(); i++) { fields[i] = descriptor->field(i); } - std::sort(fields, fields + descriptor->field_count(), - FieldOrderingByNumber()); + std::sort(fields.begin(), fields.end(), FieldOrderingByNumber()); return fields; } @@ -227,59 +226,150 @@ class FieldGroup { // used in a vector. }; +// Helper for the code that emits the Clear() method. +bool CanInitializeByZeroing(const FieldDescriptor* field) { + if (field->is_repeated() || field->is_extension()) return false; + switch (field->cpp_type()) { + case internal::WireFormatLite::CPPTYPE_ENUM: + return field->default_value_enum()->number() == 0; + case internal::WireFormatLite::CPPTYPE_INT32: + return field->default_value_int32() == 0; + case internal::WireFormatLite::CPPTYPE_INT64: + return field->default_value_int64() == 0; + case internal::WireFormatLite::CPPTYPE_UINT32: + return field->default_value_uint32() == 0; + case internal::WireFormatLite::CPPTYPE_UINT64: + return field->default_value_uint64() == 0; + case internal::WireFormatLite::CPPTYPE_FLOAT: + return field->default_value_float() == 0; + case internal::WireFormatLite::CPPTYPE_DOUBLE: + return field->default_value_double() == 0; + case internal::WireFormatLite::CPPTYPE_BOOL: + return field->default_value_bool() == false; + default: + return false; + } +} + // Reorder 'fields' so that if the fields are output into a c++ class in the new -// order, the alignment padding is minimized. We try to do this while keeping -// each field as close as possible to its original position so that we don't -// reduce cache locality much for function that access each field in order. +// order, fields of similiar family (see below) are together and within each +// family, alignment padding is minimized. +// +// We try to do this while keeping each field as close as possible to its +// declaration order (from the .proto file) so that we don't reduce cache +// locality much for function that access each field in order. This is also the +// only (weak) signal we have for author intent concerning field layout. +// +// TODO(ckennelly): Update these functions to use the optimized layout order +// for their access patterns. +// +// TODO(ckennelly): If/when we have profiles available for the compiler, use +// those rather than respect declaration order. +// +// We classify each field into a particular "family" of fields, that we perform +// the same operation on in our generated functions. +// +// REPEATED is placed first, as the C++ compiler automatically initializes +// these fields in layout order. +// +// STRING is grouped next, as our Clear/SharedCtor/SharedDtor walks it and +// calls ArenaStringPtr::Destroy on each. +// +// MESSAGE is grouped next, as our Clear/SharedDtor code walks it and calls +// delete on each. We initialize these fields with a NULL pointer (see +// MessageFieldGenerator::GenerateConstructorCode). +// TODO(ckennelly): memset these in SharedCtor. +// +// ZERO_INITIALIZABLE is memset in Clear/SharedCtor +// +// OTHER these fields are initialized one-by-one. void OptimizePadding(vector* fields) { + // The sorted numeric order of Family determines the declaration order in the + // memory layout. + enum Family { + REPEATED = 0, + STRING = 1, + MESSAGE = 2, + ZERO_INITIALIZABLE = 3, + OTHER = 4, + kMaxFamily + }; + // First divide fields into those that align to 1 byte, 4 bytes or 8 bytes. - vector aligned_to_1, aligned_to_4, aligned_to_8; + vector aligned_to_1[kMaxFamily]; + vector aligned_to_4[kMaxFamily]; + vector aligned_to_8[kMaxFamily]; for (int i = 0; i < fields->size(); ++i) { - switch (EstimateAlignmentSize((*fields)[i])) { - case 1: aligned_to_1.push_back(FieldGroup(i, (*fields)[i])); break; - case 4: aligned_to_4.push_back(FieldGroup(i, (*fields)[i])); break; - case 8: aligned_to_8.push_back(FieldGroup(i, (*fields)[i])); break; - default: - GOOGLE_LOG(FATAL) << "Unknown alignment size."; + const FieldDescriptor* field = (*fields)[i]; + + Family f = OTHER; + if (field->is_repeated()) { + f = REPEATED; + } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { + f = STRING; + } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + f = MESSAGE; + } else if (CanInitializeByZeroing(field)) { + f = ZERO_INITIALIZABLE; } - } - // Now group fields aligned to 1 byte into sets of 4, and treat those like a - // single field aligned to 4 bytes. - for (int i = 0; i < aligned_to_1.size(); i += 4) { - FieldGroup field_group; - for (int j = i; j < aligned_to_1.size() && j < i + 4; ++j) { - field_group.Append(aligned_to_1[j]); + switch (EstimateAlignmentSize(field)) { + case 1: aligned_to_1[f].push_back(FieldGroup(i, field)); break; + case 4: aligned_to_4[f].push_back(FieldGroup(i, field)); break; + case 8: aligned_to_8[f].push_back(FieldGroup(i, field)); break; + default: + GOOGLE_LOG(FATAL) << "Unknown alignment size."; } - aligned_to_4.push_back(field_group); } - // Sort by preferred location to keep fields as close to their original - // location as possible. Using stable_sort ensures that the output is - // consistent across runs. - std::stable_sort(aligned_to_4.begin(), aligned_to_4.end()); - // Now group fields aligned to 4 bytes (or the 4-field groups created above) - // into pairs, and treat those like a single field aligned to 8 bytes. - for (int i = 0; i < aligned_to_4.size(); i += 2) { - FieldGroup field_group; - for (int j = i; j < aligned_to_4.size() && j < i + 2; ++j) { - field_group.Append(aligned_to_4[j]); - } - if (i == aligned_to_4.size() - 1) { - // Move incomplete 4-byte block to the end. - field_group.SetPreferredLocation(fields->size() + 1); + // For each family, group fields to optimize padding. + for (int f = 0; f < kMaxFamily; f++) { + // Now group fields aligned to 1 byte into sets of 4, and treat those like a + // single field aligned to 4 bytes. + for (int i = 0; i < aligned_to_1[f].size(); i += 4) { + FieldGroup field_group; + for (int j = i; j < aligned_to_1[f].size() && j < i + 4; ++j) { + field_group.Append(aligned_to_1[f][j]); + } + aligned_to_4[f].push_back(field_group); + } + // Sort by preferred location to keep fields as close to their declaration + // order as possible. Using stable_sort ensures that the output is + // consistent across runs. + std::stable_sort(aligned_to_4[f].begin(), aligned_to_4[f].end()); + + // Now group fields aligned to 4 bytes (or the 4-field groups created above) + // into pairs, and treat those like a single field aligned to 8 bytes. + for (int i = 0; i < aligned_to_4[f].size(); i += 2) { + FieldGroup field_group; + for (int j = i; j < aligned_to_4[f].size() && j < i + 2; ++j) { + field_group.Append(aligned_to_4[f][j]); + } + if (i == aligned_to_4[f].size() - 1) { + if (f == OTHER) { + // Move incomplete 4-byte block to the beginning. This is done to + // pair with the (possible) leftover blocks from the + // ZERO_INITIALIZABLE family. + field_group.SetPreferredLocation(-1); + } else { + // Move incomplete 4-byte block to the end. + field_group.SetPreferredLocation(fields->size() + 1); + } + } + aligned_to_8[f].push_back(field_group); } - aligned_to_8.push_back(field_group); + // Sort by preferred location. + std::stable_sort(aligned_to_8[f].begin(), aligned_to_8[f].end()); } - // Sort by preferred location. - std::stable_sort(aligned_to_8.begin(), aligned_to_8.end()); // Now pull out all the FieldDescriptors in order. fields->clear(); - for (int i = 0; i < aligned_to_8.size(); ++i) { - fields->insert(fields->end(), - aligned_to_8[i].fields().begin(), - aligned_to_8[i].fields().end()); + for (int f = 0; f < kMaxFamily; ++f) { + for (int i = 0; i < aligned_to_8[f].size(); ++i) { + fields->insert(fields->end(), + aligned_to_8[f][i].fields().begin(), + aligned_to_8[f][i].fields().end()); + } } } @@ -337,6 +427,20 @@ bool HasHasMethod(const FieldDescriptor* field) { return field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE; } +size_t HasBitsSize(const Descriptor* descriptor) { + // TODO(jieluo) - Optimize _has_bits_ for repeated and oneof fields. + size_t sizeof_has_bits = (descriptor->field_count() + 31) / 32 * 4; + if (descriptor->field_count() == 0) { + // Zero-size arrays aren't technically allowed, and MSVC in particular + // doesn't like them. We still need to declare these arrays to make + // other code compile. Since this is an uncommon case, we'll just declare + // them with size 1 and waste some space. Oh well. + sizeof_has_bits = 4; + } + + return sizeof_has_bits; +} + // Collects map entry message type information. void CollectMapInfo(const Descriptor* descriptor, map* variables) { @@ -389,6 +493,15 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, ExtensionGenerator>[descriptor->extension_count()]), use_dependent_base_(false) { + // Compute optimized field order to be used for layout and initialization + // purposes. + for (int i = 0; i < descriptor_->field_count(); i++) { + if (!descriptor_->field(i)->containing_oneof()) { + optimized_order_.push_back(descriptor_->field(i)); + } + } + OptimizePadding(&optimized_order_); + for (int i = 0; i < descriptor->nested_type_count(); i++) { nested_generators_[i].reset( new MessageGenerator(descriptor->nested_type(i), options)); @@ -644,11 +757,12 @@ GenerateSingularFieldHasBits(const FieldDescriptor* field, " return !$name$_.IsCleared();\n" "}\n"); } else { - printer->Print(vars, - "$inline$" - "bool $classname$::has_$name$() const {\n" - " return !_is_default_instance_ && $name$_ != NULL;\n" - "}\n"); + printer->Print( + vars, + "$inline$" + "bool $classname$::has_$name$() const {\n" + " return this != internal_default_instance() && $name$_ != NULL;\n" + "}\n"); } } } @@ -805,31 +919,6 @@ GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline) { } } -// Helper for the code that emits the Clear() method. -static bool CanClearByZeroing(const FieldDescriptor* field) { - if (field->is_repeated() || field->is_extension()) return false; - switch (field->cpp_type()) { - case internal::WireFormatLite::CPPTYPE_ENUM: - return field->default_value_enum()->number() == 0; - case internal::WireFormatLite::CPPTYPE_INT32: - return field->default_value_int32() == 0; - case internal::WireFormatLite::CPPTYPE_INT64: - return field->default_value_int64() == 0; - case internal::WireFormatLite::CPPTYPE_UINT32: - return field->default_value_uint32() == 0; - case internal::WireFormatLite::CPPTYPE_UINT64: - return field->default_value_uint64() == 0; - case internal::WireFormatLite::CPPTYPE_FLOAT: - return field->default_value_float() == 0; - case internal::WireFormatLite::CPPTYPE_DOUBLE: - return field->default_value_double() == 0; - case internal::WireFormatLite::CPPTYPE_BOOL: - return field->default_value_bool() == false; - default: - return false; - } -} - void MessageGenerator:: GenerateDependentBaseClassDefinition(io::Printer* printer) { if (!use_dependent_base_) { @@ -1009,19 +1098,13 @@ GenerateClassDefinition(io::Printer* printer) { "\n"); } - if (!StaticInitializersForced(descriptor_->file(), options_)) { - printer->Print(vars, - "#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n" - "// Returns the internal default instance pointer. This function can\n" - "// return NULL thus should not be used by the user. This is intended\n" - "// for Protobuf internal code. Please use default_instance() declared\n" - "// above instead.\n" + // TODO(gerbens) make this private, while still granting other protos access. + printer->Print( + vars, "static inline const $classname$* internal_default_instance() {\n" - " return default_instance_;\n" + " return &default_instance_.get();\n" "}\n" - "#endif\n" "\n"); - } if (SupportsArenas(descriptor_)) { @@ -1068,7 +1151,7 @@ GenerateClassDefinition(io::Printer* printer) { "void Clear();\n" "bool IsInitialized() const;\n" "\n" - "int ByteSize() const;\n" + "size_t ByteSizeLong() const;\n" "bool MergePartialFromCodedStream(\n" " ::google::protobuf::io::CodedInputStream* input);\n" "void SerializeWithCachedSizes(\n" @@ -1131,7 +1214,8 @@ GenerateClassDefinition(io::Printer* printer) { "void SharedCtor();\n" "void SharedDtor();\n" "void SetCachedSize(int size) const;\n" - "void InternalSwap($classname$* other);\n", + "void InternalSwap($classname$* other);\n" + "void UnsafeMergeFrom(const $classname$& from);\n", "classname", classname_); if (SupportsArenas(descriptor_)) { printer->Print( @@ -1260,8 +1344,8 @@ GenerateClassDefinition(io::Printer* printer) { !descriptor_->options().message_set_wire_format() && num_required_fields_ > 1) { printer->Print( - "// helper for ByteSize()\n" - "int RequiredFieldsByteSizeFallback() const;\n\n"); + "// helper for ByteSizeLong()\n" + "size_t RequiredFieldsByteSizeFallback() const;\n\n"); } // Prepare decls for _cached_size_ and _has_bits_. Their position in the @@ -1271,18 +1355,10 @@ GenerateClassDefinition(io::Printer* printer) { // TODO(kenton): Make _cached_size_ an atomic when C++ supports it. const string cached_size_decl = "mutable int _cached_size_;\n"; - // TODO(jieluo) - Optimize _has_bits_ for repeated and oneof fields. - size_t sizeof_has_bits = (descriptor_->field_count() + 31) / 32 * 4; - if (descriptor_->field_count() == 0) { - // Zero-size arrays aren't technically allowed, and MSVC in particular - // doesn't like them. We still need to declare these arrays to make - // other code compile. Since this is an uncommon case, we'll just declare - // them with size 1 and waste some space. Oh well. - sizeof_has_bits = 4; - } + const size_t sizeof_has_bits = HasBitsSize(descriptor_); const string has_bits_decl = sizeof_has_bits == 0 ? "" : - "::google::protobuf::uint32 _has_bits_[" + SimpleItoa(sizeof_has_bits / 4) + "];\n"; - + "::google::protobuf::internal::HasBits<" + SimpleItoa(sizeof_has_bits / 4) + + "> _has_bits_;\n"; // To minimize padding, data members are divided into three sections: // (1) members assumed to align to 8 bytes @@ -1326,45 +1402,27 @@ GenerateClassDefinition(io::Printer* printer) { printer->Print(cached_size_decl.c_str()); need_to_emit_cached_size = false; } - } else { - // Without field presence, we need another way to disambiguate the default - // instance, because the default instance's submessage fields (if any) store - // pointers to the default instances of the submessages even when they - // aren't present. Alternatives to this approach might be to (i) use a - // tagged pointer on all message fields, setting a tag bit for "not really - // present, just default instance"; or (ii) comparing |this| against the - // return value from GeneratedMessageFactory::GetPrototype() in all - // has_$field$() calls. However, both of these options are much more - // expensive (in code size and CPU overhead) than just checking a field in - // the message. Long-term, the best solution would be to rearchitect the - // default instance design not to store pointers to submessage default - // instances, and have reflection get those some other way; but that change - // would have too much impact on proto2. - printer->Print( - "bool _is_default_instance_;\n"); } // Field members: // List fields which doesn't belong to any oneof - vector fields; hash_map fieldname_to_chunk; for (int i = 0; i < descriptor_->field_count(); i++) { if (!descriptor_->field(i)->containing_oneof()) { const FieldDescriptor* field = descriptor_->field(i); - fields.push_back(field); fieldname_to_chunk[FieldName(field)] = i / 8; } } - OptimizePadding(&fields); + // Emit some private and static members runs_of_fields_ = vector< vector >(1); - for (int i = 0; i < fields.size(); ++i) { - const FieldDescriptor* field = fields[i]; + for (int i = 0; i < optimized_order_.size(); ++i) { + const FieldDescriptor* field = optimized_order_[i]; const FieldGenerator& generator = field_generators_.get(field); generator.GenerateStaticMembers(printer); generator.GeneratePrivateMembers(printer); - if (CanClearByZeroing(field)) { + if (CanInitializeByZeroing(field)) { const string& fieldname = FieldName(field); if (!runs_of_fields_.back().empty() && (fieldname_to_chunk[runs_of_fields_.back().back()] != @@ -1424,15 +1482,15 @@ GenerateClassDefinition(io::Printer* printer) { // Declare AddDescriptors(), BuildDescriptors(), and ShutdownFile() as // friends so that they can access private static variables like // default_instance_ and reflection_. - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - "friend void $dllexport_decl$ $adddescriptorsname$();\n", - // Without. - "friend void $dllexport_decl$ $adddescriptorsname$_impl();\n", - // Vars. - "dllexport_decl", options_.dllexport_decl, "adddescriptorsname", - GlobalAddDescriptorsName(descriptor_->file()->name())); + printer->Print("friend void $dllexport_decl$ $initdefaultsname$_impl();\n", + // Vars. + "dllexport_decl", options_.dllexport_decl, "initdefaultsname", + GlobalInitDefaultsName(descriptor_->file()->name())); + printer->Print("friend void $dllexport_decl$ $adddescriptorsname$_impl();\n", + // Vars. + "dllexport_decl", options_.dllexport_decl, + "adddescriptorsname", + GlobalAddDescriptorsName(descriptor_->file()->name())); printer->Print( "friend void $assigndescriptorsname$();\n" @@ -1443,12 +1501,12 @@ GenerateClassDefinition(io::Printer* printer) { "shutdownfilename", GlobalShutdownFileName(descriptor_->file()->name())); printer->Print( - "void InitAsDefaultInstance();\n" - "static $classname$* default_instance_;\n", - "classname", classname_); + "void InitAsDefaultInstance();\n" + "static ::google::protobuf::internal::ExplicitlyConstructed<$classname$> default_instance_;\n", + "classname", classname_); printer->Outdent(); - printer->Print(vars, "};"); + printer->Print("};"); GOOGLE_DCHECK(!need_to_emit_cached_size); } @@ -1578,18 +1636,18 @@ GenerateDescriptorInitializer(io::Printer* printer, int index) { "::NewGeneratedMessageReflection"; // Construct the reflection object. printer->Print(vars, - "$classname$_reflection_ =\n" - " $fn$(\n" - " $classname$_descriptor_,\n" - " $classname$::default_instance_,\n" - " $classname$_offsets_,\n"); + "$classname$_reflection_ =\n" + " $fn$(\n" + " $classname$_descriptor_,\n" + " $classname$::internal_default_instance(),\n" + " $classname$_offsets_,\n"); if (!HasFieldPresence(descriptor_->file())) { // If we don't have field presence, then _has_bits_ does not exist. printer->Print(vars, " -1,\n"); } else { printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _has_bits_[0]),\n"); + " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _has_bits_),\n"); } // Unknown field offset: either points to the unknown field set if embedded @@ -1637,22 +1695,12 @@ GenerateDescriptorInitializer(io::Printer* printer, int index) { // not (because e.g. we don't have an unknown field set). if (UseUnknownFieldSet(descriptor_->file(), options_)) { printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _internal_metadata_),\n"); + " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" + "$classname$, _internal_metadata_));\n"); } else { printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _arena_),\n"); - } - - // is_default_instance_ offset. - if (HasFieldPresence(descriptor_->file())) { - printer->Print(vars, - " -1);\n"); - } else { - printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _is_default_instance_));\n"); + " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" + "$classname$, _arena_));\n"); } // Handle nested types. @@ -1670,11 +1718,11 @@ GenerateTypeRegistrations(io::Printer* printer) { // Register this message type with the message factory. if (!IsMapEntryMessage(descriptor_)) { printer->Print( - "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n" - " $classname$_descriptor_, &$classname$::default_instance());\n", - "classname", classname_); - } - else { + "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n" + " $classname$_descriptor_, " + "$classname$::internal_default_instance());\n", + "classname", classname_); + } else { map vars; CollectMapInfo(descriptor_, &vars); vars["classname"] = classname_; @@ -1708,6 +1756,12 @@ GenerateTypeRegistrations(io::Printer* printer) { void MessageGenerator:: GenerateDefaultInstanceAllocator(io::Printer* printer) { + // Force initialization of primitive values we depend on. + printer->Print( + StrCat( + uses_string_ ? "::google::protobuf::internal::GetEmptyString();\n" : "") + .c_str()); + // Construct the default instances of all fields, as they will be used // when creating the default instance of the entire message. for (int i = 0; i < descriptor_->field_count(); i++) { @@ -1720,9 +1774,8 @@ GenerateDefaultInstanceAllocator(io::Printer* printer) { // Construct the default instance. We can't call InitAsDefaultInstance() yet // because we need to make sure all default instances that this one might // depend on are constructed first. - printer->Print( - "$classname$::default_instance_ = new $classname$();\n", - "classname", classname_); + printer->Print("$classname$::default_instance_.DefaultConstruct();\n", + "classname", classname_); if ((descriptor_->oneof_decl_count() > 0) && HasDescriptorMethods(descriptor_->file(), options_)) { @@ -1741,8 +1794,9 @@ GenerateDefaultInstanceAllocator(io::Printer* printer) { void MessageGenerator:: GenerateDefaultInstanceInitializer(io::Printer* printer) { printer->Print( - "$classname$::default_instance_->InitAsDefaultInstance();\n", - "classname", classname_); + "$classname$::default_instance_.get_mutable()->InitAsDefaultInstance();" + "\n", + "classname", classname_); // Register extensions. for (int i = 0; i < descriptor_->extension_count(); i++) { @@ -1761,10 +1815,6 @@ GenerateDefaultInstanceInitializer(io::Printer* printer) { void MessageGenerator:: GenerateShutdownCode(io::Printer* printer) { - printer->Print( - "delete $classname$::default_instance_;\n", - "classname", classname_); - if (HasDescriptorMethods(descriptor_->file(), options_)) { if (descriptor_->oneof_decl_count() > 0) { printer->Print( @@ -1894,6 +1944,12 @@ GenerateClassMethods(io::Printer* printer) { GenerateIsInitialized(printer); printer->Print("\n"); + } else { + printer->Print( + "void $classname$::UnsafeMergeFrom(const $classname$& from) {\n" + " MergeFrom(from);\n" + "}\n", + "classname", classname_); } GenerateSwap(printer); @@ -1966,15 +2022,15 @@ GenerateSharedConstructorCode(io::Printer* printer) { "classname", classname_); printer->Indent(); - if (!HasFieldPresence(descriptor_->file())) { - printer->Print( - " _is_default_instance_ = false;\n"); + bool need_to_clear_cached_size = true; + // We reproduce the logic used for laying out _cached_sized_ in the class + // definition, as to initialize it in-order. + if (HasFieldPresence(descriptor_->file()) && + (HasBitsSize(descriptor_) % 8) != 0) { + printer->Print("_cached_size_ = 0;\n"); + need_to_clear_cached_size = false; } - printer->Print(StrCat( - uses_string_ ? "::google::protobuf::internal::GetEmptyString();\n" : "", - "_cached_size_ = 0;\n").c_str()); - if (PreserveUnknownFields(descriptor_) && !UseUnknownFieldSet(descriptor_->file(), options_)) { printer->Print( @@ -1982,16 +2038,52 @@ GenerateSharedConstructorCode(io::Printer* printer) { " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n"); } - for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->containing_oneof()) { - field_generators_.get(descriptor_->field(i)) - .GenerateConstructorCode(printer); + const FieldDescriptor* last_start = NULL; + // RunMap maps from fields that start each run to the number of fields in that + // run. This is optimized for the common case that there are very few runs in + // a message and that most of the eligible fields appear together. + typedef hash_map RunMap; + RunMap runs; + + for (int i = 0; i < optimized_order_.size(); ++i) { + const FieldDescriptor* field = optimized_order_[i]; + // TODO(ckennelly): Scalar messages (raw pointers) can be initialized by + // zero as well. + if (CanInitializeByZeroing(field)) { + if (last_start == NULL) { + last_start = field; + } + + runs[last_start]++; + } else { + last_start = NULL; } } - if (HasFieldPresence(descriptor_->file())) { - printer->Print( - "::memset(_has_bits_, 0, sizeof(_has_bits_));\n"); + for (int i = 0; i < optimized_order_.size(); ++i) { + const FieldDescriptor* field = optimized_order_[i]; + RunMap::const_iterator it = runs.find(field); + + // We only apply the memset technique to runs of more than one field, as + // assignment is better than memset for generated code clarity. + if (it != runs.end() && it->second > 1) { + // Use a memset, then skip run_length fields. + const size_t run_length = it->second; + const string first_field_name = FieldName(field); + const string last_field_name = + FieldName(optimized_order_[i + run_length - 1]); + + printer->Print( + "::memset(&$first$_, 0, reinterpret_cast(&$last$_) -\n" + " reinterpret_cast(&$first$_) + sizeof($last$_));\n", + "first", first_field_name, + "last", last_field_name); + + i += run_length - 1; + // ++i at the top of the loop. + } else { + field_generators_.get(field).GenerateConstructorCode(printer); + } } for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { @@ -2000,6 +2092,10 @@ GenerateSharedConstructorCode(io::Printer* printer) { "oneof_name", descriptor_->oneof_decl(i)->name()); } + if (need_to_clear_cached_size) { + printer->Print("_cached_size_ = 0;\n"); + } + printer->Outdent(); printer->Print("}\n\n"); } @@ -2013,7 +2109,8 @@ GenerateSharedDestructorCode(io::Printer* printer) { if (SupportsArenas(descriptor_)) { // Do nothing when the message is allocated in an arena. printer->Print( - "if (GetArenaNoVirtual() != NULL) {\n" + "::google::protobuf::Arena* arena = GetArenaNoVirtual();\n" + "if (arena != NULL) {\n" " return;\n" "}\n" "\n"); @@ -2026,7 +2123,7 @@ GenerateSharedDestructorCode(io::Printer* printer) { printer->Print( "_unknown_fields_.Destroy(\n" " &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n" - " GetArenaNoVirtual());\n"); + " arena);\n"); } else { printer->Print( "_unknown_fields_.DestroyNoArena(\n" @@ -2035,11 +2132,10 @@ GenerateSharedDestructorCode(io::Printer* printer) { } // Write the destructors for each field except oneof members. - for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->containing_oneof()) { - field_generators_.get(descriptor_->field(i)) - .GenerateDestructorCode(printer); - } + // optimized_order_ does not contain oneof fields. + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + field_generators_.get(field).GenerateDestructorCode(printer); } // Generate code to destruct oneofs. Clearing should do the work. @@ -2051,13 +2147,6 @@ GenerateSharedDestructorCode(io::Printer* printer) { "oneof_name", descriptor_->oneof_decl(i)->name()); } - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - "if (this != default_instance_) {\n", - // Without. - "if (this != &default_instance()) {\n"); - // We need to delete all embedded messages. // TODO(kenton): If we make unset messages point at default instances // instead of NULL, then it would make sense to move this code into @@ -2069,16 +2158,13 @@ GenerateSharedDestructorCode(io::Printer* printer) { field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { // Skip oneof members if (!field->containing_oneof()) { - printer->Print( - " delete $name$_;\n", - "name", FieldName(field)); + printer->Print("delete $name$_;\n", "name", FieldName(field)); } } } printer->Outdent(); printer->Print( - " }\n" "}\n" "\n"); } @@ -2151,16 +2237,18 @@ GenerateStructors(io::Printer* printer) { } // Initialize member variables with arena constructor. - for (int i = 0; i < descriptor_->field_count(); i++) { - bool has_arena_constructor = descriptor_->field(i)->is_repeated(); + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + + bool has_arena_constructor = field->is_repeated(); if (has_arena_constructor) { initializer_with_arena += string(",\n ") + - FieldName(descriptor_->field(i)) + string("_(arena)"); + FieldName(field) + string("_(arena)"); } } if (IsAnyMessage(descriptor_)) { - initializer_with_arena += ",\n _any_metadata_(&type_url, &value_)"; + initializer_with_arena += ",\n _any_metadata_(&type_url_, &value_)"; } string initializer_null; @@ -2173,27 +2261,31 @@ GenerateStructors(io::Printer* printer) { printer->Print( "$classname$::$classname$()\n" " : $superclass$()$initializer$ {\n" + " if (this != internal_default_instance()) $initdefaultsname$();\n" " SharedCtor();\n" " // @@protoc_insertion_point(constructor:$full_name$)\n" "}\n", - "classname", classname_, - "superclass", superclass, - "full_name", descriptor_->full_name(), - "initializer", initializer_null); + "classname", classname_, "superclass", superclass, "full_name", + descriptor_->full_name(), "initializer", initializer_null, + "initdefaultsname", GlobalInitDefaultsName(descriptor_->file()->name())); if (SupportsArenas(descriptor_)) { printer->Print( - "\n" "$classname$::$classname$(::google::protobuf::Arena* arena)\n" " : $initializer$ {\n" + // When arenas are used it's safe to assume we have finished + // static init time (protos with arenas are unsafe during static init) + "#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n" + " $initdefaultsname$();\n" + "#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n" " SharedCtor();\n" " RegisterArenaDtor(arena);\n" " // @@protoc_insertion_point(arena_constructor:$full_name$)\n" "}\n", - "initializer", initializer_with_arena, - "classname", classname_, - "superclass", superclass, - "full_name", descriptor_->full_name()); + "initializer", initializer_with_arena, "classname", classname_, + "superclass", superclass, "full_name", descriptor_->full_name(), + "initdefaultsname", + GlobalInitDefaultsName(descriptor_->file()->name())); } printer->Print( @@ -2201,11 +2293,6 @@ GenerateStructors(io::Printer* printer) { "void $classname$::InitAsDefaultInstance() {\n", "classname", classname_); - if (!HasFieldPresence(descriptor_->file())) { - printer->Print( - " _is_default_instance_ = true;\n"); - } - // The default instance needs all of its embedded message pointers // cross-linked to other default instances. We can't do this initialization // in the constructor because some other default instances may not have been @@ -2224,11 +2311,7 @@ GenerateStructors(io::Printer* printer) { name = classname_ + "_default_oneof_instance_->"; } name += FieldName(field); - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - " $name$_ = const_cast< $type$*>(&$type$::default_instance());\n", - // Without. + printer->Print( " $name$_ = const_cast< $type$*>(\n" " $type$::internal_default_instance());\n", // Vars. @@ -2262,7 +2345,7 @@ GenerateStructors(io::Printer* printer) { printer->Print(" {\n"); printer->Print( " SharedCtor();\n" - " MergeFrom(from);\n" + " UnsafeMergeFrom(from);\n" " // @@protoc_insertion_point(copy_constructor:$full_name$)\n" "}\n" "\n", @@ -2304,37 +2387,29 @@ GenerateStructors(io::Printer* printer) { if (HasDescriptorMethods(descriptor_->file(), options_) && !descriptor_->options().no_standard_descriptor_accessor()) { printer->Print( - "const ::google::protobuf::Descriptor* $classname$::descriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" - "}\n" - "\n", - "classname", classname_, - "adddescriptorsname", - GlobalAddDescriptorsName(descriptor_->file()->name())); + "const ::google::protobuf::Descriptor* $classname$::descriptor() {\n" + " protobuf_AssignDescriptorsOnce();\n" + " return $classname$_descriptor_;\n" + "}\n" + "\n", + "classname", classname_, "initdefaultsname", + GlobalInitDefaultsName(descriptor_->file()->name())); } printer->Print( - "const $classname$& $classname$::default_instance() {\n", - "classname", classname_); - - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - " if (default_instance_ == NULL) $adddescriptorsname$();\n", - // Without. - " $adddescriptorsname$();\n", - // Vars. - "adddescriptorsname", - GlobalAddDescriptorsName(descriptor_->file()->name())); + "const $classname$& $classname$::default_instance() {\n" + " $initdefaultsname$();\n" + " return *internal_default_instance();\n" + "}\n", + "classname", classname_, "initdefaultsname", + GlobalInitDefaultsName(descriptor_->file()->name())); printer->Print( - " return *default_instance_;\n" - "}\n" - "\n" - "$classname$* $classname$::default_instance_ = NULL;\n" - "\n", - "classname", classname_); + "\n" + "::google::protobuf::internal::ExplicitlyConstructed<$classname$> " + "$classname$::default_instance_;\n" + "\n", + "classname", classname_); if (SupportsArenas(descriptor_)) { printer->Print( @@ -2463,7 +2538,7 @@ GenerateClear(io::Printer* printer) { int count = popcnt(mask); GOOGLE_DCHECK_GE(count, 1); if (count == 1 || - (count <= 4 && count == memset_field_count_for_chunk[i / 8])) { + count == memset_field_count_for_chunk[i / 8]) { // No "if" here because the chunk is trivial. } else { if (HasFieldPresence(descriptor_->file())) { @@ -2540,8 +2615,7 @@ GenerateClear(io::Printer* printer) { if (HasFieldPresence(descriptor_->file())) { // Step 5: Everything else. - printer->Print( - "::memset(_has_bits_, 0, sizeof(_has_bits_));\n"); + printer->Print("_has_bits_.Clear();\n"); } if (PreserveUnknownFields(descriptor_)) { @@ -2584,7 +2658,7 @@ GenerateOneofClear(io::Printer* printer) { "$full_name$)\n"); printer->Indent(); printer->Print(oneof_vars, - "switch($oneofname$_case()) {\n"); + "switch ($oneofname$_case()) {\n"); printer->Indent(); for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); @@ -2639,7 +2713,7 @@ GenerateSwap(io::Printer* printer) { " InternalSwap(other);\n" " } else {\n" " $classname$ temp;\n" - " temp.MergeFrom(*this);\n" + " temp.UnsafeMergeFrom(*this);\n" " CopyFrom(*other);\n" " other->CopyFrom(temp);\n" " }\n" @@ -2715,9 +2789,7 @@ GenerateMergeFrom(io::Printer* printer) { "void $classname$::MergeFrom(const ::google::protobuf::Message& from) {\n" "// @@protoc_insertion_point(generalized_merge_from_start:" "$full_name$)\n" - " if (GOOGLE_PREDICT_FALSE(&from == this)) {\n" - " ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n" - " }\n", + " if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);\n", "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); @@ -2726,7 +2798,7 @@ GenerateMergeFrom(io::Printer* printer) { // system, as the GOOGLE_CHECK above ensured that we have the same descriptor // for each message. printer->Print( - "const $classname$* source = \n" + "const $classname$* source =\n" " ::google::protobuf::internal::DynamicCastToGenerated(\n" " &from);\n" "if (source == NULL) {\n" @@ -2736,7 +2808,7 @@ GenerateMergeFrom(io::Printer* printer) { "} else {\n" "// @@protoc_insertion_point(generalized_merge_from_cast_success:" "$full_name$)\n" - " MergeFrom(*source);\n" + " UnsafeMergeFrom(*source);\n" "}\n", "classname", classname_, "full_name", descriptor_->full_name()); @@ -2758,9 +2830,15 @@ GenerateMergeFrom(io::Printer* printer) { "void $classname$::MergeFrom(const $classname$& from) {\n" "// @@protoc_insertion_point(class_specific_merge_from_start:" "$full_name$)\n" - " if (GOOGLE_PREDICT_FALSE(&from == this)) {\n" - " ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n" - " }\n", + " if (GOOGLE_PREDICT_TRUE(&from != this)) {\n" + " UnsafeMergeFrom(from);\n" + " } else {\n" + " MergeFromFail(__LINE__);\n" + " }\n" + "}\n" + "\n" + "void $classname$::UnsafeMergeFrom(const $classname$& from) {\n" + " GOOGLE_DCHECK(&from != this);\n", "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); @@ -2770,7 +2848,7 @@ GenerateMergeFrom(io::Printer* printer) { const FieldDescriptor* field = descriptor_->field(i); if (field->is_repeated()) { - field_generators_.get(field).GenerateMergingCode(printer); + field_generators_.get(field).GenerateUnsafeMergingCode(printer); } } @@ -2865,7 +2943,8 @@ GenerateMergeFrom(io::Printer* printer) { if (UseUnknownFieldSet(descriptor_->file(), options_)) { printer->Print( "if (from._internal_metadata_.have_unknown_fields()) {\n" - " mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n" + " ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(\n" + " from.unknown_fields(), &_internal_metadata_);\n" "}\n"); } else { printer->Print( @@ -2911,7 +2990,7 @@ GenerateCopyFrom(io::Printer* printer) { printer->Print( "if (&from == this) return;\n" "Clear();\n" - "MergeFrom(from);\n"); + "UnsafeMergeFrom(from);\n"); printer->Outdent(); printer->Print("}\n"); @@ -2926,13 +3005,9 @@ GenerateMergeFromCodedStream(io::Printer* printer) { " ::google::protobuf::io::CodedInputStream* input) {\n", "classname", classname_); - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - " return _extensions_.ParseMessageSet(input, default_instance_,\n" - " mutable_unknown_fields());\n", - // Without. - " return _extensions_.ParseMessageSet(input, &default_instance(),\n" + printer->Print( + " return _extensions_.ParseMessageSet(input, " + "internal_default_instance(),\n" " mutable_unknown_fields());\n", // Vars. "classname", classname_); @@ -2971,8 +3046,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) { printer->Print("for (;;) {\n"); printer->Indent(); - google::protobuf::scoped_array ordered_fields( - SortFieldsByNumber(descriptor_)); + std::vector ordered_fields = + SortFieldsByNumber(descriptor_); uint32 maxtag = descriptor_->field_count() == 0 ? 0 : WireFormat::MakeTag(ordered_fields[descriptor_->field_count() - 1]); const int kCutoff0 = 127; // fits in 1-byte varint @@ -3000,7 +3075,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { // Find repeated messages and groups now, to simplify what follows. hash_set fields_with_parse_loop; - for (int i = 0; i < descriptor_->field_count(); i++) { + for (int i = 0; i < ordered_fields.size(); i++) { const FieldDescriptor* field = ordered_fields[i]; if (field->is_repeated() && (field->type() == FieldDescriptor::TYPE_MESSAGE || @@ -3012,7 +3087,13 @@ GenerateMergeFromCodedStream(io::Printer* printer) { // need_label is true if we generated "goto parse_$name$" while handling the // previous field. bool need_label = false; - for (int i = 0; i < descriptor_->field_count(); i++) { + // Pay attention to whether we are in a run of fields from the same oneof. + // Motivation: it would be unusual to parse multiple values for a single + // oneof, since only the last would be used. + const FieldDescriptor* last_of_current_oneof = NULL; + // The following is valid iff last_of_current_oneof is non-NULL. + int index_of_last_of_current_oneof = -1; + for (int i = 0; i < ordered_fields.size(); i++) { const FieldDescriptor* field = ordered_fields[i]; const bool loops = fields_with_parse_loop.count(i) > 0; const bool next_field_loops = fields_with_parse_loop.count(i + 1) > 0; @@ -3111,21 +3192,53 @@ GenerateMergeFromCodedStream(io::Printer* printer) { "input->UnsafeDecrementRecursionDepth();\n"); } - // If there are more fields, expect the next one. + // If there are more fields, expect the next one, unless we just parsed + // a oneof and the next field would be from the same oneof. (There's no + // reason to expect something that makes what we just read irrelevant, + // so guess something after the current string of fields from this oneof.) need_label = false; if (!emitted_goto_next_tag) { - if (i + 1 == descriptor_->field_count()) { + // delta is the distance in ordered_fields[] from the current field to + // the field we'll guess is next. + int delta = last_of_current_oneof == NULL + ? 1 + : std::max(index_of_last_of_current_oneof - i, 1); + if (i == index_of_last_of_current_oneof) { + printer->Outdent(); + printer->Print( + " after_$last$:\n", + "last", FieldName(last_of_current_oneof)); + printer->Indent(); + last_of_current_oneof = NULL; + } else if (last_of_current_oneof == NULL) { + delta = 1; + // Check for the unlikely case that delta > 1 is better. + if (field->containing_oneof() != NULL) { + while (i + delta < ordered_fields.size() && + ordered_fields[i + delta]->containing_oneof() == + field->containing_oneof()) { + index_of_last_of_current_oneof = i + delta; + last_of_current_oneof = ordered_fields[i + delta]; + ++delta; + } + } + } + if (delta > 1) { + printer->Print( + "goto after_$last$;\n", + "last", FieldName(last_of_current_oneof)); + } else if (i + delta == descriptor_->field_count()) { // Expect EOF. // TODO(kenton): Expect group end-tag? printer->Print( "if (input->ExpectAtEnd()) goto success;\n"); } else { - const FieldDescriptor* next_field = ordered_fields[i + 1]; + const FieldDescriptor* next_field = ordered_fields[i + delta]; printer->Print( "if (input->ExpectTag($next_tag$)) goto parse_$next_name$;\n", "next_tag", SimpleItoa(WireFormat::MakeTag(next_field)), "next_name", next_field->name()); - need_label = true; + need_label = delta == 1; } } @@ -3179,31 +3292,21 @@ GenerateMergeFromCodedStream(io::Printer* printer) { printer->Print(") {\n"); if (PreserveUnknownFields(descriptor_)) { if (UseUnknownFieldSet(descriptor_->file(), options_)) { - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - " DO_(_extensions_.ParseField(tag, input, default_instance_,\n" - " mutable_unknown_fields()));\n", - // Without. - " DO_(_extensions_.ParseField(tag, input, &default_instance(),\n" + printer->Print( + " DO_(_extensions_.ParseField(tag, input, " + "internal_default_instance(),\n" " mutable_unknown_fields()));\n"); } else { - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, - // With static initializers. - " DO_(_extensions_.ParseField(tag, input, default_instance_,\n" - " &unknown_fields_stream));\n", - // Without. - " DO_(_extensions_.ParseField(tag, input, &default_instance(),\n" + printer->Print( + " DO_(_extensions_.ParseField(tag, input, " + "internal_default_instance(),\n" " &unknown_fields_stream));\n"); } } else { - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), options_, printer, + printer->Print( // With static initializers. - " DO_(_extensions_.ParseField(tag, input, default_instance_);\n", - // Without. - " DO_(_extensions_.ParseField(tag, input, &default_instance());\n"); + " DO_(_extensions_.ParseField(tag, input, " + "internal_default_instance());\n"); } printer->Print( " continue;\n" @@ -3248,6 +3351,43 @@ GenerateMergeFromCodedStream(io::Printer* printer) { "}\n", "full_name", descriptor_->full_name()); } +void MessageGenerator::GenerateSerializeOneofFields( + io::Printer* printer, const vector& fields, + bool to_array) { + GOOGLE_CHECK(!fields.empty()); + if (fields.size() == 1) { + GenerateSerializeOneField(printer, fields[0], to_array); + return; + } + // We have multiple mutually exclusive choices. Emit a switch statement. + const OneofDescriptor* oneof = fields[0]->containing_oneof(); + printer->Print( + "switch ($oneofname$_case()) {\n", + "oneofname", oneof->name()); + printer->Indent(); + for (int i = 0; i < fields.size(); i++) { + const FieldDescriptor* field = fields[i]; + printer->Print( + "case k$field_name$:\n", + "field_name", UnderscoresToCamelCase(field->name(), true)); + printer->Indent(); + if (to_array) { + field_generators_.get(field).GenerateSerializeWithCachedSizesToArray( + printer); + } else { + field_generators_.get(field).GenerateSerializeWithCachedSizes(printer); + } + printer->Print( + "break;\n"); + printer->Outdent(); + } + printer->Outdent(); + // Doing nothing is an option. + printer->Print( + " default: ;\n" + "}\n"); +} + void MessageGenerator::GenerateSerializeOneField( io::Printer* printer, const FieldDescriptor* field, bool to_array) { PrintFieldComment(printer, field); @@ -3382,10 +3522,61 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) { void MessageGenerator:: GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) { - google::protobuf::scoped_array ordered_fields( - SortFieldsByNumber(descriptor_)); + // If there are multiple fields in a row from the same oneof then we + // coalesce them and emit a switch statement. This is more efficient + // because it lets the C++ compiler know this is a "at most one can happen" + // situation. If we emitted "if (has_x()) ...; if (has_y()) ..." the C++ + // compiler's emitted code might check has_y() even when has_x() is true. + class LazySerializerEmitter { + public: + LazySerializerEmitter(MessageGenerator* mg, io::Printer* printer, + bool to_array) + : mg_(mg), + printer_(printer), + to_array_(to_array), + eager_(!HasFieldPresence(mg->descriptor_->file())) {} + + ~LazySerializerEmitter() { Flush(); } + + // If conditions allow, try to accumulate a run of fields from the same + // oneof, and handle them at the next Flush(). + void Emit(const FieldDescriptor* field) { + if (eager_ || MustFlush(field)) { + Flush(); + } + if (field->containing_oneof() == NULL) { + mg_->GenerateSerializeOneField(printer_, field, to_array_); + } else { + v_.push_back(field); + } + } - vector sorted_extensions; + void Flush() { + if (!v_.empty()) { + mg_->GenerateSerializeOneofFields(printer_, v_, to_array_); + v_.clear(); + } + } + + private: + // If we have multiple fields in v_ then they all must be from the same + // oneof. Would adding field to v_ break that invariant? + bool MustFlush(const FieldDescriptor* field) { + return !v_.empty() && + v_[0]->containing_oneof() != field->containing_oneof(); + } + + MessageGenerator* mg_; + io::Printer* printer_; + const bool to_array_; + const bool eager_; + vector v_; + }; + + std::vector ordered_fields = + SortFieldsByNumber(descriptor_); + + std::vector sorted_extensions; for (int i = 0; i < descriptor_->extension_range_count(); ++i) { sorted_extensions.push_back(descriptor_->extension_range(i)); } @@ -3393,22 +3584,26 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) { ExtensionRangeSorter()); // Merge the fields and the extension ranges, both sorted by field number. - int i, j; - for (i = 0, j = 0; - i < descriptor_->field_count() || j < sorted_extensions.size(); - ) { - if (i == descriptor_->field_count()) { - GenerateSerializeOneExtensionRange(printer, - sorted_extensions[j++], - to_array); - } else if (j == sorted_extensions.size()) { - GenerateSerializeOneField(printer, ordered_fields[i++], to_array); - } else if (ordered_fields[i]->number() < sorted_extensions[j]->start) { - GenerateSerializeOneField(printer, ordered_fields[i++], to_array); - } else { - GenerateSerializeOneExtensionRange(printer, - sorted_extensions[j++], - to_array); + { + LazySerializerEmitter e(this, printer, to_array); + int i, j; + for (i = 0, j = 0; + i < ordered_fields.size() || j < sorted_extensions.size();) { + if (i == descriptor_->field_count()) { + e.Flush(); + GenerateSerializeOneExtensionRange(printer, + sorted_extensions[j++], + to_array); + } else if (j == sorted_extensions.size()) { + e.Emit(ordered_fields[i++]); + } else if (ordered_fields[i]->number() < sorted_extensions[j]->start) { + e.Emit(ordered_fields[i++]); + } else { + e.Flush(); + GenerateSerializeOneExtensionRange(printer, + sorted_extensions[j++], + to_array); + } } } @@ -3480,9 +3675,9 @@ GenerateByteSize(io::Printer* printer) { if (descriptor_->options().message_set_wire_format()) { // Special-case MessageSet. printer->Print( - "int $classname$::ByteSize() const {\n" + "size_t $classname$::ByteSizeLong() const {\n" "// @@protoc_insertion_point(message_set_byte_size_start:$full_name$)\n" - " int total_size = _extensions_.MessageSetByteSize();\n", + " size_t total_size = _extensions_.MessageSetByteSize();\n", "classname", classname_, "full_name", descriptor_->full_name()); GOOGLE_CHECK(UseUnknownFieldSet(descriptor_->file(), options_)); printer->Print( @@ -3491,8 +3686,9 @@ GenerateByteSize(io::Printer* printer) { " ComputeUnknownMessageSetItemsSize(unknown_fields());\n" "}\n"); printer->Print( + " int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);\n" " GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" - " _cached_size_ = total_size;\n" + " _cached_size_ = cached_size;\n" " GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" " return total_size;\n" "}\n"); @@ -3503,12 +3699,12 @@ GenerateByteSize(io::Printer* printer) { // Emit a function (rarely used, we hope) that handles the required fields // by checking for each one individually. printer->Print( - "int $classname$::RequiredFieldsByteSizeFallback() const {\n" + "size_t $classname$::RequiredFieldsByteSizeFallback() const {\n" "// @@protoc_insertion_point(required_fields_byte_size_fallback_start:" "$full_name$)\n", "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); - printer->Print("int total_size = 0;\n"); + printer->Print("size_t total_size = 0;\n"); for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); if (field->is_required()) { @@ -3529,12 +3725,12 @@ GenerateByteSize(io::Printer* printer) { } printer->Print( - "int $classname$::ByteSize() const {\n" + "size_t $classname$::ByteSizeLong() const {\n" "// @@protoc_insertion_point(message_byte_size_start:$full_name$)\n", "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); printer->Print( - "int total_size = 0;\n" + "size_t total_size = 0;\n" "\n"); // Handle required fields (if any). We expect all of them to be @@ -3727,8 +3923,9 @@ GenerateByteSize(io::Printer* printer) { // exact same value, it works on all common processors. In a future version // of C++, _cached_size_ should be made into an atomic. printer->Print( + "int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);\n" "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" - "_cached_size_ = total_size;\n" + "_cached_size_ = cached_size;\n" "GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" "return total_size;\n"); @@ -3804,7 +4001,9 @@ GenerateIsInitialized(io::Printer* printer) { if (descriptor_->extension_range_count() > 0) { printer->Print( "\n" - "if (!_extensions_.IsInitialized()) return false;\n"); + "if (!_extensions_.IsInitialized()) {\n" + " return false;\n" + "}\n"); } printer->Outdent(); diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h index b1e3fe21..3bdc0ed3 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.h +++ b/src/google/protobuf/compiler/cpp/cpp_message.h @@ -165,6 +165,11 @@ class MessageGenerator { void GenerateSerializeOneField(io::Printer* printer, const FieldDescriptor* field, bool unbounded); + // Generate a switch statement to serialize 2+ fields from the same oneof. + // Or, if fields.size() == 1, just call GenerateSerializeOneField(). + void GenerateSerializeOneofFields( + io::Printer* printer, const vector& fields, + bool to_array); void GenerateSerializeOneExtensionRange( io::Printer* printer, const Descriptor::ExtensionRange* range, bool unbounded); @@ -189,6 +194,11 @@ class MessageGenerator { string classname_; Options options_; FieldGeneratorMap field_generators_; + // optimized_order_ is the order we layout the message's fields in the class. + // This is reused to initialize the fields in-order for cache efficiency. + // + // optimized_order_ excludes oneof fields. + vector optimized_order_; vector< vector > runs_of_fields_; // that might be trivially cleared google::protobuf::scoped_array > nested_generators_; google::protobuf::scoped_array > enum_generators_; diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc index d021035d..ca7bae02 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc @@ -161,8 +161,7 @@ void MessageFieldGenerator::GenerateNonInlineAccessorDefinitions( " if ($name$_ == NULL) {\n" " return NULL;\n" " } else {\n" - " $type$* temp = new $type$;\n" - " temp->MergeFrom(*$name$_);\n" + " $type$* temp = new $type$(*$name$_);\n" " $name$_ = NULL;\n" " return temp;\n" " }\n" @@ -346,23 +345,29 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { void MessageFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { + if (dependent_field_) { + // for dependent fields we cannot access its internal_default_instance, + // because the type is incomplete. + // TODO(gerbens) deprecate dependent base class. + map variables(variables_); + variables["inline"] = is_inline ? "inline " : ""; + printer->Print(variables, + "$inline$const $type$& $classname$::$name$() const {\n" + " // @@protoc_insertion_point(field_get:$full_name$)\n" + " return $name$_ != NULL ? *$name$_\n" + " : *internal_default_instance()->$name$_;\n" + "}\n"); + return; + } + map variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$const $type$& $classname$::$name$() const {\n" - " // @@protoc_insertion_point(field_get:$full_name$)\n"); - - PrintHandlingOptionalStaticInitializers( - variables, descriptor_->file(), options_, printer, - // With static initializers. - " return $name$_ != NULL ? *$name$_ : *default_instance_->$name$_;\n", - // Without. - " return $name$_ != NULL ? *$name$_ : *default_instance().$name$_;\n"); - printer->Print(variables, "}\n"); - - if (dependent_field_) { - return; - } + " // @@protoc_insertion_point(field_get:$full_name$)\n" + " return $name$_ != NULL ? *$name$_\n" + " : *$type$::internal_default_instance();\n" + "}\n"); if (SupportsArenas(descriptor_)) { printer->Print(variables, @@ -663,8 +668,8 @@ InternalGenerateInlineAccessorDefinitions(const map& variables, " if ($this_message$GetArenaNoVirtual() != NULL) {\n" // N.B.: safe to use the underlying field pointer here because we are sure // that it is non-NULL (because has_$name$() returned true). - " $dependent_typename$* temp = new $dependent_typename$;\n" - " temp->MergeFrom(*$field_member$);\n" + " $dependent_typename$* temp = " + "new $dependent_typename$(*$field_member$);\n" " $field_member$ = NULL;\n" " return temp;\n" " } else {\n" @@ -1041,12 +1046,18 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { void RepeatedMessageFieldGenerator:: GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size();\n" - "for (int i = 0; i < this->$name$_size(); i++) {\n" + "{\n" + " unsigned int count = this->$name$_size();\n"); + printer->Indent(); + printer->Print(variables_, + "total_size += $tag_size$UL * count;\n" + "for (unsigned int i = 0; i < count; i++) {\n" " total_size +=\n" " ::google::protobuf::internal::WireFormatLite::$declared_type$SizeNoVirtual(\n" " this->$name$(i));\n" "}\n"); + printer->Outdent(); + printer->Print("}\n"); } } // namespace cpp diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc index 650f0381..54b3d24a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc @@ -123,13 +123,13 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void PrimitiveFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ $type$ $classname$::$name$() const {\n" + "$inline$$type$ $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return $name$_;\n" "}\n" - "$inline$ void $classname$::set_$name$($type$ value) {\n" + "$inline$void $classname$::set_$name$($type$ value) {\n" " $set_hasbit$\n" " $name$_ = value;\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" @@ -159,10 +159,10 @@ GenerateConstructorCode(io::Printer* printer) const { void PrimitiveFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { printer->Print(variables_, + "$set_hasbit$\n" "DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n" " $type$, $wire_format_field_type$>(\n" - " input, &$name$_)));\n" - "$set_hasbit$\n"); + " input, &$name$_)));\n"); } void PrimitiveFieldGenerator:: @@ -207,16 +207,16 @@ PrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {} void PrimitiveOneofFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ $type$ $classname$::$name$() const {\n" + "$inline$$type$ $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " if (has_$name$()) {\n" " return $oneof_prefix$$name$_;\n" " }\n" " return $default$;\n" "}\n" - "$inline$ void $classname$::set_$name$($type$ value) {\n" + "$inline$void $classname$::set_$name$($type$ value) {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" @@ -298,27 +298,27 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void RepeatedPrimitiveFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ $type$ $classname$::$name$(int index) const {\n" + "$inline$$type$ $classname$::$name$(int index) const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return $name$_.Get(index);\n" "}\n" - "$inline$ void $classname$::set_$name$(int index, $type$ value) {\n" + "$inline$void $classname$::set_$name$(int index, $type$ value) {\n" " $name$_.Set(index, value);\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$ void $classname$::add_$name$($type$ value) {\n" + "$inline$void $classname$::add_$name$($type$ value) {\n" " $name$_.Add(value);\n" " // @@protoc_insertion_point(field_add:$full_name$)\n" "}\n"); printer->Print(variables, - "$inline$ const ::google::protobuf::RepeatedField< $type$ >&\n" + "$inline$const ::google::protobuf::RepeatedField< $type$ >&\n" "$classname$::$name$() const {\n" " // @@protoc_insertion_point(field_list:$full_name$)\n" " return $name$_;\n" "}\n" - "$inline$ ::google::protobuf::RepeatedField< $type$ >*\n" + "$inline$::google::protobuf::RepeatedField< $type$ >*\n" "$classname$::mutable_$name$() {\n" " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" " return &$name$_;\n" @@ -335,6 +335,11 @@ GenerateMergingCode(io::Printer* printer) const { printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n"); } +void RepeatedPrimitiveFieldGenerator:: +GenerateUnsafeMergingCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_.UnsafeMergeFrom(from.$name$_);\n"); +} + void RepeatedPrimitiveFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n"); @@ -420,18 +425,19 @@ void RepeatedPrimitiveFieldGenerator:: GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, "{\n" - " int data_size = 0;\n"); + " size_t data_size = 0;\n" + " unsigned int count = this->$name$_size();\n"); printer->Indent(); int fixed_size = FixedSize(descriptor_->type()); if (fixed_size == -1) { printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n" + "for (unsigned int i = 0; i < count; i++) {\n" " data_size += ::google::protobuf::internal::WireFormatLite::\n" " $declared_type$Size(this->$name$(i));\n" "}\n"); } else { printer->Print(variables_, - "data_size = $fixed_size$ * this->$name$_size();\n"); + "data_size = $fixed_size$UL * count;\n"); } if (descriptor_->is_packed()) { @@ -440,13 +446,16 @@ GenerateByteSize(io::Printer* printer) const { " total_size += $tag_size$ +\n" " ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n" "}\n" + "int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n" "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" - "_$name$_cached_byte_size_ = data_size;\n" + "_$name$_cached_byte_size_ = cached_size;\n" "GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" "total_size += data_size;\n"); } else { printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size() + data_size;\n"); + "total_size += $tag_size$ *\n" + " ::google::protobuf::internal::FromIntSize(this->$name$_size());\n" + "total_size += data_size;\n"); } printer->Outdent(); printer->Print("}\n"); diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h index 655ebde4..23cc697e 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h @@ -103,6 +103,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { bool is_inline) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; + virtual void GenerateUnsafeMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index 1d743457..aee3d1ea 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -166,25 +166,25 @@ void StringFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; if (SupportsArenas(descriptor_)) { printer->Print(variables, - "$inline$ const ::std::string& $classname$::$name$() const {\n" + "$inline$const ::std::string& $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return $name$_.Get($default_variable$);\n" "}\n" - "$inline$ void $classname$::set_$name$(const ::std::string& value) {\n" + "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" " $set_hasbit$\n" " $name$_.Set($default_variable$, value, GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$ void $classname$::set_$name$(const char* value) {\n" + "$inline$void $classname$::set_$name$(const char* value) {\n" " $set_hasbit$\n" " $name$_.Set($default_variable$, $string_piece$(value),\n" " GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n" - "$inline$ " + "$inline$" "void $classname$::set_$name$(const $pointer_type$* value,\n" " size_t size) {\n" " $set_hasbit$\n" @@ -192,24 +192,24 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " reinterpret_cast(value), size), GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$ ::std::string* $classname$::mutable_$name$() {\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" " $set_hasbit$\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n" " return $name$_.Mutable($default_variable$, GetArenaNoVirtual());\n" "}\n" - "$inline$ ::std::string* $classname$::$release_name$() {\n" + "$inline$::std::string* $classname$::$release_name$() {\n" " // @@protoc_insertion_point(field_release:$full_name$)\n" " $clear_hasbit$\n" " return $name$_.Release($default_variable$, GetArenaNoVirtual());\n" "}\n" - "$inline$ ::std::string* $classname$::unsafe_arena_release_$name$() {\n" + "$inline$::std::string* $classname$::unsafe_arena_release_$name$() {\n" " // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" " $clear_hasbit$\n" " return $name$_.UnsafeArenaRelease($default_variable$,\n" " GetArenaNoVirtual());\n" "}\n" - "$inline$ void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" " if ($name$ != NULL) {\n" " $set_hasbit$\n" " } else {\n" @@ -219,7 +219,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" "}\n" - "$inline$ void $classname$::unsafe_arena_set_allocated_$name$(\n" + "$inline$void $classname$::unsafe_arena_set_allocated_$name$(\n" " ::std::string* $name$) {\n" " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" " if ($name$ != NULL) {\n" @@ -235,21 +235,21 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, } else { // No-arena case. printer->Print(variables, - "$inline$ const ::std::string& $classname$::$name$() const {\n" + "$inline$const ::std::string& $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return $name$_.GetNoArena($default_variable$);\n" "}\n" - "$inline$ void $classname$::set_$name$(const ::std::string& value) {\n" + "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" " $set_hasbit$\n" " $name$_.SetNoArena($default_variable$, value);\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$ void $classname$::set_$name$(const char* value) {\n" + "$inline$void $classname$::set_$name$(const char* value) {\n" " $set_hasbit$\n" " $name$_.SetNoArena($default_variable$, $string_piece$(value));\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n" - "$inline$ " + "$inline$" "void $classname$::set_$name$(const $pointer_type$* value, " "size_t size) {\n" " $set_hasbit$\n" @@ -257,17 +257,17 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " $string_piece$(reinterpret_cast(value), size));\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$ ::std::string* $classname$::mutable_$name$() {\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" " $set_hasbit$\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n" " return $name$_.MutableNoArena($default_variable$);\n" "}\n" - "$inline$ ::std::string* $classname$::$release_name$() {\n" + "$inline$::std::string* $classname$::$release_name$() {\n" " // @@protoc_insertion_point(field_release:$full_name$)\n" " $clear_hasbit$\n" " return $name$_.ReleaseNoArena($default_variable$);\n" "}\n" - "$inline$ void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" " if ($name$ != NULL) {\n" " $set_hasbit$\n" " } else {\n" @@ -339,8 +339,10 @@ GenerateConstructorCode(io::Printer* printer) const { void StringFieldGenerator:: GenerateDestructorCode(io::Printer* printer) const { if (SupportsArenas(descriptor_)) { + // The variable |arena| is defined by the enclosing code. + // See MessageGenerator::GenerateSharedDestructorCode. printer->Print(variables_, - "$name$_.Destroy($default_variable$, GetArenaNoVirtual());\n"); + "$name$_.Destroy($default_variable$, arena);\n"); } else { printer->Print(variables_, "$name$_.DestroyNoArena($default_variable$);\n"); @@ -426,17 +428,17 @@ void StringOneofFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; if (SupportsArenas(descriptor_)) { printer->Print(variables, - "$inline$ const ::std::string& $classname$::$name$() const {\n" + "$inline$const ::std::string& $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " if (has_$name$()) {\n" " return $oneof_prefix$$name$_.Get($default_variable$);\n" " }\n" " return *$default_variable$;\n" "}\n" - "$inline$ void $classname$::set_$name$(const ::std::string& value) {\n" + "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" @@ -446,7 +448,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$ void $classname$::set_$name$(const char* value) {\n" + "$inline$void $classname$::set_$name$(const char* value) {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" @@ -456,7 +458,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " $string_piece$(value), GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n" - "$inline$ " + "$inline$" "void $classname$::set_$name$(const $pointer_type$* value,\n" " size_t size) {\n" " if (!has_$name$()) {\n" @@ -469,7 +471,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$ ::std::string* $classname$::mutable_$name$() {\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" @@ -479,7 +481,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n" "}\n" - "$inline$ ::std::string* $classname$::$release_name$() {\n" + "$inline$::std::string* $classname$::$release_name$() {\n" " // @@protoc_insertion_point(field_release:$full_name$)\n" " if (has_$name$()) {\n" " clear_has_$oneof_name$();\n" @@ -489,7 +491,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " return NULL;\n" " }\n" "}\n" - "$inline$ ::std::string* $classname$::unsafe_arena_release_$name$() {\n" + "$inline$::std::string* $classname$::unsafe_arena_release_$name$() {\n" " // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" " if (has_$name$()) {\n" @@ -500,7 +502,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " return NULL;\n" " }\n" "}\n" - "$inline$ void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" " if (!has_$name$()) {\n" " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" " }\n" @@ -512,7 +514,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " }\n" " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" "}\n" - "$inline$ void $classname$::unsafe_arena_set_allocated_$name$(" + "$inline$void $classname$::unsafe_arena_set_allocated_$name$(" "::std::string* $name$) {\n" " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" " if (!has_$name$()) {\n" @@ -530,14 +532,14 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, } else { // No-arena case. printer->Print(variables, - "$inline$ const ::std::string& $classname$::$name$() const {\n" + "$inline$const ::std::string& $classname$::$name$() const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " if (has_$name$()) {\n" " return $oneof_prefix$$name$_.GetNoArena($default_variable$);\n" " }\n" " return *$default_variable$;\n" "}\n" - "$inline$ void $classname$::set_$name$(const ::std::string& value) {\n" + "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" @@ -547,7 +549,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " $oneof_prefix$$name$_.SetNoArena($default_variable$, value);\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" - "$inline$ void $classname$::set_$name$(const char* value) {\n" + "$inline$void $classname$::set_$name$(const char* value) {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" @@ -557,7 +559,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " $string_piece$(value));\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n" - "$inline$ " + "$inline$" "void $classname$::set_$name$(const $pointer_type$* value, size_t size) {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" @@ -568,7 +570,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " reinterpret_cast(value), size));\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$ ::std::string* $classname$::mutable_$name$() {\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" " if (!has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" @@ -577,7 +579,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " // @@protoc_insertion_point(field_mutable:$full_name$)\n" " return $oneof_prefix$$name$_.MutableNoArena($default_variable$);\n" "}\n" - "$inline$ ::std::string* $classname$::$release_name$() {\n" + "$inline$::std::string* $classname$::$release_name$() {\n" " // @@protoc_insertion_point(field_release:$full_name$)\n" " if (has_$name$()) {\n" " clear_has_$oneof_name$();\n" @@ -586,7 +588,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, " return NULL;\n" " }\n" "}\n" - "$inline$ void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" " if (!has_$name$()) {\n" " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" " }\n" @@ -732,55 +734,55 @@ void RepeatedStringFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { map variables(variables_); - variables["inline"] = is_inline ? "inline" : ""; + variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, - "$inline$ const ::std::string& $classname$::$name$(int index) const {\n" + "$inline$const ::std::string& $classname$::$name$(int index) const {\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return $name$_.$cppget$(index);\n" "}\n" - "$inline$ ::std::string* $classname$::mutable_$name$(int index) {\n" + "$inline$::std::string* $classname$::mutable_$name$(int index) {\n" " // @@protoc_insertion_point(field_mutable:$full_name$)\n" " return $name$_.Mutable(index);\n" "}\n" - "$inline$ void $classname$::set_$name$(int index, const ::std::string& value) {\n" + "$inline$void $classname$::set_$name$(int index, const ::std::string& value) {\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" " $name$_.Mutable(index)->assign(value);\n" "}\n" - "$inline$ void $classname$::set_$name$(int index, const char* value) {\n" + "$inline$void $classname$::set_$name$(int index, const char* value) {\n" " $name$_.Mutable(index)->assign(value);\n" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n" - "$inline$ void " + "$inline$void " "$classname$::set_$name$" "(int index, const $pointer_type$* value, size_t size) {\n" " $name$_.Mutable(index)->assign(\n" " reinterpret_cast(value), size);\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "$inline$ ::std::string* $classname$::add_$name$() {\n" + "$inline$::std::string* $classname$::add_$name$() {\n" " // @@protoc_insertion_point(field_add_mutable:$full_name$)\n" " return $name$_.Add();\n" "}\n" - "$inline$ void $classname$::add_$name$(const ::std::string& value) {\n" + "$inline$void $classname$::add_$name$(const ::std::string& value) {\n" " $name$_.Add()->assign(value);\n" " // @@protoc_insertion_point(field_add:$full_name$)\n" "}\n" - "$inline$ void $classname$::add_$name$(const char* value) {\n" + "$inline$void $classname$::add_$name$(const char* value) {\n" " $name$_.Add()->assign(value);\n" " // @@protoc_insertion_point(field_add_char:$full_name$)\n" "}\n" - "$inline$ void " + "$inline$void " "$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n" " $name$_.Add()->assign(reinterpret_cast(value), size);\n" " // @@protoc_insertion_point(field_add_pointer:$full_name$)\n" "}\n"); printer->Print(variables, - "$inline$ const ::google::protobuf::RepeatedPtrField< ::std::string>&\n" + "$inline$const ::google::protobuf::RepeatedPtrField< ::std::string>&\n" "$classname$::$name$() const {\n" " // @@protoc_insertion_point(field_list:$full_name$)\n" " return $name$_;\n" "}\n" - "$inline$ ::google::protobuf::RepeatedPtrField< ::std::string>*\n" + "$inline$::google::protobuf::RepeatedPtrField< ::std::string>*\n" "$classname$::mutable_$name$() {\n" " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" " return &$name$_;\n" @@ -797,6 +799,11 @@ GenerateMergingCode(io::Printer* printer) const { printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n"); } +void RepeatedStringFieldGenerator:: +GenerateUnsafeMergingCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_.UnsafeMergeFrom(from.$name$_);\n"); +} + void RepeatedStringFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n"); @@ -858,7 +865,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { void RepeatedStringFieldGenerator:: GenerateByteSize(io::Printer* printer) const { printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size();\n" + "total_size += $tag_size$ *\n" + " ::google::protobuf::internal::FromIntSize(this->$name$_size());\n" "for (int i = 0; i < this->$name$_size(); i++) {\n" " total_size += ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n" " this->$name$(i));\n" diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.h b/src/google/protobuf/compiler/cpp/cpp_string_field.h index cb4e8772..1dea7663 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.h @@ -110,6 +110,7 @@ class RepeatedStringFieldGenerator : public FieldGenerator { bool is_inline) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; + void GenerateUnsafeMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_unittest.cc index b7b6039a..d214ef0a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc @@ -129,12 +129,12 @@ TEST(GeneratedDescriptorTest, IdenticalDescriptors) { // Test that descriptors are generated correctly by converting them to // FileDescriptorProtos and comparing. - FileDescriptorProto generated_decsriptor_proto, parsed_descriptor_proto; - generated_descriptor->CopyTo(&generated_decsriptor_proto); + FileDescriptorProto generated_descriptor_proto, parsed_descriptor_proto; + generated_descriptor->CopyTo(&generated_descriptor_proto); parsed_descriptor->CopyTo(&parsed_descriptor_proto); EXPECT_EQ(parsed_descriptor_proto.DebugString(), - generated_decsriptor_proto.DebugString()); + generated_descriptor_proto.DebugString()); } #if !defined(GOOGLE_PROTOBUF_CMAKE_BUILD) && !defined(_MSC_VER) diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc index 5e387285..3cbc530e 100644 --- a/src/google/protobuf/compiler/java/java_file.cc +++ b/src/google/protobuf/compiler/java/java_file.cc @@ -189,8 +189,6 @@ void MaybeRestartJavaMethod(io::Printer* printer, *bytecode_estimate = 0; } } - - } // namespace FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options, diff --git a/src/google/protobuf/compiler/java/java_map_field.cc b/src/google/protobuf/compiler/java/java_map_field.cc index 16c5bec5..07aa3565 100644 --- a/src/google/protobuf/compiler/java/java_map_field.cc +++ b/src/google/protobuf/compiler/java/java_map_field.cc @@ -92,7 +92,11 @@ void SetMessageVariables(const FieldDescriptor* descriptor, const JavaType valueJavaType = GetJavaType(value); (*variables)["key_type"] = TypeName(key, name_resolver, false); - (*variables)["boxed_key_type"] = TypeName(key, name_resolver, true); + string boxed_key_type = TypeName(key, name_resolver, true); + (*variables)["boxed_key_type"] = boxed_key_type; + // Used for calling the serialization function. + (*variables)["short_key_type"] = + boxed_key_type.substr(boxed_key_type.rfind('.') + 1); (*variables)["key_wire_type"] = WireType(key); (*variables)["key_default_value"] = DefaultValue(key, true, name_resolver); (*variables)["key_null_check"] = IsReferenceType(keyJavaType) ? @@ -147,6 +151,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, name_resolver->GetImmutableClassName(descriptor->file()) + ".internal_" + UniqueFileScopeIdentifier(descriptor->message_type()) + "_descriptor, "; + (*variables)["ver"] = GeneratedCodeVersionSuffix(); } } // namespace @@ -661,21 +666,23 @@ GenerateParsingCode(io::Printer* printer) const { variables_, "com.google.protobuf.ByteString bytes = input.readBytes();\n" "com.google.protobuf.MapEntry<$type_parameters$>\n" - "$name$ = $default_entry$.getParserForType().parseFrom(bytes);\n"); + "$name$__ = $default_entry$.getParserForType().parseFrom(bytes);\n"); printer->Print( variables_, - "if ($value_enum_type$.forNumber($name$.getValue()) == null) {\n" + "if ($value_enum_type$.forNumber($name$__.getValue()) == null) {\n" " unknownFields.mergeLengthDelimitedField($number$, bytes);\n" "} else {\n" - " $name$_.getMutableMap().put($name$.getKey(), $name$.getValue());\n" + " $name$_.getMutableMap().put(\n" + " $name$__.getKey(), $name$__.getValue());\n" "}\n"); } else { printer->Print( variables_, "com.google.protobuf.MapEntry<$type_parameters$>\n" - "$name$ = input.readMessage(\n" + "$name$__ = input.readMessage(\n" " $default_entry$.getParserForType(), extensionRegistry);\n" - "$name$_.getMutableMap().put($name$.getKey(), $name$.getValue());\n"); + "$name$_.getMutableMap().put(\n" + " $name$__.getKey(), $name$__.getValue());\n"); } } @@ -688,15 +695,12 @@ void ImmutableMapFieldGenerator:: GenerateSerializationCode(io::Printer* printer) const { printer->Print( variables_, - "for (java.util.Map.Entry<$type_parameters$> entry\n" - " : internalGet$capitalized_name$().getMap().entrySet()) {\n" - " com.google.protobuf.MapEntry<$type_parameters$>\n" - " $name$ = $default_entry$.newBuilderForType()\n" - " .setKey(entry.getKey())\n" - " .setValue(entry.getValue())\n" - " .build();\n" - " output.writeMessage($number$, $name$);\n" - "}\n"); + "com.google.protobuf.GeneratedMessage$ver$\n" + " .serialize$short_key_type$MapTo(\n" + " output,\n" + " internalGet$capitalized_name$(),\n" + " $default_entry$,\n" + " $number$);\n"); } void ImmutableMapFieldGenerator:: @@ -706,12 +710,12 @@ GenerateSerializedSizeCode(io::Printer* printer) const { "for (java.util.Map.Entry<$type_parameters$> entry\n" " : internalGet$capitalized_name$().getMap().entrySet()) {\n" " com.google.protobuf.MapEntry<$type_parameters$>\n" - " $name$ = $default_entry$.newBuilderForType()\n" + " $name$__ = $default_entry$.newBuilderForType()\n" " .setKey(entry.getKey())\n" " .setValue(entry.getValue())\n" " .build();\n" " size += com.google.protobuf.CodedOutputStream\n" - " .computeMessageSize($number$, $name$);\n" + " .computeMessageSize($number$, $name$__);\n" "}\n"); } diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.cc b/src/google/protobuf/compiler/java/java_map_field_lite.cc index 0d3bea17..5f102e07 100644 --- a/src/google/protobuf/compiler/java/java_map_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_map_field_lite.cc @@ -765,14 +765,14 @@ GenerateParsingCode(io::Printer* printer) const { printer->Print( variables_, "com.google.protobuf.ByteString bytes = input.readBytes();\n" - "java.util.Map.Entry<$type_parameters$> $name$ =\n" + "java.util.Map.Entry<$type_parameters$> $name$__ =\n" " $default_entry$.parseEntry(bytes, extensionRegistry);\n"); printer->Print( variables_, - "if ($value_enum_type$.forNumber($name$.getValue()) == null) {\n" + "if ($value_enum_type$.forNumber($name$__.getValue()) == null) {\n" " super.mergeLengthDelimitedField($number$, bytes);\n" "} else {\n" - " $name$_.put($name$);\n" + " $name$_.put($name$__);\n" "}\n"); } else { printer->Print( diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc index 6c80d070..68d28b05 100644 --- a/src/google/protobuf/compiler/java/java_message.cc +++ b/src/google/protobuf/compiler/java/java_message.cc @@ -928,7 +928,7 @@ void ImmutableMessageGenerator::GenerateIsInitialized( case FieldDescriptor::LABEL_REPEATED: if (IsMapEntry(field->message_type())) { printer->Print( - "for ($type$ item : get$name$().values()) {\n" + "for ($type$ item : get$name$Map().values()) {\n" " if (!item.isInitialized()) {\n" " memoizedIsInitialized = 0;\n" " return false;\n" diff --git a/src/google/protobuf/compiler/java/java_message_builder.cc b/src/google/protobuf/compiler/java/java_message_builder.cc index 42154694..cd82c51a 100644 --- a/src/google/protobuf/compiler/java/java_message_builder.cc +++ b/src/google/protobuf/compiler/java/java_message_builder.cc @@ -184,6 +184,11 @@ Generate(io::Printer* printer) { "}\n" "\n"); } else { + // Override methods declared in GeneratedMessage to return the concrete + // generated type so callsites won't depend on GeneratedMessage. This + // is needed to keep binary compatibility when we change generated code + // to subclass a different GeneratedMessage class (e.g., in v3.0.0 release + // we changed all generated code to subclass GeneratedMessageV3). printer->Print( "public final Builder setUnknownFields(\n" " final com.google.protobuf.UnknownFieldSet unknownFields) {\n" @@ -456,6 +461,11 @@ GenerateCommonBuilderMethods(io::Printer* printer) { "\n", "classname", name_resolver_->GetImmutableClassName(descriptor_)); + // Override methods declared in GeneratedMessage to return the concrete + // generated type so callsites won't depend on GeneratedMessage. This + // is needed to keep binary compatibility when we change generated code + // to subclass a different GeneratedMessage class (e.g., in v3.0.0 release + // we changed all generated code to subclass GeneratedMessageV3). printer->Print( "public Builder clone() {\n" " return (Builder) super.clone();\n" @@ -596,7 +606,6 @@ GenerateCommonBuilderMethods(io::Printer* printer) { " return this;\n" "}\n" "\n"); - } } @@ -690,7 +699,7 @@ void MessageBuilderGenerator::GenerateIsInitialized( case FieldDescriptor::LABEL_REPEATED: if (IsMapEntry(field->message_type())) { printer->Print( - "for ($type$ item : get$name$().values()) {\n" + "for ($type$ item : get$name$Map().values()) {\n" " if (!item.isInitialized()) {\n" " return false;\n" " }\n" diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.cc b/src/google/protobuf/compiler/java/java_message_field_lite.cc index 14281816..cba18360 100644 --- a/src/google/protobuf/compiler/java/java_message_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_field_lite.cc @@ -145,6 +145,7 @@ GenerateInterfaceMembers(io::Printer* printer) const { void ImmutableMessageFieldLiteGenerator:: GenerateMembers(io::Printer* printer) const { + printer->Print(variables_, "private $type$ $name$_;\n"); PrintExtraFieldInfo(variables_, printer); diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc index 7c8c4a03..0c5a1f8a 100644 --- a/src/google/protobuf/compiler/java/java_message_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_lite.cc @@ -179,6 +179,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { MaybePrintGeneratedAnnotation(context_, printer, descriptor_, /* immutable = */ true); + // The builder_type stores the super type name of the nested Builder class. string builder_type; if (descriptor_->extension_range_count() > 0) { @@ -203,7 +204,6 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { } printer->Indent(); - GenerateConstructor(printer); // Nested types @@ -748,7 +748,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodIsInitialized( case FieldDescriptor::LABEL_REPEATED: if (IsMapEntry(field->message_type())) { printer->Print( - "for ($type$ item : get$name$().values()) {\n" + "for ($type$ item : get$name$Map().values()) {\n" " if (!item.isInitialized()) {\n" " if (shouldMemoize) {\n" " memoizedIsInitialized = 0;\n" diff --git a/src/google/protobuf/compiler/java/java_service.cc b/src/google/protobuf/compiler/java/java_service.cc index 9f34f010..cfa8295d 100644 --- a/src/google/protobuf/compiler/java/java_service.cc +++ b/src/google/protobuf/compiler/java/java_service.cc @@ -184,6 +184,10 @@ void ImmutableServiceGenerator::GenerateAbstractMethods(io::Printer* printer) { } } +string ImmutableServiceGenerator::GetOutput(const MethodDescriptor* method) { + return name_resolver_->GetImmutableClassName(method->output_type()); +} + void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) { printer->Print( "\n" @@ -209,8 +213,7 @@ void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) { vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName( method->input_type()); - vars["output"] = name_resolver_->GetImmutableClassName( - method->output_type()); + vars["output"] = GetOutput(method); printer->Print(vars, "case $index$:\n" " this.$method$(controller, ($input$)request,\n" @@ -257,8 +260,7 @@ void ImmutableServiceGenerator::GenerateCallBlockingMethod( vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName( method->input_type()); - vars["output"] = name_resolver_->GetImmutableClassName( - method->output_type()); + vars["output"] = GetOutput(method); printer->Print(vars, "case $index$:\n" " return impl.$method$(controller, ($input$)request);\n"); @@ -353,8 +355,7 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) { map vars; vars["index"] = SimpleItoa(i); - vars["output"] = name_resolver_->GetImmutableClassName( - method->output_type()); + vars["output"] = GetOutput(method); printer->Print(vars, "channel.callMethod(\n" " getDescriptor().getMethods().get($index$),\n" @@ -418,8 +419,7 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) { map vars; vars["index"] = SimpleItoa(i); - vars["output"] = name_resolver_->GetImmutableClassName( - method->output_type()); + vars["output"] = GetOutput(method); printer->Print(vars, "return ($output$) channel.callBlockingMethod(\n" " getDescriptor().getMethods().get($index$),\n" @@ -443,7 +443,7 @@ void ImmutableServiceGenerator::GenerateMethodSignature(io::Printer* printer, map vars; vars["name"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName(method->input_type()); - vars["output"] = name_resolver_->GetImmutableClassName(method->output_type()); + vars["output"] = GetOutput(method); vars["abstract"] = (is_abstract == IS_ABSTRACT) ? "abstract" : ""; printer->Print(vars, "public $abstract$ void $name$(\n" @@ -458,7 +458,7 @@ void ImmutableServiceGenerator::GenerateBlockingMethodSignature( map vars; vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName(method->input_type()); - vars["output"] = name_resolver_->GetImmutableClassName(method->output_type()); + vars["output"] = GetOutput(method); printer->Print(vars, "\n" "public $output$ $method$(\n" diff --git a/src/google/protobuf/compiler/java/java_service.h b/src/google/protobuf/compiler/java/java_service.h index 5fc9e2f6..12b3f942 100644 --- a/src/google/protobuf/compiler/java/java_service.h +++ b/src/google/protobuf/compiler/java/java_service.h @@ -122,6 +122,9 @@ class ImmutableServiceGenerator : public ServiceGenerator { void GenerateBlockingMethodSignature(io::Printer* printer, const MethodDescriptor* method); + // Return the output type of the method. + string GetOutput(const MethodDescriptor* method); + Context* context_; ClassNameResolver* name_resolver_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableServiceGenerator); diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.cc b/src/google/protobuf/compiler/java/java_shared_code_generator.cc index 52893721..18bf1f51 100644 --- a/src/google/protobuf/compiler/java/java_shared_code_generator.cc +++ b/src/google/protobuf/compiler/java/java_shared_code_generator.cc @@ -119,7 +119,6 @@ void SharedCodeGenerator::Generate(GeneratorContext* context, } } - void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) { // Embed the descriptor. We simply serialize the entire FileDescriptorProto // and embed it as a string literal, which is parsed and built into real @@ -134,7 +133,6 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) { FileDescriptorProto file_proto; file_->CopyTo(&file_proto); - string file_data; file_proto.SerializeToString(&file_data); diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index 58c77d00..1a882057 100755 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -153,8 +153,8 @@ string StripProto(const string& filename) { // Given a filename like foo/bar/baz.proto, returns the corresponding JavaScript // file foo/bar/baz.js. -string GetJSFilename(const string& filename) { - return StripProto(filename) + "_pb.js"; +string GetJSFilename(const GeneratorOptions& options, const string& filename) { + return StripProto(filename) + options.GetFileNameExtension(); } // Given a filename like foo/bar/baz.proto, returns the root directory @@ -273,7 +273,7 @@ string GetPath(const GeneratorOptions& options, string MaybeCrossFileRef(const GeneratorOptions& options, const FileDescriptor* from_file, const Descriptor* to_message) { - if (options.import_style == GeneratorOptions::IMPORT_COMMONJS && + if (options.import_style == GeneratorOptions::kImportCommonJs && from_file != to_message->file()) { // Cross-file ref in CommonJS needs to use the module alias instead of // the global name. @@ -405,21 +405,24 @@ string ToFileName(const string& input) { // that top-level extensions should go in. string GetExtensionFileName(const GeneratorOptions& options, const FileDescriptor* file) { - return options.output_dir + "/" + ToFileName(GetPath(options, file)) + ".js"; + return options.output_dir + "/" + ToFileName(GetPath(options, file)) + + options.GetFileNameExtension(); } // When we're generating one output file per type name, this is the filename // that a top-level message should go in. string GetMessageFileName(const GeneratorOptions& options, const Descriptor* desc) { - return options.output_dir + "/" + ToFileName(desc->name()) + ".js"; + return options.output_dir + "/" + ToFileName(desc->name()) + + options.GetFileNameExtension(); } // When we're generating one output file per type name, this is the filename // that a top-level message should go in. string GetEnumFileName(const GeneratorOptions& options, const EnumDescriptor* desc) { - return options.output_dir + "/" + ToFileName(desc->name()) + ".js"; + return options.output_dir + "/" + ToFileName(desc->name()) + + options.GetFileNameExtension(); } // Returns the message/response ID, if set. @@ -444,9 +447,19 @@ bool IgnoreField(const FieldDescriptor* field) { } +// Used inside Google only -- do not remove. +bool ShouldTreatMapsAsRepeatedFields(const FileDescriptor& descriptor) { + return false; +} + // Do we ignore this message type? bool IgnoreMessage(const GeneratorOptions& options, const Descriptor* d) { - return d->options().map_entry(); + return d->options().map_entry() && + !ShouldTreatMapsAsRepeatedFields(*d->file()); +} + +bool IsMap(const GeneratorOptions& options, const FieldDescriptor* field) { + return field->is_map() && !ShouldTreatMapsAsRepeatedFields(*field->file()); } // Does JSPB ignore this entire oneof? True only if all fields are ignored. @@ -459,10 +472,8 @@ bool IgnoreOneof(const OneofDescriptor* oneof) { return true; } -string JSIdent(const GeneratorOptions& options, - const FieldDescriptor* field, - bool is_upper_camel, - bool is_map) { +string JSIdent(const GeneratorOptions& options, const FieldDescriptor* field, + bool is_upper_camel, bool is_map, bool drop_list) { string result; if (field->type() == FieldDescriptor::TYPE_GROUP) { result = is_upper_camel ? @@ -473,10 +484,10 @@ string JSIdent(const GeneratorOptions& options, ToUpperCamel(ParseLowerUnderscore(field->name())) : ToLowerCamel(ParseLowerUnderscore(field->name())); } - if (is_map || (field->is_map())) { + if (is_map || IsMap(options, field)) { // JSPB-style or proto3-style map. result += "Map"; - } else if (field->is_repeated()) { + } else if (!drop_list && field->is_repeated()) { // Repeated field. result += "List"; } @@ -485,11 +496,10 @@ string JSIdent(const GeneratorOptions& options, string JSObjectFieldName(const GeneratorOptions& options, const FieldDescriptor* field) { - string name = JSIdent( - options, - field, - /* is_upper_camel = */ false, - /* is_map = */ false); + string name = JSIdent(options, field, + /* is_upper_camel = */ false, + /* is_map = */ false, + /* drop_list = */ false); if (IsReserved(name)) { name = "pb_" + name; } @@ -514,10 +524,11 @@ string JSByteGetterSuffix(BytesMode bytes_mode) { // name, e.g. MyField for .getMyField(). string JSGetterName(const GeneratorOptions& options, const FieldDescriptor* field, - BytesMode bytes_mode = BYTES_DEFAULT) { + BytesMode bytes_mode = BYTES_DEFAULT, + bool drop_list = false) { string name = JSIdent(options, field, /* is_upper_camel = */ true, - /* is_map = */ false); + /* is_map = */ false, drop_list); if (field->type() == FieldDescriptor::TYPE_BYTES) { string suffix = JSByteGetterSuffix(bytes_mode); if (!suffix.empty()) { @@ -535,7 +546,8 @@ string JSMapGetterName(const GeneratorOptions& options, const FieldDescriptor* field) { return JSIdent(options, field, /* is_upper_camel = */ true, - /* is_map = */ true); + /* is_map = */ true, + /* drop_list = */ false); } @@ -768,6 +780,10 @@ string MaybeNumberString(const FieldDescriptor* field, const string& orig) { } string JSFieldDefault(const FieldDescriptor* field) { + if (field->is_repeated()) { + return "[]"; + } + switch (field->cpp_type()) { case FieldDescriptor::CPPTYPE_INT32: return MaybeNumberString( @@ -909,20 +925,91 @@ string JSTypeName(const GeneratorOptions& options, } } -bool HasFieldPresence(const FieldDescriptor* field); +bool UseBrokenPresenceSemantics(const GeneratorOptions& options, + const FieldDescriptor* field) { + if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) { + return options.broken_proto3_semantics; + } else if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO2) { + return false; + } else { + GOOGLE_LOG(FATAL) << "We can only handle syntax=proto2 and syntax=proto3."; + return false; + } +} + +// Returns true for fields that return "null" from accessors when they are +// unset. This should normally only be true for non-repeated submessages, but +// we have legacy users who relied on old behavior where accessors behaved this +// way. +bool ReturnsNullWhenUnset(const GeneratorOptions& options, + const FieldDescriptor* field) { + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + field->is_optional()) { + return true; + } + + // TODO(haberman): remove this case and unconditionally return false. + return UseBrokenPresenceSemantics(options, field) && !field->is_repeated() && + !field->has_default_value(); +} + +// In a sane world, this would be the same as ReturnsNullWhenUnset(). But in +// the status quo, some fields declare that they never return null/undefined +// even though they actually do: +// * required fields +// * optional enum fields +// * proto3 primitive fields. +bool DeclaredReturnTypeIsNullable(const GeneratorOptions& options, + const FieldDescriptor* field) { + if (field->is_required() || field->type() == FieldDescriptor::TYPE_ENUM) { + return false; + } + + if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 && + field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) { + return false; + } + + return ReturnsNullWhenUnset(options, field); +} + +bool SetterAcceptsUndefined(const GeneratorOptions& options, + const FieldDescriptor* field) { + if (ReturnsNullWhenUnset(options, field)) { + return true; + } + + // Broken presence semantics always accepts undefined for setters. + return UseBrokenPresenceSemantics(options, field); +} + +bool SetterAcceptsNull(const GeneratorOptions& options, + const FieldDescriptor* field) { + if (ReturnsNullWhenUnset(options, field)) { + return true; + } + + // With broken presence semantics, fields with defaults accept "null" for + // setters, but other fields do not. This is a strange quirk of the old + // codegen. + return UseBrokenPresenceSemantics(options, field) && + field->has_default_value(); +} + +// Returns types which are known to by non-nullable by default. +// The style guide requires that we omit "!" in this case. +bool IsPrimitive(const string& type) { + return type == "undefined" || type == "string" || type == "number" || + type == "boolean"; +} string JSFieldTypeAnnotation(const GeneratorOptions& options, const FieldDescriptor* field, - bool force_optional, + bool is_setter_argument, bool force_present, bool singular_if_not_packed, BytesMode bytes_mode = BYTES_DEFAULT) { - bool is_primitive = - (field->cpp_type() != FieldDescriptor::CPPTYPE_ENUM && - field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE && - (field->type() != FieldDescriptor::TYPE_BYTES || - bytes_mode == BYTES_B64)); - + GOOGLE_CHECK(!(is_setter_argument && force_present)); string jstype = JSTypeName(options, field, bytes_mode); if (field->is_repeated() && @@ -931,27 +1018,35 @@ string JSFieldTypeAnnotation(const GeneratorOptions& options, bytes_mode == BYTES_DEFAULT) { jstype = "(Array|Array)"; } else { - if (!is_primitive) { + if (!IsPrimitive(jstype)) { jstype = "!" + jstype; } jstype = "Array.<" + jstype + ">"; } - if (!force_optional) { - jstype = "!" + jstype; - } } - if (field->is_optional() && is_primitive && - force_optional && !force_present) { - jstype += "?"; - } else if (field->is_required() && !is_primitive && !force_optional) { - jstype = "!" + jstype; - } + bool is_null_or_undefined = false; - if (force_optional && HasFieldPresence(field)) { - jstype += "|undefined"; + if (is_setter_argument) { + if (SetterAcceptsNull(options, field)) { + jstype = "?" + jstype; + is_null_or_undefined = true; + } + + if (SetterAcceptsUndefined(options, field)) { + jstype += "|undefined"; + is_null_or_undefined = true; + } + } else if (force_present) { + // Don't add null or undefined. + } else { + if (DeclaredReturnTypeIsNullable(options, field)) { + jstype = "?" + jstype; + is_null_or_undefined = true; + } } - if (force_present && jstype[0] != '!' && !is_primitive) { + + if (!is_null_or_undefined && !IsPrimitive(jstype)) { jstype = "!" + jstype; } @@ -1007,9 +1102,10 @@ string JSReturnDoc(const GeneratorOptions& options, return ""; } -bool HasRepeatedFields(const Descriptor* desc) { +bool HasRepeatedFields(const GeneratorOptions& options, + const Descriptor* desc) { for (int i = 0; i < desc->field_count(); i++) { - if (desc->field(i)->is_repeated() && !desc->field(i)->is_map()) { + if (desc->field(i)->is_repeated() && !IsMap(options, desc->field(i))) { return true; } } @@ -1020,8 +1116,9 @@ static const char* kRepeatedFieldArrayName = ".repeatedFields_"; string RepeatedFieldsArrayName(const GeneratorOptions& options, const Descriptor* desc) { - return HasRepeatedFields(desc) ? - (GetPath(options, desc) + kRepeatedFieldArrayName) : "null"; + return HasRepeatedFields(options, desc) + ? (GetPath(options, desc) + kRepeatedFieldArrayName) + : "null"; } bool HasOneofFields(const Descriptor* desc) { @@ -1041,10 +1138,11 @@ string OneofFieldsArrayName(const GeneratorOptions& options, (GetPath(options, desc) + kOneofGroupArrayName) : "null"; } -string RepeatedFieldNumberList(const Descriptor* desc) { +string RepeatedFieldNumberList(const GeneratorOptions& options, + const Descriptor* desc) { std::vector numbers; for (int i = 0; i < desc->field_count(); i++) { - if (desc->field(i)->is_repeated() && !desc->field(i)->is_map()) { + if (desc->field(i)->is_repeated() && !IsMap(options, desc->field(i))) { numbers.push_back(JSFieldIndex(desc->field(i))); } } @@ -1108,7 +1206,7 @@ string JSExtensionsObjectName(const GeneratorOptions& options, const FileDescriptor* from_file, const Descriptor* desc) { if (desc->full_name() == "google.protobuf.bridge.MessageSet") { - // TODO(haberman): fix this for the IMPORT_COMMONJS case. + // TODO(haberman): fix this for the kImportCommonJs case. return "jspb.Message.messageSetExtensions"; } else { return MaybeCrossFileRef(options, from_file, desc) + ".extensions"; @@ -1130,7 +1228,7 @@ const FieldDescriptor* MapFieldValue(const FieldDescriptor* field) { string FieldDefinition(const GeneratorOptions& options, const FieldDescriptor* field) { - if (field->is_map()) { + if (IsMap(options, field)) { const FieldDescriptor* key_field = MapFieldKey(field); const FieldDescriptor* value_field = MapFieldValue(field); string key_type = ProtoTypeName(options, key_field); @@ -1254,47 +1352,24 @@ string GetPivot(const Descriptor* desc) { return SimpleItoa(pivot); } -// Returns true for fields that represent "null" as distinct from the default -// value. See http://go/proto3#heading=h.kozewqqcqhuz for more information. -bool HasFieldPresence(const FieldDescriptor* field) { - if (field->is_repeated()) { +// Whether this field represents presence. For fields with presence, we +// generate extra methods (clearFoo() and hasFoo()) for this field. +bool HasFieldPresence(const GeneratorOptions& options, + const FieldDescriptor* field) { + if (field->is_repeated() || field->is_map()) { + // We say repeated fields and maps don't have presence, but we still do + // generate clearFoo() methods for them through a special case elsewhere. return false; } - return - (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) || - (field->containing_oneof() != NULL) || - (field->file()->syntax() != FileDescriptor::SYNTAX_PROTO3); -} - -// For proto3 fields without presence, returns a string representing the default -// value in JavaScript. See http://go/proto3#heading=h.kozewqqcqhuz for more -// information. -string Proto3PrimitiveFieldDefault(const FieldDescriptor* field) { - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_INT32: - case FieldDescriptor::CPPTYPE_INT64: - case FieldDescriptor::CPPTYPE_UINT32: - case FieldDescriptor::CPPTYPE_UINT64: { - return "0"; - } - - case FieldDescriptor::CPPTYPE_ENUM: - case FieldDescriptor::CPPTYPE_FLOAT: - case FieldDescriptor::CPPTYPE_DOUBLE: - return "0"; - - case FieldDescriptor::CPPTYPE_BOOL: - return "false"; - - case FieldDescriptor::CPPTYPE_STRING: // includes BYTES - return "\"\""; - - default: - // MESSAGE is handled separately. - assert(false); - return ""; + if (UseBrokenPresenceSemantics(options, field)) { + // Proto3 files with broken presence semantics have field presence. + return true; } + + return field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || + field->containing_oneof() != NULL || + field->file()->syntax() == FileDescriptor::SYNTAX_PROTO2; } // We use this to implement the semantics that same file can be generated @@ -1524,8 +1599,19 @@ void Generator::GenerateProvides(const GeneratorOptions& options, std::set* provided) const { for (std::set::iterator it = provided->begin(); it != provided->end(); ++it) { - printer->Print("goog.provide('$name$');\n", - "name", *it); + if (options.import_style == GeneratorOptions::kImportClosure) { + printer->Print("goog.provide('$name$');\n", "name", *it); + } else { + // We aren't using Closure's import system, but we use goog.exportSymbol() + // to construct the expected tree of objects, eg. + // + // goog.exportSymbol('foo.bar.Baz', null, this); + // + // // Later generated code expects foo.bar = {} to exist: + // foo.bar.Baz = function() { /* ... */ } + printer->Print("goog.exportSymbol('$name$', null, global);\n", "name", + *it); + } } } @@ -1548,7 +1634,7 @@ void Generator::GenerateRequiresForLibrary( const GeneratorOptions& options, io::Printer* printer, const vector& files, std::set* provided) const { - GOOGLE_CHECK_EQ(options.import_style, GeneratorOptions::IMPORT_CLOSURE); + GOOGLE_CHECK_EQ(options.import_style, GeneratorOptions::kImportClosure); // For Closure imports we need to import every message type individually. std::set required; std::set forwards; @@ -1623,6 +1709,10 @@ void Generator::GenerateRequiresImpl(const GeneratorOptions& options, } } if (require_extension) { + if (options.binary) { + printer->Print( + "goog.require('jspb.ExtensionFieldBinaryInfo');\n"); + } printer->Print( "goog.require('jspb.ExtensionFieldInfo');\n"); } @@ -1755,14 +1845,13 @@ void Generator::GenerateClass(const GeneratorOptions& options, GenerateClassDeserializeBinary(options, printer, desc); GenerateClassSerializeBinary(options, printer, desc); } - GenerateClassClone(options, printer, desc); GenerateClassRegistration(options, printer, desc); GenerateClassFields(options, printer, desc); if (IsExtendable(desc) && desc->full_name() != "google.protobuf.bridge.MessageSet") { GenerateClassExtensionFieldInfo(options, printer, desc); } - if (options.import_style != GeneratorOptions:: IMPORT_CLOSURE) { + if (options.import_style != GeneratorOptions::kImportClosure) { for (int i = 0; i < desc->extension_count(); i++) { GenerateExtension(options, printer, desc->extension(i)); } @@ -1820,7 +1909,7 @@ void Generator::GenerateClassConstructor(const GeneratorOptions& options, void Generator::GenerateClassFieldInfo(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc) const { - if (HasRepeatedFields(desc)) { + if (HasRepeatedFields(options, desc)) { printer->Print( "/**\n" " * List of repeated fields within this message type.\n" @@ -1831,7 +1920,7 @@ void Generator::GenerateClassFieldInfo(const GeneratorOptions& options, "\n", "classname", GetPath(options, desc), "rptfieldarray", kRepeatedFieldArrayName, - "rptfields", RepeatedFieldNumberList(desc)); + "rptfields", RepeatedFieldNumberList(options, desc)); } if (HasOneofFields(desc)) { @@ -2000,14 +2089,59 @@ void Generator::GenerateClassToObject(const GeneratorOptions& options, "classname", GetPath(options, desc)); } +void Generator::GenerateFieldValueExpression(io::Printer* printer, + const char *obj_reference, + const FieldDescriptor* field, + bool use_default) const { + bool is_float_or_double = + field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT || + field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE; + if (use_default) { + if (is_float_or_double) { + // Coerce "Nan" and "Infinity" to actual float values. + // + // This will change null to 0, but that doesn't matter since we're getting + // with a default. + printer->Print("+"); + } + + printer->Print( + "jspb.Message.getFieldWithDefault($obj$, $index$, $default$)", + "obj", obj_reference, + "index", JSFieldIndex(field), + "default", JSFieldDefault(field)); + } else { + if (is_float_or_double) { + if (field->is_required()) { + // Use "+" to convert all fields to numeric (including null). + printer->Print( + "+jspb.Message.getField($obj$, $index$)", + "index", JSFieldIndex(field), + "obj", obj_reference); + } else { + // Converts "NaN" and "Infinity" while preserving null. + printer->Print( + "jspb.Message.get$cardinality$FloatingPointField($obj$, $index$)", + "cardinality", field->is_repeated() ? "Repeated" : "Optional", + "index", JSFieldIndex(field), + "obj", obj_reference); + } + } else { + printer->Print("jspb.Message.getField($obj$, $index$)", + "index", JSFieldIndex(field), + "obj", obj_reference); + } + } +} + void Generator::GenerateClassFieldToObject(const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field) const { printer->Print("$fieldname$: ", "fieldname", JSObjectFieldName(options, field)); - if (field->is_map()) { - printer->Print("(f = msg.get$name$(true)) ? f.toArray() : []", + if (IsMap(options, field)) { + printer->Print("(f = msg.get$name$()) ? f.toArray() : []", "name", JSGetterName(options, field)); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { // Message field. @@ -2024,40 +2158,29 @@ void Generator::GenerateClassFieldToObject(const GeneratorOptions& options, "getter", JSGetterName(options, field), "type", SubmessageTypeRef(options, field)); } + } else if (field->type() == FieldDescriptor::TYPE_BYTES) { + // For bytes fields we want to always return the B64 data. + printer->Print("msg.get$getter$()", + "getter", JSGetterName(options, field, BYTES_B64)); } else { - // Simple field (singular or repeated). - if ((!HasFieldPresence(field) && !field->is_repeated()) || - field->type() == FieldDescriptor::TYPE_BYTES) { - // Delegate to the generated get() method in order not to duplicate - // the proto3-field-default-value or byte-coercion logic here. - printer->Print("msg.get$getter$()", - "getter", JSGetterName(options, field, BYTES_B64)); - } else { - if (field->has_default_value()) { - printer->Print("!msg.has$name$() ? $defaultValue$ : ", - "name", JSGetterName(options, field), - "defaultValue", JSFieldDefault(field)); - } - if (field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT || - field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE) { - if (field->is_repeated()) { - printer->Print("jspb.Message.getRepeatedFloatingPointField(" - "msg, $index$)", - "index", JSFieldIndex(field)); - } else if (field->is_optional() && !field->has_default_value()) { - printer->Print("jspb.Message.getOptionalFloatingPointField(" - "msg, $index$)", - "index", JSFieldIndex(field)); - } else { - // Convert "NaN" to NaN. - printer->Print("+jspb.Message.getField(msg, $index$)", - "index", JSFieldIndex(field)); - } - } else { - printer->Print("jspb.Message.getField(msg, $index$)", - "index", JSFieldIndex(field)); - } + bool use_default = field->has_default_value(); + + if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 && + // Repeated fields get initialized to their default in the constructor + // (why?), so we emit a plain getField() call for them. + !field->is_repeated() && !UseBrokenPresenceSemantics(options, field)) { + // Proto3 puts all defaults (including implicit defaults) in toObject(). + // But for proto2 we leave the existing semantics unchanged: unset fields + // without default are unset. + use_default = true; } + + // We don't implement this by calling the accessors, because the semantics + // of the accessors are changing independently of the toObject() semantics. + // We are migrating the accessors to return defaults instead of null, but + // it may take longer to migrate toObject (or we might not want to do it at + // all). So we want to generate independent code. + GenerateFieldValueExpression(printer, "msg", field, use_default); } } @@ -2091,8 +2214,7 @@ void Generator::GenerateClassFieldFromObject( const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field) const { - - if (field->is_map()) { + if (IsMap(options, field)) { // `msg` is a newly-constructed message object that has not yet built any // map containers wrapping underlying arrays, so we can simply directly set // the array here without fear of a stale wrapper. @@ -2133,21 +2255,6 @@ void Generator::GenerateClassFieldFromObject( } } -void Generator::GenerateClassClone(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - printer->Print( - "/**\n" - " * Creates a deep clone of this proto. No data is shared with the " - "original.\n" - " * @return {!$name$} The clone.\n" - " */\n" - "$name$.prototype.cloneMessage = function() {\n" - " return /** @type {!$name$} */ (jspb.Message.cloneMessage(this));\n" - "};\n\n\n", - "name", GetPath(options, desc)); -} - void Generator::GenerateClassRegistration(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc) const { @@ -2175,12 +2282,11 @@ void GenerateBytesWrapper(const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field, BytesMode bytes_mode) { - string type = - JSFieldTypeAnnotation(options, field, - /* force_optional = */ false, - /* force_present = */ !HasFieldPresence(field), - /* singular_if_not_packed = */ false, - bytes_mode); + string type = JSFieldTypeAnnotation( + options, field, + /* is_setter_argument = */ false, + /* force_present = */ false, + /* singular_if_not_packed = */ false, bytes_mode); printer->Print( "/**\n" " * $fielddef$\n" @@ -2208,20 +2314,20 @@ void GenerateBytesWrapper(const GeneratorOptions& options, void Generator::GenerateClassField(const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field) const { - if (field->is_map()) { + if (IsMap(options, field)) { const FieldDescriptor* key_field = MapFieldKey(field); const FieldDescriptor* value_field = MapFieldValue(field); // Map field: special handling to instantiate the map object on demand. string key_type = JSFieldTypeAnnotation( options, key_field, - /* force_optional = */ false, + /* is_setter_argument = */ false, /* force_present = */ true, /* singular_if_not_packed = */ false); string value_type = JSFieldTypeAnnotation( options, value_field, - /* force_optional = */ false, + /* is_setter_argument = */ false, /* force_present = */ true, /* singular_if_not_packed = */ false); @@ -2275,7 +2381,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options, "fielddef", FieldDefinition(options, field), "comment", FieldComments(field, BYTES_DEFAULT), "type", JSFieldTypeAnnotation(options, field, - /* force_optional = */ false, + /* is_setter_argument = */ false, /* force_present = */ false, /* singular_if_not_packed = */ false)); printer->Print( @@ -2289,7 +2395,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options, "class", GetPath(options, field->containing_type()), "name", JSGetterName(options, field), "type", JSFieldTypeAnnotation(options, field, - /* force_optional = */ false, + /* is_setter_argument = */ false, /* force_present = */ false, /* singular_if_not_packed = */ false), "rpt", (field->is_repeated() ? "Repeated" : ""), @@ -2298,12 +2404,12 @@ void Generator::GenerateClassField(const GeneratorOptions& options, "required", (field->label() == FieldDescriptor::LABEL_REQUIRED ? ", 1" : "")); printer->Print( - "/** @param {$optionaltype$} value $returndoc$ */\n" + "/** @param {$optionaltype$} value$returndoc$ */\n" "$class$.prototype.set$name$ = function(value) {\n" " jspb.Message.set$oneoftag$$repeatedtag$WrapperField(", "optionaltype", JSFieldTypeAnnotation(options, field, - /* force_optional = */ true, + /* is_setter_argument = */ true, /* force_present = */ false, /* singular_if_not_packed = */ false), "returndoc", JSReturnDoc(options, field), @@ -2322,16 +2428,9 @@ void Generator::GenerateClassField(const GeneratorOptions& options, (", " + JSOneofArray(options, field)) : ""), "returnvalue", JSReturnClause(field)); - printer->Print( - "$class$.prototype.clear$name$ = function() {\n" - " this.set$name$($clearedvalue$);$returnvalue$\n" - "};\n" - "\n" - "\n", - "class", GetPath(options, field->containing_type()), - "name", JSGetterName(options, field), - "clearedvalue", (field->is_repeated() ? "[]" : "undefined"), - "returnvalue", JSReturnClause(field)); + if (field->is_repeated()) { + GenerateRepeatedMessageHelperMethods(options, printer, field); + } } else { bool untyped = @@ -2345,12 +2444,12 @@ void Generator::GenerateClassField(const GeneratorOptions& options, BytesMode bytes_mode = field->type() == FieldDescriptor::TYPE_BYTES && !options.binary ? BYTES_B64 : BYTES_DEFAULT; - string typed_annotation = - JSFieldTypeAnnotation(options, field, - /* force_optional = */ false, - /* force_present = */ !HasFieldPresence(field), - /* singular_if_not_packed = */ false, - /* bytes_mode = */ bytes_mode); + string typed_annotation = JSFieldTypeAnnotation( + options, field, + /* is_setter_argument = */ false, + /* force_present = */ false, + /* singular_if_not_packed = */ false, + /* bytes_mode = */ bytes_mode); if (untyped) { printer->Print( "/**\n" @@ -2382,36 +2481,21 @@ void Generator::GenerateClassField(const GeneratorOptions& options, "type", typed_annotation); } - // For proto3 fields without presence, use special getters that will return - // defaults when the field is unset, possibly constructing a value if - // required. - if (!HasFieldPresence(field) && !field->is_repeated()) { - printer->Print("jspb.Message.getFieldProto3(this, $index$, $default$)", - "index", JSFieldIndex(field), - "default", Proto3PrimitiveFieldDefault(field)); - } else { - if (!field->is_repeated()) { - printer->Print("!this.has$name$() ? $defaultValue$ : ", - "name", JSGetterName(options, field), - "defaultValue", JSFieldDefault(field)); - } - if (field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT || - field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE) { - if (field->is_repeated()) { - printer->Print("jspb.Message.getRepeatedFloatingPointField(" - "this, $index$)", - "index", JSFieldIndex(field)); - } else { - // Convert "NaN" to NaN. - printer->Print("+jspb.Message.getField(this, $index$)", - "index", JSFieldIndex(field)); - } - } else { - printer->Print("jspb.Message.getField(this, $index$)", - "index", JSFieldIndex(field)); - } + bool use_default = !ReturnsNullWhenUnset(options, field); + + // Raw fields with no default set should just return undefined. + if (untyped && !field->has_default_value()) { + use_default = false; + } + + // Repeated fields get initialized to their default in the constructor + // (why?), so we emit a plain getField() call for them. + if (field->is_repeated()) { + use_default = false; } + GenerateFieldValueExpression(printer, "this", field, use_default); + if (untyped) { printer->Print( ";\n" @@ -2434,17 +2518,17 @@ void Generator::GenerateClassField(const GeneratorOptions& options, if (untyped) { printer->Print( "/**\n" - " * @param {*} value $returndoc$\n" + " * @param {*} value$returndoc$\n" " */\n", "returndoc", JSReturnDoc(options, field)); } else { printer->Print( - "/** @param {$optionaltype$} value $returndoc$ */\n", - "optionaltype", - JSFieldTypeAnnotation(options, field, - /* force_optional = */ true, - /* force_present = */ !HasFieldPresence(field), - /* singular_if_not_packed = */ false), + "/** @param {$optionaltype$} value$returndoc$ */\n", "optionaltype", + JSFieldTypeAnnotation( + options, field, + /* is_setter_argument = */ true, + /* force_present = */ false, + /* singular_if_not_packed = */ false), "returndoc", JSReturnDoc(options, field)); } printer->Print( @@ -2471,36 +2555,70 @@ void Generator::GenerateClassField(const GeneratorOptions& options, if (untyped) { printer->Print( "/**\n" - " * Clears the value. $returndoc$\n" + " * Clears the value.$returndoc$\n" " */\n", "returndoc", JSReturnDoc(options, field)); } - if (HasFieldPresence(field) || field->is_repeated()) { - printer->Print( - "$class$.prototype.clear$name$ = function() {\n" - " jspb.Message.set$oneoftag$Field(this, $index$$oneofgroup$, ", - "class", GetPath(options, field->containing_type()), - "name", JSGetterName(options, field), - "oneoftag", (field->containing_oneof() ? "Oneof" : ""), - "oneofgroup", (field->containing_oneof() ? - (", " + JSOneofArray(options, field)) : ""), - "index", JSFieldIndex(field)); - printer->Print( - "$clearedvalue$);$returnvalue$\n" - "};\n" - "\n" - "\n", - "clearedvalue", (field->is_repeated() ? "[]" : "undefined"), - "returnvalue", JSReturnClause(field)); + + if (field->is_repeated()) { + GenerateRepeatedPrimitiveHelperMethods(options, printer, field, untyped); } } - if (HasFieldPresence(field)) { + // Generate clearFoo() method for map fields, repeated fields, and other + // fields with presence. + if (IsMap(options, field)) { + printer->Print( + "$class$.prototype.clear$name$ = function() {\n" + " this.get$name$().clear();$returnvalue$\n" + "};\n" + "\n" + "\n", + "class", GetPath(options, field->containing_type()), + "name", JSGetterName(options, field), + "returnvalue", JSReturnClause(field)); + } else if (field->is_repeated() || + (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + !field->is_required())) { + // Fields where we can delegate to the regular setter. + printer->Print( + "$class$.prototype.clear$name$ = function() {\n" + " this.set$name$($clearedvalue$);$returnvalue$\n" + "};\n" + "\n" + "\n", + "class", GetPath(options, field->containing_type()), + "name", JSGetterName(options, field), + "clearedvalue", (field->is_repeated() ? "[]" : "undefined"), + "returnvalue", JSReturnClause(field)); + } else if (HasFieldPresence(options, field)) { + // Fields where we can't delegate to the regular setter because it doesn't + // accept "undefined" as an argument. + printer->Print( + "$class$.prototype.clear$name$ = function() {\n" + " jspb.Message.set$maybeoneof$Field(this, " + "$index$$maybeoneofgroup$, ", + "class", GetPath(options, field->containing_type()), + "name", JSGetterName(options, field), + "maybeoneof", (field->containing_oneof() ? "Oneof" : ""), + "maybeoneofgroup", (field->containing_oneof() ? + (", " + JSOneofArray(options, field)) : ""), + "index", JSFieldIndex(field)); + printer->Print( + "$clearedvalue$);$returnvalue$\n" + "};\n" + "\n" + "\n", + "clearedvalue", (field->is_repeated() ? "[]" : "undefined"), + "returnvalue", JSReturnClause(field)); + } + + if (HasFieldPresence(options, field)) { printer->Print( "/**\n" " * Returns whether this field is set.\n" - " * @return{!boolean}\n" + " * @return {!boolean}\n" " */\n" "$class$.prototype.has$name$ = function() {\n" " return jspb.Message.getField(this, $index$) != null;\n" @@ -2513,6 +2631,59 @@ void Generator::GenerateClassField(const GeneratorOptions& options, } } +void Generator::GenerateRepeatedPrimitiveHelperMethods( + const GeneratorOptions& options, io::Printer* printer, + const FieldDescriptor* field, bool untyped) const { + printer->Print( + "/**\n" + " * @param {!$optionaltype$} value\n" + " * @param {number=} opt_index\n" + " */\n" + "$class$.prototype.add$name$ = function(value, opt_index) {\n" + " jspb.Message.addToRepeatedField(this, $index$", + "class", GetPath(options, field->containing_type()), "name", + JSGetterName(options, field, BYTES_DEFAULT, + /* drop_list = */ true), + "optionaltype", JSTypeName(options, field, BYTES_DEFAULT), "index", + JSFieldIndex(field)); + printer->Print( + "$oneofgroup$, $type$value$rptvalueinit$$typeclose$, opt_index);\n" + "};\n" + "\n" + "\n", + "type", untyped ? "/** @type{string|number|boolean|!Uint8Array} */(" : "", + "typeclose", untyped ? ")" : "", "oneofgroup", + (field->containing_oneof() ? (", " + JSOneofArray(options, field)) : ""), + "rptvalueinit", ""); +} + +void Generator::GenerateRepeatedMessageHelperMethods( + const GeneratorOptions& options, io::Printer* printer, + const FieldDescriptor* field) const { + printer->Print( + "/**\n" + " * @param {!$optionaltype$=} opt_value\n" + " * @param {number=} opt_index\n" + " * @return {!$optionaltype$}\n" + " */\n" + "$class$.prototype.add$name$ = function(opt_value, opt_index) {\n" + " return jspb.Message.addTo$repeatedtag$WrapperField(", + "optionaltype", JSTypeName(options, field, BYTES_DEFAULT), "class", + GetPath(options, field->containing_type()), "name", + JSGetterName(options, field, BYTES_DEFAULT, + /* drop_list = */ true), + "repeatedtag", (field->is_repeated() ? "Repeated" : "")); + + printer->Print( + "this, $index$$oneofgroup$, opt_value, $ctor$, opt_index);\n" + "};\n" + "\n" + "\n", + "index", JSFieldIndex(field), "oneofgroup", + (field->containing_oneof() ? (", " + JSOneofArray(options, field)) : ""), + "ctor", GetPath(options, field->message_type())); +} + void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc) const { @@ -2554,7 +2725,7 @@ void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options, "so that it\n" " * works in OPTIMIZED mode.\n" " *\n" - " * @type {!Object.}\n" + " * @type {!Object.}\n" " */\n" "$class$.extensionsBinary = {};\n" "\n", @@ -2636,7 +2807,7 @@ void Generator::GenerateClassDeserializeBinaryField( printer->Print(" case $num$:\n", "num", SimpleItoa(field->number())); - if (field->is_map()) { + if (IsMap(options, field)) { const FieldDescriptor* key_field = MapFieldKey(field); const FieldDescriptor* value_field = MapFieldValue(field); printer->Print( @@ -2757,11 +2928,18 @@ void Generator::GenerateClassSerializeBinaryField( const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field) const { - if (HasFieldPresence(field) && + if (HasFieldPresence(options, field) && field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) { + string typed_annotation = JSFieldTypeAnnotation( + options, field, + /* is_setter_argument = */ false, + /* force_present = */ false, + /* singular_if_not_packed = */ false, + /* bytes_mode = */ BYTES_DEFAULT); printer->Print( - " f = jspb.Message.getField(this, $index$);\n", - "index", JSFieldIndex(field)); + " f = /** @type {$type$} */ (jspb.Message.getField(this, $index$));\n", + "index", JSFieldIndex(field), + "type", typed_annotation); } else { printer->Print( " f = this.get$name$($nolazy$);\n", @@ -2770,17 +2948,16 @@ void Generator::GenerateClassSerializeBinaryField( "nolazy", (field->is_map()) ? "true" : ""); } - // Print an `if (condition)` statement that evaluates to true if the field // goes on the wire. - if (field->is_map()) { + if (IsMap(options, field)) { printer->Print( " if (f && f.getLength() > 0) {\n"); } else if (field->is_repeated()) { printer->Print( " if (f.length > 0) {\n"); } else { - if (HasFieldPresence(field)) { + if (HasFieldPresence(options, field)) { printer->Print( " if (f != null) {\n"); } else { @@ -2820,7 +2997,7 @@ void Generator::GenerateClassSerializeBinaryField( } // Write the field on the wire. - if (field->is_map()) { + if (IsMap(options, field)) { const FieldDescriptor* key_field = MapFieldKey(field); const FieldDescriptor* value_field = MapFieldValue(field); printer->Print( @@ -2845,7 +3022,7 @@ void Generator::GenerateClassSerializeBinaryField( "index", SimpleItoa(field->number())); if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - !(field->is_map())) { + !IsMap(options, field)) { printer->Print( ",\n" " $submsg$.serializeBinaryToWriter\n", @@ -2907,7 +3084,7 @@ void Generator::GenerateExtension(const GeneratorOptions& options, "class", extension_scope, "extensionType", JSFieldTypeAnnotation( options, field, - /* force_optional = */ false, + /* is_setter_argument = */ false, /* force_present = */ true, /* singular_if_not_packed = */ false)); printer->Print( @@ -2946,11 +3123,11 @@ void Generator::GenerateExtension(const GeneratorOptions& options, "binaryMessageSerializeFn", (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ? (SubmessageTypeRef(options, field) + - ".serializeBinaryToWriter") : "null", + ".serializeBinaryToWriter") : "undefined", "binaryMessageDeserializeFn", (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ? (SubmessageTypeRef(options, field) + - ".deserializeBinaryFromReader") : "null"); + ".deserializeBinaryFromReader") : "undefined"); printer->Print( " $isPacked$);\n", @@ -3005,17 +3182,31 @@ bool GeneratorOptions::ParseFromOptions( library = options[i].second; } else if (options[i].first == "import_style") { if (options[i].second == "closure") { - import_style = IMPORT_CLOSURE; + import_style = kImportClosure; } else if (options[i].second == "commonjs") { - import_style = IMPORT_COMMONJS; + import_style = kImportCommonJs; } else if (options[i].second == "browser") { - import_style = IMPORT_BROWSER; + import_style = kImportBrowser; } else if (options[i].second == "es6") { - import_style = IMPORT_ES6; + import_style = kImportEs6; } else { *error = "Unknown import style " + options[i].second + ", expected " + "one of: closure, commonjs, browser, es6."; } + } else if (options[i].first == "extension") { + extension = options[i].second; + } else if (options[i].first == "one_output_file_per_input_file") { + if (!options[i].second.empty()) { + *error = "Unexpected option value for one_output_file_per_input_file"; + return false; + } + one_output_file_per_input_file = true; + } else if (options[i].first == "broken_proto3_semantics") { + if (!options[i].second.empty()) { + *error = "Unexpected option value for broken_proto3_semantics"; + return false; + } + broken_proto3_semantics = true; } else { // Assume any other option is an output directory, as long as it is a bare // `key` rather than a `key=value` option. @@ -3027,14 +3218,37 @@ bool GeneratorOptions::ParseFromOptions( } } - if (!library.empty() && import_style != IMPORT_CLOSURE) { - *error = "The library option should only be used for " - "import_style=closure"; + if (import_style != kImportClosure && + (add_require_for_enums || testonly || !library.empty() || + error_on_name_conflict || broken_proto3_semantics || + extension != ".js" || one_output_file_per_input_file)) { + *error = + "The add_require_for_enums, testonly, library, error_on_name_conflict, " + "broken_proto3_semantics, extension, and " + "one_output_file_per_input_file options should only be used for " + "import_style=closure"; + return false; } return true; } +GeneratorOptions::OutputMode GeneratorOptions::output_mode() const { + // We use one output file per input file if we are not using Closure or if + // this is explicitly requested. + if (import_style != kImportClosure || one_output_file_per_input_file) { + return kOneOutputFilePerInputFile; + } + + // If a library name is provided, we put everything in that one file. + if (!library.empty()) { + return kEverythingInOneFile; + } + + // Otherwise, we create one output file per type. + return kOneOutputFilePerType; +} + void Generator::GenerateFilesInDepOrder( const GeneratorOptions& options, io::Printer* printer, @@ -3081,7 +3295,7 @@ void Generator::GenerateFile(const GeneratorOptions& options, GenerateHeader(options, printer); // Generate "require" statements. - if (options.import_style == GeneratorOptions::IMPORT_COMMONJS) { + if (options.import_style == GeneratorOptions::kImportCommonJs) { printer->Print("var jspb = require('google-protobuf');\n"); printer->Print("var goog = jspb;\n"); printer->Print("var global = Function('return this')();\n\n"); @@ -3091,42 +3305,43 @@ void Generator::GenerateFile(const GeneratorOptions& options, printer->Print( "var $alias$ = require('$file$');\n", "alias", ModuleAlias(name), - "file", GetRootPath(file->name(), name) + GetJSFilename(name)); + "file", GetRootPath(file->name(), name) + GetJSFilename(options, name)); } } - // We aren't using Closure's import system, but we use goog.exportSymbol() - // to construct the expected tree of objects, eg. - // - // goog.exportSymbol('foo.bar.Baz', null, this); - // - // // Later generated code expects foo.bar = {} to exist: - // foo.bar.Baz = function() { /* ... */ } set provided; - - // Cover the case where this file declares extensions but no messages. - // This will ensure that the file-level object will be declared to hold - // the extensions. + set extensions; for (int i = 0; i < file->extension_count(); i++) { - provided.insert(file->extension(i)->full_name()); + // We honor the jspb::ignore option here only when working with + // Closure-style imports. Use of this option is discouraged and so we want + // to avoid adding new support for it. + if (options.import_style == GeneratorOptions::kImportClosure && + IgnoreField(file->extension(i))) { + continue; + } + provided.insert(GetPath(options, file) + "." + + JSObjectFieldName(options, file->extension(i))); + extensions.insert(file->extension(i)); } FindProvidesForFile(options, printer, file, &provided); - for (std::set::iterator it = provided.begin(); - it != provided.end(); ++it) { - printer->Print("goog.exportSymbol('$name$', null, global);\n", - "name", *it); + GenerateProvides(options, printer, &provided); + vector files; + files.push_back(file); + if (options.import_style == GeneratorOptions::kImportClosure) { + GenerateRequiresForLibrary(options, printer, files, &provided); } GenerateClassesAndEnums(options, printer, file); - // Extensions nested inside messages are emitted inside - // GenerateClassesAndEnums(). - for (int i = 0; i < file->extension_count(); i++) { - GenerateExtension(options, printer, file->extension(i)); + // Generate code for top-level extensions. Extensions nested inside messages + // are emitted inside GenerateClassesAndEnums(). + for (set::const_iterator it = extensions.begin(); + it != extensions.end(); ++it) { + GenerateExtension(options, printer, *it); } - if (options.import_style == GeneratorOptions::IMPORT_COMMONJS) { + if (options.import_style == GeneratorOptions::kImportCommonJs) { printer->Print("goog.object.extend(exports, $package$);\n", "package", GetPath(options, file)); } @@ -3144,15 +3359,10 @@ bool Generator::GenerateAll(const vector& files, } - // There are three schemes for where output files go: - // - // - import_style = IMPORT_CLOSURE, library non-empty: all output in one file - // - import_style = IMPORT_CLOSURE, library empty: one output file per type - // - import_style != IMPORT_CLOSURE: one output file per .proto file - if (options.import_style == GeneratorOptions::IMPORT_CLOSURE && - options.library != "") { + if (options.output_mode() == GeneratorOptions::kEverythingInOneFile) { // All output should go in a single file. - string filename = options.output_dir + "/" + options.library + ".js"; + string filename = options.output_dir + "/" + options.library + + options.GetFileNameExtension(); google::protobuf::scoped_ptr output(context->Open(filename)); GOOGLE_CHECK(output.get()); io::Printer printer(output.get(), '$'); @@ -3187,7 +3397,7 @@ bool Generator::GenerateAll(const vector& files, if (printer.failed()) { return false; } - } else if (options.import_style == GeneratorOptions::IMPORT_CLOSURE) { + } else if (options.output_mode() == GeneratorOptions::kOneOutputFilePerType) { set allowed_set; if (!GenerateJspbAllowedSet(options, files, &allowed_set, error)) { return false; @@ -3279,13 +3489,14 @@ bool Generator::GenerateAll(const vector& files, } } } - } else { + } else /* options.output_mode() == kOneOutputFilePerInputFile */ { // Generate one output file per input (.proto) file. for (int i = 0; i < files.size(); i++) { const google::protobuf::FileDescriptor* file = files[i]; - string filename = options.output_dir + "/" + GetJSFilename(file->name()); + string filename = + options.output_dir + "/" + GetJSFilename(options, file->name()); google::protobuf::scoped_ptr output(context->Open(filename)); GOOGLE_CHECK(output.get()); io::Printer printer(output.get(), '$'); diff --git a/src/google/protobuf/compiler/js/js_generator.h b/src/google/protobuf/compiler/js/js_generator.h index 056c9897..4ca3493c 100755 --- a/src/google/protobuf/compiler/js/js_generator.h +++ b/src/google/protobuf/compiler/js/js_generator.h @@ -36,6 +36,8 @@ #include #include +#include +#include #include namespace google { @@ -53,43 +55,74 @@ namespace compiler { namespace js { struct GeneratorOptions { - // Add a `goog.requires()` call for each enum type used. If not set, a forward - // declaration with `goog.forwardDeclare` is produced instead. - bool add_require_for_enums; - // Set this as a test-only module via `goog.setTestOnly();`. - bool testonly; // Output path. string output_dir; // Namespace prefix. string namespace_prefix; - // Create a library with name _lib.js rather than a separate .js file - // per type? - string library; - // Error if there are two types that would generate the same output file? - bool error_on_name_conflict; // Enable binary-format support? bool binary; // What style of imports should be used. enum ImportStyle { - IMPORT_CLOSURE, // goog.require() - IMPORT_COMMONJS, // require() - IMPORT_BROWSER, // no import statements - IMPORT_ES6, // import { member } from '' + kImportClosure, // goog.require() + kImportCommonJs, // require() + kImportBrowser, // no import statements + kImportEs6, // import { member } from '' } import_style; GeneratorOptions() - : add_require_for_enums(false), - testonly(false), - output_dir("."), + : output_dir("."), namespace_prefix(""), + binary(false), + import_style(kImportClosure), + add_require_for_enums(false), + testonly(false), library(""), error_on_name_conflict(false), - binary(false), - import_style(IMPORT_CLOSURE) {} + broken_proto3_semantics(false), + extension(".js"), + one_output_file_per_input_file(false) {} bool ParseFromOptions( const vector< pair< string, string > >& options, string* error); + + // Returns the file name extension to use for generated code. + string GetFileNameExtension() const { + return import_style == kImportClosure ? extension : "_pb.js"; + } + + enum OutputMode { + // Create an output file for each input .proto file. + kOneOutputFilePerInputFile, + // Create an output file for each type. + kOneOutputFilePerType, + // Put everything in a single file named by the library option. + kEverythingInOneFile, + }; + + // Indicates how to output the generated code based on the provided options. + OutputMode output_mode() const; + + // The remaining options are only relevant when we are using kImportClosure. + + // Add a `goog.requires()` call for each enum type used. If not set, a + // forward declaration with `goog.forwardDeclare` is produced instead. + bool add_require_for_enums; + // Set this as a test-only module via `goog.setTestOnly();`. + bool testonly; + // Create a library with name _lib.js rather than a separate .js file + // per type? + string library; + // Error if there are two types that would generate the same output file? + bool error_on_name_conflict; + // Preserve the broken proto3 semantics from the old codegen? This amounts + // to using proto2 field presence semantics even for proto3 files. DO NOT + // USE except for migrating legacy code. + bool broken_proto3_semantics; + // The extension to use for output file names. + string extension; + // Create a separate output file for each input file? + bool one_output_file_per_input_file; }; // CodeGenerator implementation which generates a JavaScript source file and @@ -207,6 +240,11 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { io::Printer* printer, const FileDescriptor* file) const; + void GenerateFieldValueExpression(io::Printer* printer, + const char* obj_reference, + const FieldDescriptor* field, + bool use_default) const; + // Generate definition for one class. void GenerateClass(const GeneratorOptions& options, io::Printer* printer, @@ -276,6 +314,17 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { io::Printer* printer, const FieldDescriptor* field) const; + // Generate addFoo() method for repeated primitive fields. + void GenerateRepeatedPrimitiveHelperMethods(const GeneratorOptions& options, + io::Printer* printer, + const FieldDescriptor* field, + bool untyped) const; + + // Generate addFoo() method for repeated message fields. + void GenerateRepeatedMessageHelperMethods(const GeneratorOptions& options, + io::Printer* printer, + const FieldDescriptor* field) const; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator); }; diff --git a/src/google/protobuf/compiler/main.cc b/src/google/protobuf/compiler/main.cc index b83b8f32..aca2a5b9 100644 --- a/src/google/protobuf/compiler/main.cc +++ b/src/google/protobuf/compiler/main.cc @@ -32,14 +32,20 @@ #include #include + +#ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP #include #include +#endif // ! OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP + +#ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP #include #include #include #include #include #include +#endif // ! OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP int main(int argc, char* argv[]) { @@ -51,12 +57,15 @@ int main(int argc, char* argv[]) { cli.RegisterGenerator("--cpp_out", "--cpp_opt", &cpp_generator, "Generate C++ header and source."); +#ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP // Proto2 Java google::protobuf::compiler::java::JavaGenerator java_generator; cli.RegisterGenerator("--java_out", &java_generator, "Generate Java source file."); +#endif // !OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP +#ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP // Proto2 Python google::protobuf::compiler::python::Generator py_generator; cli.RegisterGenerator("--python_out", &py_generator, @@ -91,6 +100,7 @@ int main(int argc, char* argv[]) { google::protobuf::compiler::js::Generator js_generator; cli.RegisterGenerator("--js_out", &js_generator, "Generate JavaScript source."); +#endif // !OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP return cli.Run(argc, argv); } diff --git a/src/google/protobuf/compiler/plugin.cc b/src/google/protobuf/compiler/plugin.cc index 2ff50f61..e1087601 100644 --- a/src/google/protobuf/compiler/plugin.cc +++ b/src/google/protobuf/compiler/plugin.cc @@ -118,35 +118,16 @@ bool GenerateCode(const CodeGeneratorRequest& request, GeneratorResponseContext context(response, parsed_files); - if (generator.HasGenerateAll()) { - string error; - bool succeeded = generator.GenerateAll( - parsed_files, request.parameter(), &context, &error); - - if (!succeeded && error.empty()) { - error = "Code generator returned false but provided no error " - "description."; - } - if (!error.empty()) { - response->set_error(error); - } - } else { - for (int i = 0; i < parsed_files.size(); i++) { - const FileDescriptor* file = parsed_files[i]; - - string error; - bool succeeded = generator.Generate( - file, request.parameter(), &context, &error); - - if (!succeeded && error.empty()) { - error = "Code generator returned false but provided no error " - "description."; - } - if (!error.empty()) { - response->set_error(file->name() + ": " + error); - break; - } - } + string error; + bool succeeded = generator.GenerateAll( + parsed_files, request.parameter(), &context, &error); + + if (!succeeded && error.empty()) { + error = "Code generator returned false but provided no error " + "description."; + } + if (!error.empty()) { + response->set_error(error); } return true; diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index 5247f9a2..1c19d46a 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -52,14 +52,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { CodeGeneratorRequest_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( CodeGeneratorRequest_descriptor_, - CodeGeneratorRequest::default_instance_, + CodeGeneratorRequest::internal_default_instance(), CodeGeneratorRequest_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_), -1, -1, sizeof(CodeGeneratorRequest), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_)); CodeGeneratorResponse_descriptor_ = file->message_type(1); static const int CodeGeneratorResponse_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_), @@ -68,14 +67,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { CodeGeneratorResponse_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( CodeGeneratorResponse_descriptor_, - CodeGeneratorResponse::default_instance_, + CodeGeneratorResponse::internal_default_instance(), CodeGeneratorResponse_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_), -1, -1, sizeof(CodeGeneratorResponse), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_)); CodeGeneratorResponse_File_descriptor_ = CodeGeneratorResponse_descriptor_->nested_type(0); static const int CodeGeneratorResponse_File_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, name_), @@ -85,20 +83,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { CodeGeneratorResponse_File_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( CodeGeneratorResponse_File_descriptor_, - CodeGeneratorResponse_File::default_instance_, + CodeGeneratorResponse_File::internal_default_instance(), CodeGeneratorResponse_File_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_), -1, -1, sizeof(CodeGeneratorResponse_File), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_)); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { +void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto); } @@ -107,32 +104,45 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorRequest_descriptor_, &CodeGeneratorRequest::default_instance()); + CodeGeneratorRequest_descriptor_, CodeGeneratorRequest::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorResponse_descriptor_, &CodeGeneratorResponse::default_instance()); + CodeGeneratorResponse_descriptor_, CodeGeneratorResponse::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorResponse_File_descriptor_, &CodeGeneratorResponse_File::default_instance()); + CodeGeneratorResponse_File_descriptor_, CodeGeneratorResponse_File::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - delete CodeGeneratorRequest::default_instance_; delete CodeGeneratorRequest_reflection_; - delete CodeGeneratorResponse::default_instance_; delete CodeGeneratorResponse_reflection_; - delete CodeGeneratorResponse_File::default_instance_; delete CodeGeneratorResponse_File_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + ::google::protobuf::internal::GetEmptyString(); + CodeGeneratorRequest::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + CodeGeneratorResponse::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + CodeGeneratorResponse_File::default_instance_.DefaultConstruct(); + CodeGeneratorRequest::default_instance_.get_mutable()->InitAsDefaultInstance(); + CodeGeneratorResponse::default_instance_.get_mutable()->InitAsDefaultInstance(); + CodeGeneratorResponse_File::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n%google/protobuf/compiler/plugin.proto\022" "\030google.protobuf.compiler\032 google/protob" @@ -148,15 +158,15 @@ void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { "rotosZ\tplugin_go", 456); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/compiler/plugin.proto", &protobuf_RegisterTypes); - CodeGeneratorRequest::default_instance_ = new CodeGeneratorRequest(); - CodeGeneratorResponse::default_instance_ = new CodeGeneratorResponse(); - CodeGeneratorResponse_File::default_instance_ = new CodeGeneratorResponse_File(); - CodeGeneratorRequest::default_instance_->InitAsDefaultInstance(); - CodeGeneratorResponse::default_instance_->InitAsDefaultInstance(); - CodeGeneratorResponse_File::default_instance_->InitAsDefaultInstance(); + ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { @@ -164,6 +174,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto } } static_descriptor_initializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto_; +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; +static void MergeFromFail(int line) { + ::google::protobuf::internal::MergeFromFail(__FILE__, line); +} + +} // namespace + + // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -174,6 +194,7 @@ const int CodeGeneratorRequest::kProtoFileFieldNumber; CodeGeneratorRequest::CodeGeneratorRequest() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorRequest) } @@ -185,15 +206,13 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorRequest) } void CodeGeneratorRequest::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; parameter_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } CodeGeneratorRequest::~CodeGeneratorRequest() { @@ -203,8 +222,6 @@ CodeGeneratorRequest::~CodeGeneratorRequest() { void CodeGeneratorRequest::SharedDtor() { parameter_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void CodeGeneratorRequest::SetCachedSize(int size) const { @@ -218,11 +235,11 @@ const ::google::protobuf::Descriptor* CodeGeneratorRequest::descriptor() { } const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + return *internal_default_instance(); } -CodeGeneratorRequest* CodeGeneratorRequest::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed CodeGeneratorRequest::default_instance_; CodeGeneratorRequest* CodeGeneratorRequest::New(::google::protobuf::Arena* arena) const { CodeGeneratorRequest* n = new CodeGeneratorRequest; @@ -239,7 +256,7 @@ void CodeGeneratorRequest::Clear() { } file_to_generate_.Clear(); proto_file_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -406,9 +423,9 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( return target; } -int CodeGeneratorRequest::ByteSize() const { +size_t CodeGeneratorRequest::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorRequest) - int total_size = 0; + size_t total_size = 0; // optional string parameter = 2; if (has_parameter()) { @@ -418,18 +435,22 @@ int CodeGeneratorRequest::ByteSize() const { } // repeated string file_to_generate = 1; - total_size += 1 * this->file_to_generate_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->file_to_generate_size()); for (int i = 0; i < this->file_to_generate_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->file_to_generate(i)); } // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - total_size += 1 * this->proto_file_size(); - for (int i = 0; i < this->proto_file_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->proto_file(i)); + { + unsigned int count = this->proto_file_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->proto_file(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -437,18 +458,17 @@ int CodeGeneratorRequest::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void CodeGeneratorRequest::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const CodeGeneratorRequest* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const CodeGeneratorRequest* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -456,16 +476,22 @@ void CodeGeneratorRequest::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorRequest) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } - file_to_generate_.MergeFrom(from.file_to_generate_); +} + +void CodeGeneratorRequest::UnsafeMergeFrom(const CodeGeneratorRequest& from) { + GOOGLE_DCHECK(&from != this); + file_to_generate_.UnsafeMergeFrom(from.file_to_generate_); proto_file_.MergeFrom(from.proto_file_); if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) { if (from.has_parameter()) { @@ -474,7 +500,8 @@ void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -489,7 +516,7 @@ void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorRequest) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool CodeGeneratorRequest::IsInitialized() const { @@ -529,49 +556,49 @@ int CodeGeneratorRequest::file_to_generate_size() const { void CodeGeneratorRequest::clear_file_to_generate() { file_to_generate_.Clear(); } - const ::std::string& CodeGeneratorRequest::file_to_generate(int index) const { +const ::std::string& CodeGeneratorRequest::file_to_generate(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) return file_to_generate_.Get(index); } - ::std::string* CodeGeneratorRequest::mutable_file_to_generate(int index) { +::std::string* CodeGeneratorRequest::mutable_file_to_generate(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) return file_to_generate_.Mutable(index); } - void CodeGeneratorRequest::set_file_to_generate(int index, const ::std::string& value) { +void CodeGeneratorRequest::set_file_to_generate(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) file_to_generate_.Mutable(index)->assign(value); } - void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { +void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { file_to_generate_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } - void CodeGeneratorRequest::set_file_to_generate(int index, const char* value, size_t size) { +void CodeGeneratorRequest::set_file_to_generate(int index, const char* value, size_t size) { file_to_generate_.Mutable(index)->assign( reinterpret_cast(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } - ::std::string* CodeGeneratorRequest::add_file_to_generate() { +::std::string* CodeGeneratorRequest::add_file_to_generate() { // @@protoc_insertion_point(field_add_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) return file_to_generate_.Add(); } - void CodeGeneratorRequest::add_file_to_generate(const ::std::string& value) { +void CodeGeneratorRequest::add_file_to_generate(const ::std::string& value) { file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } - void CodeGeneratorRequest::add_file_to_generate(const char* value) { +void CodeGeneratorRequest::add_file_to_generate(const char* value) { file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } - void CodeGeneratorRequest::add_file_to_generate(const char* value, size_t size) { +void CodeGeneratorRequest::add_file_to_generate(const char* value, size_t size) { file_to_generate_.Add()->assign(reinterpret_cast(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } - const ::google::protobuf::RepeatedPtrField< ::std::string>& +const ::google::protobuf::RepeatedPtrField< ::std::string>& CodeGeneratorRequest::file_to_generate() const { // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) return file_to_generate_; } - ::google::protobuf::RepeatedPtrField< ::std::string>* +::google::protobuf::RepeatedPtrField< ::std::string>* CodeGeneratorRequest::mutable_file_to_generate() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) return &file_to_generate_; @@ -591,37 +618,37 @@ void CodeGeneratorRequest::clear_parameter() { parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_parameter(); } - const ::std::string& CodeGeneratorRequest::parameter() const { +const ::std::string& CodeGeneratorRequest::parameter() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter) return parameter_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorRequest::set_parameter(const ::std::string& value) { +void CodeGeneratorRequest::set_parameter(const ::std::string& value) { set_has_parameter(); parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter) } - void CodeGeneratorRequest::set_parameter(const char* value) { +void CodeGeneratorRequest::set_parameter(const char* value) { set_has_parameter(); parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.parameter) } - void CodeGeneratorRequest::set_parameter(const char* value, size_t size) { +void CodeGeneratorRequest::set_parameter(const char* value, size_t size) { set_has_parameter(); parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.parameter) } - ::std::string* CodeGeneratorRequest::mutable_parameter() { +::std::string* CodeGeneratorRequest::mutable_parameter() { set_has_parameter(); // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.parameter) return parameter_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* CodeGeneratorRequest::release_parameter() { +::std::string* CodeGeneratorRequest::release_parameter() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter) clear_has_parameter(); return parameter_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorRequest::set_allocated_parameter(::std::string* parameter) { +void CodeGeneratorRequest::set_allocated_parameter(::std::string* parameter) { if (parameter != NULL) { set_has_parameter(); } else { @@ -673,6 +700,7 @@ const int CodeGeneratorResponse_File::kContentFieldNumber; CodeGeneratorResponse_File::CodeGeneratorResponse_File() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse.File) } @@ -684,17 +712,15 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File) } void CodeGeneratorResponse_File::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); insertion_point_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); content_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } CodeGeneratorResponse_File::~CodeGeneratorResponse_File() { @@ -706,8 +732,6 @@ void CodeGeneratorResponse_File::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); insertion_point_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); content_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void CodeGeneratorResponse_File::SetCachedSize(int size) const { @@ -721,11 +745,11 @@ const ::google::protobuf::Descriptor* CodeGeneratorResponse_File::descriptor() { } const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + return *internal_default_instance(); } -CodeGeneratorResponse_File* CodeGeneratorResponse_File::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed CodeGeneratorResponse_File::default_instance_; CodeGeneratorResponse_File* CodeGeneratorResponse_File::New(::google::protobuf::Arena* arena) const { CodeGeneratorResponse_File* n = new CodeGeneratorResponse_File; @@ -748,7 +772,7 @@ void CodeGeneratorResponse_File::Clear() { content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -921,9 +945,9 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes( return target; } -int CodeGeneratorResponse_File::ByteSize() const { +size_t CodeGeneratorResponse_File::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse.File) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 7u) { // optional string name = 1; @@ -953,18 +977,17 @@ int CodeGeneratorResponse_File::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void CodeGeneratorResponse_File::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const CodeGeneratorResponse_File* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const CodeGeneratorResponse_File* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -972,15 +995,21 @@ void CodeGeneratorResponse_File::MergeFrom(const ::google::protobuf::Message& fr ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorResponse.File) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void CodeGeneratorResponse_File::UnsafeMergeFrom(const CodeGeneratorResponse_File& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { set_has_name(); @@ -996,7 +1025,8 @@ void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& fro } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -1011,7 +1041,7 @@ void CodeGeneratorResponse_File::CopyFrom(const CodeGeneratorResponse_File& from // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool CodeGeneratorResponse_File::IsInitialized() const { @@ -1050,6 +1080,7 @@ const int CodeGeneratorResponse::kFileFieldNumber; CodeGeneratorResponse::CodeGeneratorResponse() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse) } @@ -1061,15 +1092,13 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse) } void CodeGeneratorResponse::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; error_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } CodeGeneratorResponse::~CodeGeneratorResponse() { @@ -1079,8 +1108,6 @@ CodeGeneratorResponse::~CodeGeneratorResponse() { void CodeGeneratorResponse::SharedDtor() { error_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void CodeGeneratorResponse::SetCachedSize(int size) const { @@ -1094,11 +1121,11 @@ const ::google::protobuf::Descriptor* CodeGeneratorResponse::descriptor() { } const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + return *internal_default_instance(); } -CodeGeneratorResponse* CodeGeneratorResponse::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed CodeGeneratorResponse::default_instance_; CodeGeneratorResponse* CodeGeneratorResponse::New(::google::protobuf::Arena* arena) const { CodeGeneratorResponse* n = new CodeGeneratorResponse; @@ -1114,7 +1141,7 @@ void CodeGeneratorResponse::Clear() { error_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } file_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -1241,9 +1268,9 @@ void CodeGeneratorResponse::SerializeWithCachedSizes( return target; } -int CodeGeneratorResponse::ByteSize() const { +size_t CodeGeneratorResponse::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse) - int total_size = 0; + size_t total_size = 0; // optional string error = 1; if (has_error()) { @@ -1253,11 +1280,14 @@ int CodeGeneratorResponse::ByteSize() const { } // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - total_size += 1 * this->file_size(); - for (int i = 0; i < this->file_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->file(i)); + { + unsigned int count = this->file_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->file(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -1265,18 +1295,17 @@ int CodeGeneratorResponse::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void CodeGeneratorResponse::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const CodeGeneratorResponse* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const CodeGeneratorResponse* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -1284,15 +1313,21 @@ void CodeGeneratorResponse::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorResponse) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void CodeGeneratorResponse::UnsafeMergeFrom(const CodeGeneratorResponse& from) { + GOOGLE_DCHECK(&from != this); file_.MergeFrom(from.file_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_error()) { @@ -1301,7 +1336,8 @@ void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -1316,7 +1352,7 @@ void CodeGeneratorResponse::CopyFrom(const CodeGeneratorResponse& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool CodeGeneratorResponse::IsInitialized() const { @@ -1361,37 +1397,37 @@ void CodeGeneratorResponse_File::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& CodeGeneratorResponse_File::name() const { +const ::std::string& CodeGeneratorResponse_File::name() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse_File::set_name(const ::std::string& value) { +void CodeGeneratorResponse_File::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) } - void CodeGeneratorResponse_File::set_name(const char* value) { +void CodeGeneratorResponse_File::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name) } - void CodeGeneratorResponse_File::set_name(const char* value, size_t size) { +void CodeGeneratorResponse_File::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.name) } - ::std::string* CodeGeneratorResponse_File::mutable_name() { +::std::string* CodeGeneratorResponse_File::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* CodeGeneratorResponse_File::release_name() { +::std::string* CodeGeneratorResponse_File::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) { +void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -1415,37 +1451,37 @@ void CodeGeneratorResponse_File::clear_insertion_point() { insertion_point_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_insertion_point(); } - const ::std::string& CodeGeneratorResponse_File::insertion_point() const { +const ::std::string& CodeGeneratorResponse_File::insertion_point() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) return insertion_point_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) { +void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) { set_has_insertion_point(); insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } - void CodeGeneratorResponse_File::set_insertion_point(const char* value) { +void CodeGeneratorResponse_File::set_insertion_point(const char* value) { set_has_insertion_point(); insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } - void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) { +void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) { set_has_insertion_point(); insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } - ::std::string* CodeGeneratorResponse_File::mutable_insertion_point() { +::std::string* CodeGeneratorResponse_File::mutable_insertion_point() { set_has_insertion_point(); // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) return insertion_point_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* CodeGeneratorResponse_File::release_insertion_point() { +::std::string* CodeGeneratorResponse_File::release_insertion_point() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) clear_has_insertion_point(); return insertion_point_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) { +void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) { if (insertion_point != NULL) { set_has_insertion_point(); } else { @@ -1469,37 +1505,37 @@ void CodeGeneratorResponse_File::clear_content() { content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_content(); } - const ::std::string& CodeGeneratorResponse_File::content() const { +const ::std::string& CodeGeneratorResponse_File::content() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content) return content_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse_File::set_content(const ::std::string& value) { +void CodeGeneratorResponse_File::set_content(const ::std::string& value) { set_has_content(); content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) } - void CodeGeneratorResponse_File::set_content(const char* value) { +void CodeGeneratorResponse_File::set_content(const char* value) { set_has_content(); content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content) } - void CodeGeneratorResponse_File::set_content(const char* value, size_t size) { +void CodeGeneratorResponse_File::set_content(const char* value, size_t size) { set_has_content(); content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.content) } - ::std::string* CodeGeneratorResponse_File::mutable_content() { +::std::string* CodeGeneratorResponse_File::mutable_content() { set_has_content(); // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.content) return content_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* CodeGeneratorResponse_File::release_content() { +::std::string* CodeGeneratorResponse_File::release_content() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content) clear_has_content(); return content_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) { +void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) { if (content != NULL) { set_has_content(); } else { @@ -1527,37 +1563,37 @@ void CodeGeneratorResponse::clear_error() { error_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_error(); } - const ::std::string& CodeGeneratorResponse::error() const { +const ::std::string& CodeGeneratorResponse::error() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error) return error_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse::set_error(const ::std::string& value) { +void CodeGeneratorResponse::set_error(const ::std::string& value) { set_has_error(); error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error) } - void CodeGeneratorResponse::set_error(const char* value) { +void CodeGeneratorResponse::set_error(const char* value) { set_has_error(); error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.error) } - void CodeGeneratorResponse::set_error(const char* value, size_t size) { +void CodeGeneratorResponse::set_error(const char* value, size_t size) { set_has_error(); error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.error) } - ::std::string* CodeGeneratorResponse::mutable_error() { +::std::string* CodeGeneratorResponse::mutable_error() { set_has_error(); // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.error) return error_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* CodeGeneratorResponse::release_error() { +::std::string* CodeGeneratorResponse::release_error() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error) clear_has_error(); return error_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void CodeGeneratorResponse::set_allocated_error(::std::string* error) { +void CodeGeneratorResponse::set_allocated_error(::std::string* error) { if (error != NULL) { set_has_error(); } else { diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 282c977d..709ab6ba 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -36,6 +36,7 @@ namespace compiler { // Internal implementation detail -- do not call these. void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); +void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); @@ -68,6 +69,10 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorRequest& default_instance(); + static inline const CodeGeneratorRequest* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(CodeGeneratorRequest* other); // implements Message ---------------------------------------------- @@ -82,7 +87,7 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -98,6 +103,7 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(CodeGeneratorRequest* other); + void UnsafeMergeFrom(const CodeGeneratorRequest& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -159,17 +165,18 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message inline void clear_has_parameter(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::std::string> file_to_generate_; - ::google::protobuf::internal::ArenaStringPtr parameter_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > proto_file_; - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + ::google::protobuf::internal::ArenaStringPtr parameter_; + friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); + friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); void InitAsDefaultInstance(); - static CodeGeneratorRequest* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -196,6 +203,10 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorResponse_File& default_instance(); + static inline const CodeGeneratorResponse_File* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(CodeGeneratorResponse_File* other); // implements Message ---------------------------------------------- @@ -210,7 +221,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -226,6 +237,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(CodeGeneratorResponse_File* other); + void UnsafeMergeFrom(const CodeGeneratorResponse_File& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -287,17 +299,18 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M inline void clear_has_content(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr insertion_point_; ::google::protobuf::internal::ArenaStringPtr content_; - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); + friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); void InitAsDefaultInstance(); - static CodeGeneratorResponse_File* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -324,6 +337,10 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorResponse& default_instance(); + static inline const CodeGeneratorResponse* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(CodeGeneratorResponse* other); // implements Message ---------------------------------------------- @@ -338,7 +355,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -354,6 +371,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(CodeGeneratorResponse* other); + void UnsafeMergeFrom(const CodeGeneratorResponse& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -401,16 +419,17 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag inline void clear_has_error(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::internal::ArenaStringPtr error_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File > file_; - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + ::google::protobuf::internal::ArenaStringPtr error_; + friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); + friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); void InitAsDefaultInstance(); - static CodeGeneratorResponse* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc index d5468a0c..3b1b0d1d 100644 --- a/src/google/protobuf/compiler/python/python_generator.cc +++ b/src/google/protobuf/compiler/python/python_generator.cc @@ -88,8 +88,8 @@ string StripProto(const string& filename) { // Returns the Python module name expected for a given .proto filename. string ModuleName(const string& filename) { string basename = StripProto(filename); - StripString(&basename, "-", '_'); - StripString(&basename, "/", '.'); + ReplaceCharacters(&basename, "-", '_'); + ReplaceCharacters(&basename, "/", '.'); return basename + "_pb2"; } @@ -320,7 +320,7 @@ bool Generator::Generate(const FileDescriptor* file, file_ = file; string module_name = ModuleName(file->name()); string filename = module_name; - StripString(&filename, ".", '/'); + ReplaceCharacters(&filename, ".", '/'); filename += ".py"; FileDescriptorProto fdp; @@ -430,6 +430,15 @@ void Generator::PrintFileDescriptor() const { } printer_->Print("]"); } + if (file_->public_dependency_count() > 0) { + printer_->Print(",\npublic_dependencies=["); + for (int i = 0; i < file_->public_dependency_count(); ++i) { + string module_alias = ModuleAlias(file_->public_dependency(i)->name()); + printer_->Print("$module_alias$.DESCRIPTOR,", "module_alias", + module_alias); + } + printer_->Print("]"); + } // TODO(falk): Also print options and fix the message_type, enum_type, // service and extension later in the generation. @@ -1094,6 +1103,8 @@ void Generator::PrintFieldDescriptor( m["default_value"] = StringifyDefaultValue(field); m["is_extension"] = is_extension ? "True" : "False"; m["options"] = OptionsValue("FieldOptions", options_string); + m["json_name"] = field.has_json_name() ? + ", json_name='" + field.json_name() + "'": ""; // We always set message_type and enum_type to None at this point, and then // these fields in correctly after all referenced descriptors have been // defined and/or imported (see FixForeignFieldsInDescriptors()). @@ -1104,7 +1115,7 @@ void Generator::PrintFieldDescriptor( " has_default_value=$has_default_value$, default_value=$default_value$,\n" " message_type=None, enum_type=None, containing_type=None,\n" " is_extension=$is_extension$, extension_scope=None,\n" - " options=$options$)"; + " options=$options$$json_name$)"; printer_->Print(m, field_descriptor_decl); } diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 9b20946c..4dccb585 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -69,6 +69,7 @@ #undef PACKAGE // autoheader #defines this. :( namespace google { + namespace protobuf { const FieldDescriptor::CppType @@ -164,6 +165,15 @@ const int FieldDescriptor::kLastReservedNumber; namespace { +// Note: I distrust ctype.h due to locales. +char ToUpper(char ch) { + return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch; +} + +char ToLower(char ch) { + return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch; +} + string ToCamelCase(const string& input, bool lower_first) { bool capitalize_next = !lower_first; string result; @@ -173,12 +183,7 @@ string ToCamelCase(const string& input, bool lower_first) { if (input[i] == '_') { capitalize_next = true; } else if (capitalize_next) { - // Note: I distrust ctype.h due to locales. - if ('a' <= input[i] && input[i] <= 'z') { - result.push_back(input[i] - 'a' + 'A'); - } else { - result.push_back(input[i]); - } + result.push_back(ToUpper(input[i])); capitalize_next = false; } else { result.push_back(input[i]); @@ -186,13 +191,116 @@ string ToCamelCase(const string& input, bool lower_first) { } // Lower-case the first letter. - if (lower_first && !result.empty() && 'A' <= result[0] && result[0] <= 'Z') { - result[0] = result[0] - 'A' + 'a'; + if (lower_first && !result.empty()) { + result[0] = ToLower(result[0]); } return result; } +string ToJsonName(const string& input) { + bool capitalize_next = false; + string result; + result.reserve(input.size()); + + for (int i = 0; i < input.size(); i++) { + if (input[i] == '_') { + capitalize_next = true; + } else if (capitalize_next) { + result.push_back(ToUpper(input[i])); + capitalize_next = false; + } else { + result.push_back(input[i]); + } + } + + return result; +} + +string EnumValueToPascalCase(const string& input) { + bool next_upper = true; + string result; + result.reserve(input.size()); + + for (int i = 0; i < input.size(); i++) { + if (input[i] == '_') { + next_upper = true; + } else { + if (next_upper) { + result.push_back(ToUpper(input[i])); + } else { + result.push_back(ToLower(input[i])); + } + next_upper = false; + } + } + + return result; +} + +// Class to remove an enum prefix from enum values. +class PrefixRemover { + public: + PrefixRemover(StringPiece prefix) { + // Strip underscores and lower-case the prefix. + for (int i = 0; i < prefix.size(); i++) { + if (prefix[i] != '_') { + prefix_ += ascii_tolower(prefix[i]); + } + } + } + + // Tries to remove the enum prefix from this enum value. + // If this is not possible, returns the input verbatim. + string MaybeRemove(StringPiece str) { + // We can't just lowercase and strip str and look for a prefix. + // We need to properly recognize the difference between: + // + // enum Foo { + // FOO_BAR_BAZ = 0; + // FOO_BARBAZ = 1; + // } + // + // This is acceptable (though perhaps not advisable) because even when + // we PascalCase, these two will still be distinct (BarBaz vs. Barbaz). + size_t i, j; + + // Skip past prefix_ in str if we can. + for (i = 0, j = 0; i < str.size() && j < prefix_.size(); i++) { + if (str[i] == '_') { + continue; + } + + if (ascii_tolower(str[i]) != prefix_[j++]) { + return str.as_string(); + } + } + + // If we didn't make it through the prefix, we've failed to strip the + // prefix. + if (j < prefix_.size()) { + return str.as_string(); + } + + // Skip underscores between prefix and further characters. + while (i < str.size() && str[i] == '_') { + i++; + } + + // Enum label can't be the empty string. + if (i == str.size()) { + return str.as_string(); + } + + // We successfully stripped the prefix. + str.remove_prefix(i); + return str.as_string(); + } + + private: + string prefix_; +}; + // A DescriptorPool contains a bunch of hash_maps to implement the // various Find*By*() methods. Since hashtable lookups are O(1), it's // most efficient to construct a fixed set of large hash_maps used by @@ -2390,6 +2498,17 @@ void FieldDescriptor::DebugString(int depth, strings::SubstituteAndAppend(contents, " [default = $0", DefaultValueAsString(true)); } + if (has_json_name_) { + if (!bracketed) { + bracketed = true; + contents->append("["); + } else { + contents->append(", "); + } + contents->append("json_name = \""); + contents->append(CEscape(json_name())); + contents->append("\""); + } string formatted_options; if (FormatBracketedOptions(depth, options(), &formatted_options)) { @@ -2980,6 +3099,8 @@ class DescriptorBuilder { void BuildOneof(const OneofDescriptorProto& proto, Descriptor* parent, OneofDescriptor* result); + void CheckEnumValueUniqueness(const EnumDescriptorProto& proto, + const EnumDescriptor* result); void BuildEnum(const EnumDescriptorProto& proto, const Descriptor* parent, EnumDescriptor* result); @@ -4232,7 +4353,7 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, result->json_name_ = tables_->AllocateString(proto.json_name()); } else { result->has_json_name_ = false; - result->json_name_ = result->camelcase_name_; + result->json_name_ = tables_->AllocateString(ToJsonName(proto.name())); } // Some compilers do not allow static_cast directly between two enum types, @@ -4540,6 +4661,61 @@ void DescriptorBuilder::BuildOneof(const OneofDescriptorProto& proto, proto, Symbol(result)); } +void DescriptorBuilder::CheckEnumValueUniqueness( + const EnumDescriptorProto& proto, const EnumDescriptor* result) { + + // Check that enum labels are still unique when we remove the enum prefix from + // values that have it. + // + // This will fail for something like: + // + // enum MyEnum { + // MY_ENUM_FOO = 0; + // FOO = 1; + // } + // + // By enforcing this reasonable constraint, we allow code generators to strip + // the prefix and/or PascalCase it without creating conflicts. This can lead + // to much nicer language-specific enums like: + // + // enum NameType { + // FirstName = 1, + // LastName = 2, + // } + // + // Instead of: + // + // enum NameType { + // NAME_TYPE_FIRST_NAME = 1, + // NAME_TYPE_LAST_NAME = 2, + // } + PrefixRemover remover(result->name()); + map 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::iterator, bool> + insert_result = values.insert(std::make_pair(stripped, value)); + bool inserted = insert_result.second; + + // We don't throw the error if the two conflicting symbols are identical, or + // if they map to the same number. In the former case, the normal symbol + // duplication error will fire so we don't need to (and its error message + // will make more sense). We allow the latter case so users can create + // aliases which add or remove the prefix (code generators that do prefix + // stripping should de-dup the labels in this case). + if (!inserted && insert_result.first->second->name() != value->name() && + insert_result.first->second->number() != value->number()) { + AddError(value->full_name(), proto.value(i), + DescriptorPool::ErrorCollector::NAME, + "When enum name is stripped and label is PascalCased (" + + stripped + "), this value label conflicts with " + + values[stripped]->name()); + } + } +} + void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, const Descriptor* parent, EnumDescriptor* result) { @@ -4568,6 +4744,8 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, BUILD_ARRAY(proto, result, value, BuildEnumValue, result); + CheckEnumValueUniqueness(proto, result); + // Copy options. if (!proto.has_options()) { result->options_ = NULL; // Will set to default_instance later. @@ -5254,7 +5432,6 @@ void DescriptorBuilder::ValidateProto3Enum( } } - void DescriptorBuilder::ValidateMessageOptions(Descriptor* message, const DescriptorProto& proto) { VALIDATE_OPTIONS_FROM_ARRAY(message, field, Field); @@ -5275,7 +5452,6 @@ void DescriptorBuilder::ValidateMessageOptions(Descriptor* message, max_extension_range)); } } - } void DescriptorBuilder::ValidateFieldOptions(FieldDescriptor* field, diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index b040b62c..0151e1d9 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -143,7 +143,7 @@ struct SourceLocation { // See the comments in SourceCodeInfo.Location (descriptor.proto) for details. string leading_comments; string trailing_comments; - vector leading_detached_comments; + std::vector leading_detached_comments; }; // Options when generating machine-parsable output from a descriptor with @@ -558,6 +558,10 @@ class LIBPROTOBUF_EXPORT FieldDescriptor { // Does this field have an explicitly-declared default value? bool has_default_value() const; + // Whether the user has specified the json_name field option in the .proto + // file. + bool has_json_name() const; + // Get the field default value if cpp_type() == CPPTYPE_INT32. If no // explicit default was defined, the default is 0. int32 default_value_int32() const; @@ -683,7 +687,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptor { // file. bool has_json_name_; // If has_json_name_ is true, it's the value specified by the user. - // Otherwise, it has the same value as lowercase_name_. + // Otherwise, it has the same value as camelcase_name_. const string* json_name_; const FileDescriptor* file_; int number_; @@ -1699,6 +1703,7 @@ PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, message_type, const Descriptor*) PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, enum_type, const EnumDescriptor*) PROTOBUF_DEFINE_OPTIONS_ACCESSOR(FieldDescriptor, FieldOptions) PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, has_default_value, bool) +PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, has_json_name, bool) PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_int32 , int32 ) PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_int64 , int64 ) PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_uint32, uint32) diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 13e8776f..3f310801 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -120,14 +120,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { FileDescriptorSet_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FileDescriptorSet_descriptor_, - FileDescriptorSet::default_instance_, + FileDescriptorSet::internal_default_instance(), FileDescriptorSet_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_), -1, -1, sizeof(FileDescriptorSet), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _internal_metadata_)); FileDescriptorProto_descriptor_ = file->message_type(1); static const int FileDescriptorProto_offsets_[12] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, name_), @@ -146,14 +145,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { FileDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FileDescriptorProto_descriptor_, - FileDescriptorProto::default_instance_, + FileDescriptorProto::internal_default_instance(), FileDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_), -1, -1, sizeof(FileDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _internal_metadata_)); DescriptorProto_descriptor_ = file->message_type(2); static const int DescriptorProto_offsets_[10] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, name_), @@ -170,14 +168,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { DescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( DescriptorProto_descriptor_, - DescriptorProto::default_instance_, + DescriptorProto::internal_default_instance(), DescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_), -1, -1, sizeof(DescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _internal_metadata_)); DescriptorProto_ExtensionRange_descriptor_ = DescriptorProto_descriptor_->nested_type(0); static const int DescriptorProto_ExtensionRange_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, start_), @@ -186,14 +183,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { DescriptorProto_ExtensionRange_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( DescriptorProto_ExtensionRange_descriptor_, - DescriptorProto_ExtensionRange::default_instance_, + DescriptorProto_ExtensionRange::internal_default_instance(), DescriptorProto_ExtensionRange_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _has_bits_), -1, -1, sizeof(DescriptorProto_ExtensionRange), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _internal_metadata_)); DescriptorProto_ReservedRange_descriptor_ = DescriptorProto_descriptor_->nested_type(1); static const int DescriptorProto_ReservedRange_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, start_), @@ -202,14 +198,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { DescriptorProto_ReservedRange_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( DescriptorProto_ReservedRange_descriptor_, - DescriptorProto_ReservedRange::default_instance_, + DescriptorProto_ReservedRange::internal_default_instance(), DescriptorProto_ReservedRange_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _has_bits_), -1, -1, sizeof(DescriptorProto_ReservedRange), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _internal_metadata_)); FieldDescriptorProto_descriptor_ = file->message_type(3); static const int FieldDescriptorProto_offsets_[10] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, name_), @@ -226,14 +221,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { FieldDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FieldDescriptorProto_descriptor_, - FieldDescriptorProto::default_instance_, + FieldDescriptorProto::internal_default_instance(), FieldDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_), -1, -1, sizeof(FieldDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _internal_metadata_)); FieldDescriptorProto_Type_descriptor_ = FieldDescriptorProto_descriptor_->enum_type(0); FieldDescriptorProto_Label_descriptor_ = FieldDescriptorProto_descriptor_->enum_type(1); OneofDescriptorProto_descriptor_ = file->message_type(4); @@ -244,14 +238,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { OneofDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( OneofDescriptorProto_descriptor_, - OneofDescriptorProto::default_instance_, + OneofDescriptorProto::internal_default_instance(), OneofDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _has_bits_), -1, -1, sizeof(OneofDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _internal_metadata_)); EnumDescriptorProto_descriptor_ = file->message_type(5); static const int EnumDescriptorProto_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, name_), @@ -261,14 +254,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { EnumDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( EnumDescriptorProto_descriptor_, - EnumDescriptorProto::default_instance_, + EnumDescriptorProto::internal_default_instance(), EnumDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_), -1, -1, sizeof(EnumDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _internal_metadata_)); EnumValueDescriptorProto_descriptor_ = file->message_type(6); static const int EnumValueDescriptorProto_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, name_), @@ -278,14 +270,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { EnumValueDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( EnumValueDescriptorProto_descriptor_, - EnumValueDescriptorProto::default_instance_, + EnumValueDescriptorProto::internal_default_instance(), EnumValueDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_), -1, -1, sizeof(EnumValueDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _internal_metadata_)); ServiceDescriptorProto_descriptor_ = file->message_type(7); static const int ServiceDescriptorProto_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, name_), @@ -295,14 +286,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { ServiceDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ServiceDescriptorProto_descriptor_, - ServiceDescriptorProto::default_instance_, + ServiceDescriptorProto::internal_default_instance(), ServiceDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_), -1, -1, sizeof(ServiceDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _internal_metadata_)); MethodDescriptorProto_descriptor_ = file->message_type(8); static const int MethodDescriptorProto_offsets_[6] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, name_), @@ -315,20 +305,18 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { MethodDescriptorProto_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( MethodDescriptorProto_descriptor_, - MethodDescriptorProto::default_instance_, + MethodDescriptorProto::internal_default_instance(), MethodDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_), -1, -1, sizeof(MethodDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_)); FileOptions_descriptor_ = file->message_type(9); - static const int FileOptions_offsets_[15] = { + static const int FileOptions_offsets_[14] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generate_equals_and_hash_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_string_check_utf8_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, optimize_for_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, go_package_), @@ -344,14 +332,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { FileOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FileOptions_descriptor_, - FileOptions::default_instance_, + FileOptions::internal_default_instance(), FileOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _extensions_), sizeof(FileOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _internal_metadata_)); FileOptions_OptimizeMode_descriptor_ = FileOptions_descriptor_->enum_type(0); MessageOptions_descriptor_ = file->message_type(10); static const int MessageOptions_offsets_[5] = { @@ -364,14 +351,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { MessageOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( MessageOptions_descriptor_, - MessageOptions::default_instance_, + MessageOptions::internal_default_instance(), MessageOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _extensions_), sizeof(MessageOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_)); FieldOptions_descriptor_ = file->message_type(11); static const int FieldOptions_offsets_[7] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, ctype_), @@ -385,14 +371,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { FieldOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FieldOptions_descriptor_, - FieldOptions::default_instance_, + FieldOptions::internal_default_instance(), FieldOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _extensions_), sizeof(FieldOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _internal_metadata_)); FieldOptions_CType_descriptor_ = FieldOptions_descriptor_->enum_type(0); FieldOptions_JSType_descriptor_ = FieldOptions_descriptor_->enum_type(1); OneofOptions_descriptor_ = file->message_type(12); @@ -402,14 +387,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { OneofOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( OneofOptions_descriptor_, - OneofOptions::default_instance_, + OneofOptions::internal_default_instance(), OneofOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _extensions_), sizeof(OneofOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _internal_metadata_)); EnumOptions_descriptor_ = file->message_type(13); static const int EnumOptions_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, allow_alias_), @@ -419,14 +403,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { EnumOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( EnumOptions_descriptor_, - EnumOptions::default_instance_, + EnumOptions::internal_default_instance(), EnumOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _extensions_), sizeof(EnumOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _internal_metadata_)); EnumValueOptions_descriptor_ = file->message_type(14); static const int EnumValueOptions_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, deprecated_), @@ -435,14 +418,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { EnumValueOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( EnumValueOptions_descriptor_, - EnumValueOptions::default_instance_, + EnumValueOptions::internal_default_instance(), EnumValueOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _extensions_), sizeof(EnumValueOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _internal_metadata_)); ServiceOptions_descriptor_ = file->message_type(15); static const int ServiceOptions_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, deprecated_), @@ -451,14 +433,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { ServiceOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ServiceOptions_descriptor_, - ServiceOptions::default_instance_, + ServiceOptions::internal_default_instance(), ServiceOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _extensions_), sizeof(ServiceOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _internal_metadata_)); MethodOptions_descriptor_ = file->message_type(16); static const int MethodOptions_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, deprecated_), @@ -467,14 +448,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { MethodOptions_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( MethodOptions_descriptor_, - MethodOptions::default_instance_, + MethodOptions::internal_default_instance(), MethodOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _has_bits_), -1, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _extensions_), sizeof(MethodOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _internal_metadata_)); UninterpretedOption_descriptor_ = file->message_type(17); static const int UninterpretedOption_offsets_[7] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, name_), @@ -488,14 +468,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { UninterpretedOption_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( UninterpretedOption_descriptor_, - UninterpretedOption::default_instance_, + UninterpretedOption::internal_default_instance(), UninterpretedOption_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_), -1, -1, sizeof(UninterpretedOption), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _internal_metadata_)); UninterpretedOption_NamePart_descriptor_ = UninterpretedOption_descriptor_->nested_type(0); static const int UninterpretedOption_NamePart_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, name_part_), @@ -504,14 +483,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { UninterpretedOption_NamePart_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( UninterpretedOption_NamePart_descriptor_, - UninterpretedOption_NamePart::default_instance_, + UninterpretedOption_NamePart::internal_default_instance(), UninterpretedOption_NamePart_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _has_bits_), -1, -1, sizeof(UninterpretedOption_NamePart), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _internal_metadata_)); SourceCodeInfo_descriptor_ = file->message_type(18); static const int SourceCodeInfo_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, location_), @@ -519,14 +497,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { SourceCodeInfo_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( SourceCodeInfo_descriptor_, - SourceCodeInfo::default_instance_, + SourceCodeInfo::internal_default_instance(), SourceCodeInfo_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_), -1, -1, sizeof(SourceCodeInfo), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _internal_metadata_)); SourceCodeInfo_Location_descriptor_ = SourceCodeInfo_descriptor_->nested_type(0); static const int SourceCodeInfo_Location_offsets_[5] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, path_), @@ -538,14 +515,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { SourceCodeInfo_Location_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( SourceCodeInfo_Location_descriptor_, - SourceCodeInfo_Location::default_instance_, + SourceCodeInfo_Location::internal_default_instance(), SourceCodeInfo_Location_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _has_bits_), -1, -1, sizeof(SourceCodeInfo_Location), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _internal_metadata_)); GeneratedCodeInfo_descriptor_ = file->message_type(19); static const int GeneratedCodeInfo_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, annotation_), @@ -553,14 +529,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GeneratedCodeInfo_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( GeneratedCodeInfo_descriptor_, - GeneratedCodeInfo::default_instance_, + GeneratedCodeInfo::internal_default_instance(), GeneratedCodeInfo_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _has_bits_), -1, -1, sizeof(GeneratedCodeInfo), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _internal_metadata_)); GeneratedCodeInfo_Annotation_descriptor_ = GeneratedCodeInfo_descriptor_->nested_type(0); static const int GeneratedCodeInfo_Annotation_offsets_[4] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, path_), @@ -571,20 +546,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GeneratedCodeInfo_Annotation_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( GeneratedCodeInfo_Annotation_descriptor_, - GeneratedCodeInfo_Annotation::default_instance_, + GeneratedCodeInfo_Annotation::internal_default_instance(), GeneratedCodeInfo_Annotation_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _has_bits_), -1, -1, sizeof(GeneratedCodeInfo_Annotation), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _internal_metadata_), - -1); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _internal_metadata_)); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { +void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto); } @@ -593,119 +567,164 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileDescriptorSet_descriptor_, &FileDescriptorSet::default_instance()); + FileDescriptorSet_descriptor_, FileDescriptorSet::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileDescriptorProto_descriptor_, &FileDescriptorProto::default_instance()); + FileDescriptorProto_descriptor_, FileDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_descriptor_, &DescriptorProto::default_instance()); + DescriptorProto_descriptor_, DescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_ExtensionRange_descriptor_, &DescriptorProto_ExtensionRange::default_instance()); + DescriptorProto_ExtensionRange_descriptor_, DescriptorProto_ExtensionRange::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_ReservedRange_descriptor_, &DescriptorProto_ReservedRange::default_instance()); + DescriptorProto_ReservedRange_descriptor_, DescriptorProto_ReservedRange::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldDescriptorProto_descriptor_, &FieldDescriptorProto::default_instance()); + FieldDescriptorProto_descriptor_, FieldDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - OneofDescriptorProto_descriptor_, &OneofDescriptorProto::default_instance()); + OneofDescriptorProto_descriptor_, OneofDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumDescriptorProto_descriptor_, &EnumDescriptorProto::default_instance()); + EnumDescriptorProto_descriptor_, EnumDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValueDescriptorProto_descriptor_, &EnumValueDescriptorProto::default_instance()); + EnumValueDescriptorProto_descriptor_, EnumValueDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ServiceDescriptorProto_descriptor_, &ServiceDescriptorProto::default_instance()); + ServiceDescriptorProto_descriptor_, ServiceDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MethodDescriptorProto_descriptor_, &MethodDescriptorProto::default_instance()); + MethodDescriptorProto_descriptor_, MethodDescriptorProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileOptions_descriptor_, &FileOptions::default_instance()); + FileOptions_descriptor_, FileOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MessageOptions_descriptor_, &MessageOptions::default_instance()); + MessageOptions_descriptor_, MessageOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldOptions_descriptor_, &FieldOptions::default_instance()); + FieldOptions_descriptor_, FieldOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - OneofOptions_descriptor_, &OneofOptions::default_instance()); + OneofOptions_descriptor_, OneofOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumOptions_descriptor_, &EnumOptions::default_instance()); + EnumOptions_descriptor_, EnumOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValueOptions_descriptor_, &EnumValueOptions::default_instance()); + EnumValueOptions_descriptor_, EnumValueOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ServiceOptions_descriptor_, &ServiceOptions::default_instance()); + ServiceOptions_descriptor_, ServiceOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MethodOptions_descriptor_, &MethodOptions::default_instance()); + MethodOptions_descriptor_, MethodOptions::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UninterpretedOption_descriptor_, &UninterpretedOption::default_instance()); + UninterpretedOption_descriptor_, UninterpretedOption::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UninterpretedOption_NamePart_descriptor_, &UninterpretedOption_NamePart::default_instance()); + UninterpretedOption_NamePart_descriptor_, UninterpretedOption_NamePart::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceCodeInfo_descriptor_, &SourceCodeInfo::default_instance()); + SourceCodeInfo_descriptor_, SourceCodeInfo::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceCodeInfo_Location_descriptor_, &SourceCodeInfo_Location::default_instance()); + SourceCodeInfo_Location_descriptor_, SourceCodeInfo_Location::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - GeneratedCodeInfo_descriptor_, &GeneratedCodeInfo::default_instance()); + GeneratedCodeInfo_descriptor_, GeneratedCodeInfo::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - GeneratedCodeInfo_Annotation_descriptor_, &GeneratedCodeInfo_Annotation::default_instance()); + GeneratedCodeInfo_Annotation_descriptor_, GeneratedCodeInfo_Annotation::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto() { - delete FileDescriptorSet::default_instance_; delete FileDescriptorSet_reflection_; - delete FileDescriptorProto::default_instance_; delete FileDescriptorProto_reflection_; - delete DescriptorProto::default_instance_; delete DescriptorProto_reflection_; - delete DescriptorProto_ExtensionRange::default_instance_; delete DescriptorProto_ExtensionRange_reflection_; - delete DescriptorProto_ReservedRange::default_instance_; delete DescriptorProto_ReservedRange_reflection_; - delete FieldDescriptorProto::default_instance_; delete FieldDescriptorProto_reflection_; - delete OneofDescriptorProto::default_instance_; delete OneofDescriptorProto_reflection_; - delete EnumDescriptorProto::default_instance_; delete EnumDescriptorProto_reflection_; - delete EnumValueDescriptorProto::default_instance_; delete EnumValueDescriptorProto_reflection_; - delete ServiceDescriptorProto::default_instance_; delete ServiceDescriptorProto_reflection_; - delete MethodDescriptorProto::default_instance_; delete MethodDescriptorProto_reflection_; - delete FileOptions::default_instance_; delete FileOptions_reflection_; - delete MessageOptions::default_instance_; delete MessageOptions_reflection_; - delete FieldOptions::default_instance_; delete FieldOptions_reflection_; - delete OneofOptions::default_instance_; delete OneofOptions_reflection_; - delete EnumOptions::default_instance_; delete EnumOptions_reflection_; - delete EnumValueOptions::default_instance_; delete EnumValueOptions_reflection_; - delete ServiceOptions::default_instance_; delete ServiceOptions_reflection_; - delete MethodOptions::default_instance_; delete MethodOptions_reflection_; - delete UninterpretedOption::default_instance_; delete UninterpretedOption_reflection_; - delete UninterpretedOption_NamePart::default_instance_; delete UninterpretedOption_NamePart_reflection_; - delete SourceCodeInfo::default_instance_; delete SourceCodeInfo_reflection_; - delete SourceCodeInfo_Location::default_instance_; delete SourceCodeInfo_Location_reflection_; - delete GeneratedCodeInfo::default_instance_; delete GeneratedCodeInfo_reflection_; - delete GeneratedCodeInfo_Annotation::default_instance_; delete GeneratedCodeInfo_Annotation_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + FileDescriptorSet::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + FileDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + DescriptorProto::default_instance_.DefaultConstruct(); + DescriptorProto_ExtensionRange::default_instance_.DefaultConstruct(); + DescriptorProto_ReservedRange::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + FieldDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + OneofDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + EnumDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + EnumValueDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + ServiceDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + MethodDescriptorProto::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + FileOptions::default_instance_.DefaultConstruct(); + MessageOptions::default_instance_.DefaultConstruct(); + FieldOptions::default_instance_.DefaultConstruct(); + OneofOptions::default_instance_.DefaultConstruct(); + EnumOptions::default_instance_.DefaultConstruct(); + EnumValueOptions::default_instance_.DefaultConstruct(); + ServiceOptions::default_instance_.DefaultConstruct(); + MethodOptions::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + UninterpretedOption::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + UninterpretedOption_NamePart::default_instance_.DefaultConstruct(); + SourceCodeInfo::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + SourceCodeInfo_Location::default_instance_.DefaultConstruct(); + GeneratedCodeInfo::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + GeneratedCodeInfo_Annotation::default_instance_.DefaultConstruct(); + FileDescriptorSet::default_instance_.get_mutable()->InitAsDefaultInstance(); + FileDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + DescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + DescriptorProto_ExtensionRange::default_instance_.get_mutable()->InitAsDefaultInstance(); + DescriptorProto_ReservedRange::default_instance_.get_mutable()->InitAsDefaultInstance(); + FieldDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + OneofDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + EnumDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + EnumValueDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + ServiceDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + MethodDescriptorProto::default_instance_.get_mutable()->InitAsDefaultInstance(); + FileOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + MessageOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + FieldOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + OneofOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + EnumOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + EnumValueOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + ServiceOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + MethodOptions::default_instance_.get_mutable()->InitAsDefaultInstance(); + UninterpretedOption::default_instance_.get_mutable()->InitAsDefaultInstance(); + UninterpretedOption_NamePart::default_instance_.get_mutable()->InitAsDefaultInstance(); + SourceCodeInfo::default_instance_.get_mutable()->InitAsDefaultInstance(); + SourceCodeInfo_Location::default_instance_.get_mutable()->InitAsDefaultInstance(); + GeneratedCodeInfo::default_instance_.get_mutable()->InitAsDefaultInstance(); + GeneratedCodeInfo_Annotation::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n google/protobuf/descriptor.proto\022\017goog" "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file" @@ -772,29 +791,28 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "\n\013output_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.g" "oogle.protobuf.MethodOptions\022\037\n\020client_s" "treaming\030\005 \001(\010:\005false\022\037\n\020server_streamin" - "g\030\006 \001(\010:\005false\"\207\005\n\013FileOptions\022\024\n\014java_p" + "g\030\006 \001(\010:\005false\"\331\004\n\013FileOptions\022\024\n\014java_p" "ackage\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001" - "(\t\022\"\n\023java_multiple_files\030\n \001(\010:\005false\022," - "\n\035java_generate_equals_and_hash\030\024 \001(\010:\005f" - "alse\022%\n\026java_string_check_utf8\030\033 \001(\010:\005fa" - "lse\022F\n\014optimize_for\030\t \001(\0162).google.proto" - "buf.FileOptions.OptimizeMode:\005SPEED\022\022\n\ng" - "o_package\030\013 \001(\t\022\"\n\023cc_generic_services\030\020" - " \001(\010:\005false\022$\n\025java_generic_services\030\021 \001" - "(\010:\005false\022\"\n\023py_generic_services\030\022 \001(\010:\005" - "false\022\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_e" - "nable_arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_" - "prefix\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022C" - "\n\024uninterpreted_option\030\347\007 \003(\0132$.google.p" - "rotobuf.UninterpretedOption\":\n\014OptimizeM" - "ode\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RU" - "NTIME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\346\001\n\016MessageOpti" - "ons\022&\n\027message_set_wire_format\030\001 \001(\010:\005fa" - "lse\022.\n\037no_standard_descriptor_accessor\030\002" - " \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021" - "\n\tmap_entry\030\007 \001(\010\022C\n\024uninterpreted_optio" - "n\030\347\007 \003(\0132$.google.protobuf.Uninterpreted" - "Option*\t\010\350\007\020\200\200\200\200\002\"\230\003\n\014FieldOptions\022:\n\005ct" + "(\t\022\"\n\023java_multiple_files\030\n \001(\010:\005false\022%" + "\n\026java_string_check_utf8\030\033 \001(\010:\005false\022F\n" + "\014optimize_for\030\t \001(\0162).google.protobuf.Fi" + "leOptions.OptimizeMode:\005SPEED\022\022\n\ngo_pack" + "age\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(\010:\005" + "false\022$\n\025java_generic_services\030\021 \001(\010:\005fa" + "lse\022\"\n\023py_generic_services\030\022 \001(\010:\005false\022" + "\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enable_" + "arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_prefix" + "\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022C\n\024unin" + "terpreted_option\030\347\007 \003(\0132$.google.protobu" + "f.UninterpretedOption\":\n\014OptimizeMode\022\t\n" + "\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020" + "\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\354\001\n\016MessageOptions\022&\n" + "\027message_set_wire_format\030\001 \001(\010:\005false\022.\n" + "\037no_standard_descriptor_accessor\030\002 \001(\010:\005" + "false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tmap_" + "entry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347\007 \003" + "(\0132$.google.protobuf.UninterpretedOption" + "*\t\010\350\007\020\200\200\200\200\002J\004\010\010\020\t\"\236\003\n\014FieldOptions\022:\n\005ct" "ype\030\001 \001(\0162#.google.protobuf.FieldOptions" ".CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jstype" "\030\006 \001(\0162$.google.protobuf.FieldOptions.JS" @@ -804,97 +822,52 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "ogle.protobuf.UninterpretedOption\"/\n\005CTy" "pe\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIECE" "\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_STRING" - "\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002\"^\n\014OneofOpt" - "ions\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.go" - "ogle.protobuf.UninterpretedOption*\t\010\350\007\020\200" - "\200\200\200\002\"\215\001\n\013EnumOptions\022\023\n\013allow_alias\030\002 \001(" - "\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n\024uninterp" - "reted_option\030\347\007 \003(\0132$.google.protobuf.Un" - "interpretedOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020EnumValu" - "eOptions\022\031\n\ndeprecated\030\001 \001(\010:\005false\022C\n\024u" - "ninterpreted_option\030\347\007 \003(\0132$.google.prot" - "obuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016S" - "erviceOptions\022\031\n\ndeprecated\030! \001(\010:\005false" - "\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.google" - ".protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002" - "\"z\n\rMethodOptions\022\031\n\ndeprecated\030! \001(\010:\005f" - "alse\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.go" - "ogle.protobuf.UninterpretedOption*\t\010\350\007\020\200" - "\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n\004name\030\002 \003" - "(\0132-.google.protobuf.UninterpretedOption" - ".NamePart\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022p" - "ositive_int_value\030\004 \001(\004\022\032\n\022negative_int_" - "value\030\005 \001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014str" - "ing_value\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t" - "\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_ex" - "tension\030\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010loca" - "tion\030\001 \003(\0132(.google.protobuf.SourceCodeI" - "nfo.Location\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B" - "\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading_comment" - "s\030\003 \001(\t\022\031\n\021trailing_comments\030\004 \001(\t\022!\n\031le" - "ading_detached_comments\030\006 \003(\t\"\247\001\n\021Genera" - "tedCodeInfo\022A\n\nannotation\030\001 \003(\0132-.google" - ".protobuf.GeneratedCodeInfo.Annotation\032O" - "\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013source" - "_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B" - "[\n\023com.google.protobufB\020DescriptorProtos" - "H\001Z\ndescriptor\240\001\001\242\002\003GPB\252\002\032Google.Protobu" - "f.Reflection", 5292); + "\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n\014On" + "eofOptions\022C\n\024uninterpreted_option\030\347\007 \003(" + "\0132$.google.protobuf.UninterpretedOption*" + "\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013EnumOptions\022\023\n\013allow_alia" + "s\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n\024un" + "interpreted_option\030\347\007 \003(\0132$.google.proto" + "buf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020En" + "umValueOptions\022\031\n\ndeprecated\030\001 \001(\010:\005fals" + "e\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.googl" + "e.protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200" + "\002\"{\n\016ServiceOptions\022\031\n\ndeprecated\030! \001(\010:" + "\005false\022C\n\024uninterpreted_option\030\347\007 \003(\0132$." + "google.protobuf.UninterpretedOption*\t\010\350\007" + "\020\200\200\200\200\002\"z\n\rMethodOptions\022\031\n\ndeprecated\030! " + "\001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(" + "\0132$.google.protobuf.UninterpretedOption*" + "\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n\004na" + "me\030\002 \003(\0132-.google.protobuf.Uninterpreted" + "Option.NamePart\022\030\n\020identifier_value\030\003 \001(" + "\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022negativ" + "e_int_value\030\005 \001(\003\022\024\n\014double_value\030\006 \001(\001\022" + "\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_value" + "\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t\022\024\n" + "\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:" + "\n\010location\030\001 \003(\0132(.google.protobuf.Sourc" + "eCodeInfo.Location\032\206\001\n\010Location\022\020\n\004path\030" + "\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading_c" + "omments\030\003 \001(\t\022\031\n\021trailing_comments\030\004 \001(\t" + "\022!\n\031leading_detached_comments\030\006 \003(\t\"\247\001\n\021" + "GeneratedCodeInfo\022A\n\nannotation\030\001 \003(\0132-." + "google.protobuf.GeneratedCodeInfo.Annota" + "tion\032O\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013" + "source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030" + "\004 \001(\005BX\n\023com.google.protobufB\020Descriptor" + "ProtosH\001Z\ndescriptor\242\002\003GPB\252\002\032Google.Prot" + "obuf.Reflection", 5255); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); - FileDescriptorSet::default_instance_ = new FileDescriptorSet(); - FileDescriptorProto::default_instance_ = new FileDescriptorProto(); - DescriptorProto::default_instance_ = new DescriptorProto(); - DescriptorProto_ExtensionRange::default_instance_ = new DescriptorProto_ExtensionRange(); - DescriptorProto_ReservedRange::default_instance_ = new DescriptorProto_ReservedRange(); - FieldDescriptorProto::default_instance_ = new FieldDescriptorProto(); - OneofDescriptorProto::default_instance_ = new OneofDescriptorProto(); - EnumDescriptorProto::default_instance_ = new EnumDescriptorProto(); - EnumValueDescriptorProto::default_instance_ = new EnumValueDescriptorProto(); - ServiceDescriptorProto::default_instance_ = new ServiceDescriptorProto(); - MethodDescriptorProto::default_instance_ = new MethodDescriptorProto(); - FileOptions::default_instance_ = new FileOptions(); - MessageOptions::default_instance_ = new MessageOptions(); - FieldOptions::default_instance_ = new FieldOptions(); - OneofOptions::default_instance_ = new OneofOptions(); - EnumOptions::default_instance_ = new EnumOptions(); - EnumValueOptions::default_instance_ = new EnumValueOptions(); - ServiceOptions::default_instance_ = new ServiceOptions(); - MethodOptions::default_instance_ = new MethodOptions(); - UninterpretedOption::default_instance_ = new UninterpretedOption(); - UninterpretedOption_NamePart::default_instance_ = new UninterpretedOption_NamePart(); - SourceCodeInfo::default_instance_ = new SourceCodeInfo(); - SourceCodeInfo_Location::default_instance_ = new SourceCodeInfo_Location(); - GeneratedCodeInfo::default_instance_ = new GeneratedCodeInfo(); - GeneratedCodeInfo_Annotation::default_instance_ = new GeneratedCodeInfo_Annotation(); - FileDescriptorSet::default_instance_->InitAsDefaultInstance(); - FileDescriptorProto::default_instance_->InitAsDefaultInstance(); - DescriptorProto::default_instance_->InitAsDefaultInstance(); - DescriptorProto_ExtensionRange::default_instance_->InitAsDefaultInstance(); - DescriptorProto_ReservedRange::default_instance_->InitAsDefaultInstance(); - FieldDescriptorProto::default_instance_->InitAsDefaultInstance(); - OneofDescriptorProto::default_instance_->InitAsDefaultInstance(); - EnumDescriptorProto::default_instance_->InitAsDefaultInstance(); - EnumValueDescriptorProto::default_instance_->InitAsDefaultInstance(); - ServiceDescriptorProto::default_instance_->InitAsDefaultInstance(); - MethodDescriptorProto::default_instance_->InitAsDefaultInstance(); - FileOptions::default_instance_->InitAsDefaultInstance(); - MessageOptions::default_instance_->InitAsDefaultInstance(); - FieldOptions::default_instance_->InitAsDefaultInstance(); - OneofOptions::default_instance_->InitAsDefaultInstance(); - EnumOptions::default_instance_->InitAsDefaultInstance(); - EnumValueOptions::default_instance_->InitAsDefaultInstance(); - ServiceOptions::default_instance_->InitAsDefaultInstance(); - MethodOptions::default_instance_->InitAsDefaultInstance(); - UninterpretedOption::default_instance_->InitAsDefaultInstance(); - UninterpretedOption_NamePart::default_instance_->InitAsDefaultInstance(); - SourceCodeInfo::default_instance_->InitAsDefaultInstance(); - SourceCodeInfo_Location::default_instance_->InitAsDefaultInstance(); - GeneratedCodeInfo::default_instance_->InitAsDefaultInstance(); - GeneratedCodeInfo_Annotation::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto() { @@ -902,6 +875,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fdescriptor_2eproto_; +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; +static void MergeFromFail(int line) { + ::google::protobuf::internal::MergeFromFail(__FILE__, line); +} + +} // namespace + + // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -910,6 +893,7 @@ const int FileDescriptorSet::kFileFieldNumber; FileDescriptorSet::FileDescriptorSet() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorSet) } @@ -921,13 +905,12 @@ FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorSet) } void FileDescriptorSet::SharedCtor() { _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } FileDescriptorSet::~FileDescriptorSet() { @@ -936,8 +919,6 @@ FileDescriptorSet::~FileDescriptorSet() { } void FileDescriptorSet::SharedDtor() { - if (this != default_instance_) { - } } void FileDescriptorSet::SetCachedSize(int size) const { @@ -951,11 +932,11 @@ const ::google::protobuf::Descriptor* FileDescriptorSet::descriptor() { } const FileDescriptorSet& FileDescriptorSet::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -FileDescriptorSet* FileDescriptorSet::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed FileDescriptorSet::default_instance_; FileDescriptorSet* FileDescriptorSet::New(::google::protobuf::Arena* arena) const { FileDescriptorSet* n = new FileDescriptorSet; @@ -968,7 +949,7 @@ FileDescriptorSet* FileDescriptorSet::New(::google::protobuf::Arena* arena) cons void FileDescriptorSet::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorSet) file_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -1057,16 +1038,19 @@ void FileDescriptorSet::SerializeWithCachedSizes( return target; } -int FileDescriptorSet::ByteSize() const { +size_t FileDescriptorSet::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorSet) - int total_size = 0; + size_t total_size = 0; // repeated .google.protobuf.FileDescriptorProto file = 1; - total_size += 1 * this->file_size(); - for (int i = 0; i < this->file_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->file(i)); + { + unsigned int count = this->file_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->file(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -1074,18 +1058,17 @@ int FileDescriptorSet::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void FileDescriptorSet::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorSet) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const FileDescriptorSet* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FileDescriptorSet* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -1093,18 +1076,25 @@ void FileDescriptorSet::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileDescriptorSet) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void FileDescriptorSet::MergeFrom(const FileDescriptorSet& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void FileDescriptorSet::UnsafeMergeFrom(const FileDescriptorSet& from) { + GOOGLE_DCHECK(&from != this); file_.MergeFrom(from.file_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -1119,7 +1109,7 @@ void FileDescriptorSet::CopyFrom(const FileDescriptorSet& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorSet) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FileDescriptorSet::IsInitialized() const { @@ -1201,32 +1191,33 @@ const int FileDescriptorProto::kSyntaxFieldNumber; FileDescriptorProto::FileDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorProto) } void FileDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::FileOptions*>(&::google::protobuf::FileOptions::default_instance()); - source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>(&::google::protobuf::SourceCodeInfo::default_instance()); + options_ = const_cast< ::google::protobuf::FileOptions*>( + ::google::protobuf::FileOptions::internal_default_instance()); + source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>( + ::google::protobuf::SourceCodeInfo::internal_default_instance()); } FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorProto) } void FileDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; source_code_info_ = NULL; - syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } FileDescriptorProto::~FileDescriptorProto() { @@ -1238,10 +1229,8 @@ void FileDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); syntax_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - delete source_code_info_; - } + delete options_; + delete source_code_info_; } void FileDescriptorProto::SetCachedSize(int size) const { @@ -1255,11 +1244,11 @@ const ::google::protobuf::Descriptor* FileDescriptorProto::descriptor() { } const FileDescriptorProto& FileDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -FileDescriptorProto* FileDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed FileDescriptorProto::default_instance_; FileDescriptorProto* FileDescriptorProto::New(::google::protobuf::Arena* arena) const { FileDescriptorProto* n = new FileDescriptorProto; @@ -1297,7 +1286,7 @@ void FileDescriptorProto::Clear() { enum_type_.Clear(); service_.Clear(); extension_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -1740,9 +1729,9 @@ void FileDescriptorProto::SerializeWithCachedSizes( return target; } -int FileDescriptorProto::ByteSize() const { +size_t FileDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 3u) { // optional string name = 1; @@ -1784,7 +1773,8 @@ int FileDescriptorProto::ByteSize() const { } // repeated string dependency = 3; - total_size += 1 * this->dependency_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->dependency_size()); for (int i = 0; i < this->dependency_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->dependency(i)); @@ -1792,54 +1782,72 @@ int FileDescriptorProto::ByteSize() const { // repeated int32 public_dependency = 10; { - int data_size = 0; - for (int i = 0; i < this->public_dependency_size(); i++) { + size_t data_size = 0; + unsigned int count = this->public_dependency_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int32Size(this->public_dependency(i)); } - total_size += 1 * this->public_dependency_size() + data_size; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->public_dependency_size()); + total_size += data_size; } // repeated int32 weak_dependency = 11; { - int data_size = 0; - for (int i = 0; i < this->weak_dependency_size(); i++) { + size_t data_size = 0; + unsigned int count = this->weak_dependency_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int32Size(this->weak_dependency(i)); } - total_size += 1 * this->weak_dependency_size() + data_size; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->weak_dependency_size()); + total_size += data_size; } // repeated .google.protobuf.DescriptorProto message_type = 4; - total_size += 1 * this->message_type_size(); - for (int i = 0; i < this->message_type_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->message_type(i)); + { + unsigned int count = this->message_type_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->message_type(i)); + } } // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - total_size += 1 * this->enum_type_size(); - for (int i = 0; i < this->enum_type_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->enum_type(i)); + { + unsigned int count = this->enum_type_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->enum_type(i)); + } } // repeated .google.protobuf.ServiceDescriptorProto service = 6; - total_size += 1 * this->service_size(); - for (int i = 0; i < this->service_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->service(i)); + { + unsigned int count = this->service_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->service(i)); + } } // repeated .google.protobuf.FieldDescriptorProto extension = 7; - total_size += 1 * this->extension_size(); - for (int i = 0; i < this->extension_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->extension(i)); + { + unsigned int count = this->extension_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->extension(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -1847,18 +1855,17 @@ int FileDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void FileDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const FileDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FileDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -1866,18 +1873,24 @@ void FileDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } - dependency_.MergeFrom(from.dependency_); - public_dependency_.MergeFrom(from.public_dependency_); - weak_dependency_.MergeFrom(from.weak_dependency_); +} + +void FileDescriptorProto::UnsafeMergeFrom(const FileDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); + dependency_.UnsafeMergeFrom(from.dependency_); + public_dependency_.UnsafeMergeFrom(from.public_dependency_); + weak_dependency_.UnsafeMergeFrom(from.weak_dependency_); message_type_.MergeFrom(from.message_type_); enum_type_.MergeFrom(from.enum_type_); service_.MergeFrom(from.service_); @@ -1905,7 +1918,8 @@ void FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -1920,7 +1934,7 @@ void FileDescriptorProto::CopyFrom(const FileDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FileDescriptorProto::IsInitialized() const { @@ -1982,37 +1996,37 @@ void FileDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& FileDescriptorProto::name() const { +const ::std::string& FileDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileDescriptorProto::set_name(const ::std::string& value) { +void FileDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name) } - void FileDescriptorProto::set_name(const char* value) { +void FileDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.name) } - void FileDescriptorProto::set_name(const char* value, size_t size) { +void FileDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.name) } - ::std::string* FileDescriptorProto::mutable_name() { +::std::string* FileDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileDescriptorProto::release_name() { +::std::string* FileDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileDescriptorProto::set_allocated_name(::std::string* name) { +void FileDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -2036,37 +2050,37 @@ void FileDescriptorProto::clear_package() { package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_package(); } - const ::std::string& FileDescriptorProto::package() const { +const ::std::string& FileDescriptorProto::package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package) return package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileDescriptorProto::set_package(const ::std::string& value) { +void FileDescriptorProto::set_package(const ::std::string& value) { set_has_package(); package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package) } - void FileDescriptorProto::set_package(const char* value) { +void FileDescriptorProto::set_package(const char* value) { set_has_package(); package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.package) } - void FileDescriptorProto::set_package(const char* value, size_t size) { +void FileDescriptorProto::set_package(const char* value, size_t size) { set_has_package(); package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.package) } - ::std::string* FileDescriptorProto::mutable_package() { +::std::string* FileDescriptorProto::mutable_package() { set_has_package(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.package) return package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileDescriptorProto::release_package() { +::std::string* FileDescriptorProto::release_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.package) clear_has_package(); return package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileDescriptorProto::set_allocated_package(::std::string* package) { +void FileDescriptorProto::set_allocated_package(::std::string* package) { if (package != NULL) { set_has_package(); } else { @@ -2083,49 +2097,49 @@ int FileDescriptorProto::dependency_size() const { void FileDescriptorProto::clear_dependency() { dependency_.Clear(); } - const ::std::string& FileDescriptorProto::dependency(int index) const { +const ::std::string& FileDescriptorProto::dependency(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.dependency) return dependency_.Get(index); } - ::std::string* FileDescriptorProto::mutable_dependency(int index) { +::std::string* FileDescriptorProto::mutable_dependency(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.dependency) return dependency_.Mutable(index); } - void FileDescriptorProto::set_dependency(int index, const ::std::string& value) { +void FileDescriptorProto::set_dependency(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) dependency_.Mutable(index)->assign(value); } - void FileDescriptorProto::set_dependency(int index, const char* value) { +void FileDescriptorProto::set_dependency(int index, const char* value) { dependency_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency) } - void FileDescriptorProto::set_dependency(int index, const char* value, size_t size) { +void FileDescriptorProto::set_dependency(int index, const char* value, size_t size) { dependency_.Mutable(index)->assign( reinterpret_cast(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.dependency) } - ::std::string* FileDescriptorProto::add_dependency() { +::std::string* FileDescriptorProto::add_dependency() { // @@protoc_insertion_point(field_add_mutable:google.protobuf.FileDescriptorProto.dependency) return dependency_.Add(); } - void FileDescriptorProto::add_dependency(const ::std::string& value) { +void FileDescriptorProto::add_dependency(const ::std::string& value) { dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) } - void FileDescriptorProto::add_dependency(const char* value) { +void FileDescriptorProto::add_dependency(const char* value) { dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency) } - void FileDescriptorProto::add_dependency(const char* value, size_t size) { +void FileDescriptorProto::add_dependency(const char* value, size_t size) { dependency_.Add()->assign(reinterpret_cast(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.FileDescriptorProto.dependency) } - const ::google::protobuf::RepeatedPtrField< ::std::string>& +const ::google::protobuf::RepeatedPtrField< ::std::string>& FileDescriptorProto::dependency() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.dependency) return dependency_; } - ::google::protobuf::RepeatedPtrField< ::std::string>* +::google::protobuf::RepeatedPtrField< ::std::string>* FileDescriptorProto::mutable_dependency() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.dependency) return &dependency_; @@ -2138,24 +2152,24 @@ int FileDescriptorProto::public_dependency_size() const { void FileDescriptorProto::clear_public_dependency() { public_dependency_.Clear(); } - ::google::protobuf::int32 FileDescriptorProto::public_dependency(int index) const { +::google::protobuf::int32 FileDescriptorProto::public_dependency(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.public_dependency) return public_dependency_.Get(index); } - void FileDescriptorProto::set_public_dependency(int index, ::google::protobuf::int32 value) { +void FileDescriptorProto::set_public_dependency(int index, ::google::protobuf::int32 value) { public_dependency_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.public_dependency) } - void FileDescriptorProto::add_public_dependency(::google::protobuf::int32 value) { +void FileDescriptorProto::add_public_dependency(::google::protobuf::int32 value) { public_dependency_.Add(value); // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.public_dependency) } - const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& FileDescriptorProto::public_dependency() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.public_dependency) return public_dependency_; } - ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* FileDescriptorProto::mutable_public_dependency() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.public_dependency) return &public_dependency_; @@ -2168,24 +2182,24 @@ int FileDescriptorProto::weak_dependency_size() const { void FileDescriptorProto::clear_weak_dependency() { weak_dependency_.Clear(); } - ::google::protobuf::int32 FileDescriptorProto::weak_dependency(int index) const { +::google::protobuf::int32 FileDescriptorProto::weak_dependency(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.weak_dependency) return weak_dependency_.Get(index); } - void FileDescriptorProto::set_weak_dependency(int index, ::google::protobuf::int32 value) { +void FileDescriptorProto::set_weak_dependency(int index, ::google::protobuf::int32 value) { weak_dependency_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.weak_dependency) } - void FileDescriptorProto::add_weak_dependency(::google::protobuf::int32 value) { +void FileDescriptorProto::add_weak_dependency(::google::protobuf::int32 value) { weak_dependency_.Add(value); // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.weak_dependency) } - const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& FileDescriptorProto::weak_dependency() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.weak_dependency) return weak_dependency_; } - ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* FileDescriptorProto::mutable_weak_dependency() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.weak_dependency) return &weak_dependency_; @@ -2327,7 +2341,8 @@ void FileDescriptorProto::clear_options() { } const ::google::protobuf::FileOptions& FileDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::FileOptions::internal_default_instance(); } ::google::protobuf::FileOptions* FileDescriptorProto::mutable_options() { set_has_options(); @@ -2371,7 +2386,8 @@ void FileDescriptorProto::clear_source_code_info() { } const ::google::protobuf::SourceCodeInfo& FileDescriptorProto::source_code_info() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.source_code_info) - return source_code_info_ != NULL ? *source_code_info_ : *default_instance_->source_code_info_; + return source_code_info_ != NULL ? *source_code_info_ + : *::google::protobuf::SourceCodeInfo::internal_default_instance(); } ::google::protobuf::SourceCodeInfo* FileDescriptorProto::mutable_source_code_info() { set_has_source_code_info(); @@ -2413,37 +2429,37 @@ void FileDescriptorProto::clear_syntax() { syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_syntax(); } - const ::std::string& FileDescriptorProto::syntax() const { +const ::std::string& FileDescriptorProto::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax) return syntax_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileDescriptorProto::set_syntax(const ::std::string& value) { +void FileDescriptorProto::set_syntax(const ::std::string& value) { set_has_syntax(); syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax) } - void FileDescriptorProto::set_syntax(const char* value) { +void FileDescriptorProto::set_syntax(const char* value) { set_has_syntax(); syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.syntax) } - void FileDescriptorProto::set_syntax(const char* value, size_t size) { +void FileDescriptorProto::set_syntax(const char* value, size_t size) { set_has_syntax(); syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.syntax) } - ::std::string* FileDescriptorProto::mutable_syntax() { +::std::string* FileDescriptorProto::mutable_syntax() { set_has_syntax(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.syntax) return syntax_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileDescriptorProto::release_syntax() { +::std::string* FileDescriptorProto::release_syntax() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.syntax) clear_has_syntax(); return syntax_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) { +void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) { if (syntax != NULL) { set_has_syntax(); } else { @@ -2464,6 +2480,7 @@ const int DescriptorProto_ExtensionRange::kEndFieldNumber; DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ExtensionRange) } @@ -2475,15 +2492,14 @@ DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorP : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ExtensionRange) } void DescriptorProto_ExtensionRange::SharedCtor() { _cached_size_ = 0; - start_ = 0; - end_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&start_, 0, reinterpret_cast(&end_) - + reinterpret_cast(&start_) + sizeof(end_)); } DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() { @@ -2492,8 +2508,6 @@ DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() { } void DescriptorProto_ExtensionRange::SharedDtor() { - if (this != default_instance_) { - } } void DescriptorProto_ExtensionRange::SetCachedSize(int size) const { @@ -2507,11 +2521,11 @@ const ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange::descriptor } const DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed DescriptorProto_ExtensionRange::default_instance_; DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::New(::google::protobuf::Arena* arena) const { DescriptorProto_ExtensionRange* n = new DescriptorProto_ExtensionRange; @@ -2544,7 +2558,7 @@ void DescriptorProto_ExtensionRange::Clear() { #undef ZR_HELPER_ #undef ZR_ - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -2563,10 +2577,10 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( // optional int32 start = 1; case 1: { if (tag == 8) { + set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &start_))); - set_has_start(); } else { goto handle_unusual; } @@ -2578,10 +2592,10 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_end: + set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &end_))); - set_has_end(); } else { goto handle_unusual; } @@ -2653,9 +2667,9 @@ void DescriptorProto_ExtensionRange::SerializeWithCachedSizes( return target; } -int DescriptorProto_ExtensionRange::ByteSize() const { +size_t DescriptorProto_ExtensionRange::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ExtensionRange) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 3u) { // optional int32 start = 1; @@ -2678,18 +2692,17 @@ int DescriptorProto_ExtensionRange::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void DescriptorProto_ExtensionRange::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const DescriptorProto_ExtensionRange* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const DescriptorProto_ExtensionRange* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -2697,15 +2710,21 @@ void DescriptorProto_ExtensionRange::MergeFrom(const ::google::protobuf::Message ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto.ExtensionRange) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void DescriptorProto_ExtensionRange::MergeFrom(const DescriptorProto_ExtensionRange& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void DescriptorProto_ExtensionRange::UnsafeMergeFrom(const DescriptorProto_ExtensionRange& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_start()) { set_start(from.start()); @@ -2715,7 +2734,8 @@ void DescriptorProto_ExtensionRange::MergeFrom(const DescriptorProto_ExtensionRa } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -2730,7 +2750,7 @@ void DescriptorProto_ExtensionRange::CopyFrom(const DescriptorProto_ExtensionRan // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ExtensionRange) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool DescriptorProto_ExtensionRange::IsInitialized() const { @@ -2768,6 +2788,7 @@ const int DescriptorProto_ReservedRange::kEndFieldNumber; DescriptorProto_ReservedRange::DescriptorProto_ReservedRange() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ReservedRange) } @@ -2779,15 +2800,14 @@ DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorPro : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ReservedRange) } void DescriptorProto_ReservedRange::SharedCtor() { _cached_size_ = 0; - start_ = 0; - end_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&start_, 0, reinterpret_cast(&end_) - + reinterpret_cast(&start_) + sizeof(end_)); } DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() { @@ -2796,8 +2816,6 @@ DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() { } void DescriptorProto_ReservedRange::SharedDtor() { - if (this != default_instance_) { - } } void DescriptorProto_ReservedRange::SetCachedSize(int size) const { @@ -2811,11 +2829,11 @@ const ::google::protobuf::Descriptor* DescriptorProto_ReservedRange::descriptor( } const DescriptorProto_ReservedRange& DescriptorProto_ReservedRange::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed DescriptorProto_ReservedRange::default_instance_; DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::New(::google::protobuf::Arena* arena) const { DescriptorProto_ReservedRange* n = new DescriptorProto_ReservedRange; @@ -2848,7 +2866,7 @@ void DescriptorProto_ReservedRange::Clear() { #undef ZR_HELPER_ #undef ZR_ - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -2867,10 +2885,10 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( // optional int32 start = 1; case 1: { if (tag == 8) { + set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &start_))); - set_has_start(); } else { goto handle_unusual; } @@ -2882,10 +2900,10 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_end: + set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &end_))); - set_has_end(); } else { goto handle_unusual; } @@ -2957,9 +2975,9 @@ void DescriptorProto_ReservedRange::SerializeWithCachedSizes( return target; } -int DescriptorProto_ReservedRange::ByteSize() const { +size_t DescriptorProto_ReservedRange::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ReservedRange) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 3u) { // optional int32 start = 1; @@ -2982,18 +3000,17 @@ int DescriptorProto_ReservedRange::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void DescriptorProto_ReservedRange::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto.ReservedRange) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const DescriptorProto_ReservedRange* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const DescriptorProto_ReservedRange* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -3001,15 +3018,21 @@ void DescriptorProto_ReservedRange::MergeFrom(const ::google::protobuf::Message& ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto.ReservedRange) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void DescriptorProto_ReservedRange::MergeFrom(const DescriptorProto_ReservedRange& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void DescriptorProto_ReservedRange::UnsafeMergeFrom(const DescriptorProto_ReservedRange& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_start()) { set_start(from.start()); @@ -3019,7 +3042,8 @@ void DescriptorProto_ReservedRange::MergeFrom(const DescriptorProto_ReservedRang } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -3034,7 +3058,7 @@ void DescriptorProto_ReservedRange::CopyFrom(const DescriptorProto_ReservedRange // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ReservedRange) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool DescriptorProto_ReservedRange::IsInitialized() const { @@ -3080,28 +3104,28 @@ const int DescriptorProto::kReservedNameFieldNumber; DescriptorProto::DescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto) } void DescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::MessageOptions*>(&::google::protobuf::MessageOptions::default_instance()); + options_ = const_cast< ::google::protobuf::MessageOptions*>( + ::google::protobuf::MessageOptions::internal_default_instance()); } DescriptorProto::DescriptorProto(const DescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto) } void DescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } DescriptorProto::~DescriptorProto() { @@ -3111,9 +3135,7 @@ DescriptorProto::~DescriptorProto() { void DescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void DescriptorProto::SetCachedSize(int size) const { @@ -3127,11 +3149,11 @@ const ::google::protobuf::Descriptor* DescriptorProto::descriptor() { } const DescriptorProto& DescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -DescriptorProto* DescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed DescriptorProto::default_instance_; DescriptorProto* DescriptorProto::New(::google::protobuf::Arena* arena) const { DescriptorProto* n = new DescriptorProto; @@ -3159,7 +3181,7 @@ void DescriptorProto::Clear() { oneof_decl_.Clear(); reserved_range_.Clear(); reserved_name_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -3526,9 +3548,9 @@ void DescriptorProto::SerializeWithCachedSizes( return target; } -int DescriptorProto::ByteSize() const { +size_t DescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 129u) { // optional string name = 1; @@ -3547,63 +3569,85 @@ int DescriptorProto::ByteSize() const { } // repeated .google.protobuf.FieldDescriptorProto field = 2; - total_size += 1 * this->field_size(); - for (int i = 0; i < this->field_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->field(i)); + { + unsigned int count = this->field_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->field(i)); + } } // repeated .google.protobuf.FieldDescriptorProto extension = 6; - total_size += 1 * this->extension_size(); - for (int i = 0; i < this->extension_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->extension(i)); + { + unsigned int count = this->extension_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->extension(i)); + } } // repeated .google.protobuf.DescriptorProto nested_type = 3; - total_size += 1 * this->nested_type_size(); - for (int i = 0; i < this->nested_type_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->nested_type(i)); + { + unsigned int count = this->nested_type_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->nested_type(i)); + } } // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - total_size += 1 * this->enum_type_size(); - for (int i = 0; i < this->enum_type_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->enum_type(i)); + { + unsigned int count = this->enum_type_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->enum_type(i)); + } } // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - total_size += 1 * this->extension_range_size(); - for (int i = 0; i < this->extension_range_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->extension_range(i)); + { + unsigned int count = this->extension_range_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->extension_range(i)); + } } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; - total_size += 1 * this->oneof_decl_size(); - for (int i = 0; i < this->oneof_decl_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->oneof_decl(i)); + { + unsigned int count = this->oneof_decl_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->oneof_decl(i)); + } } // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; - total_size += 1 * this->reserved_range_size(); - for (int i = 0; i < this->reserved_range_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->reserved_range(i)); + { + unsigned int count = this->reserved_range_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->reserved_range(i)); + } } // repeated string reserved_name = 10; - total_size += 1 * this->reserved_name_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->reserved_name_size()); for (int i = 0; i < this->reserved_name_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->reserved_name(i)); @@ -3614,18 +3658,17 @@ int DescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void DescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const DescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const DescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -3633,15 +3676,21 @@ void DescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void DescriptorProto::MergeFrom(const DescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void DescriptorProto::UnsafeMergeFrom(const DescriptorProto& from) { + GOOGLE_DCHECK(&from != this); field_.MergeFrom(from.field_); extension_.MergeFrom(from.extension_); nested_type_.MergeFrom(from.nested_type_); @@ -3649,7 +3698,7 @@ void DescriptorProto::MergeFrom(const DescriptorProto& from) { extension_range_.MergeFrom(from.extension_range_); oneof_decl_.MergeFrom(from.oneof_decl_); reserved_range_.MergeFrom(from.reserved_range_); - reserved_name_.MergeFrom(from.reserved_name_); + reserved_name_.UnsafeMergeFrom(from.reserved_name_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { set_has_name(); @@ -3660,7 +3709,8 @@ void DescriptorProto::MergeFrom(const DescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -3675,7 +3725,7 @@ void DescriptorProto::CopyFrom(const DescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool DescriptorProto::IsInitialized() const { @@ -3736,11 +3786,11 @@ void DescriptorProto_ExtensionRange::clear_start() { start_ = 0; clear_has_start(); } - ::google::protobuf::int32 DescriptorProto_ExtensionRange::start() const { +::google::protobuf::int32 DescriptorProto_ExtensionRange::start() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.start) return start_; } - void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 value) { +void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 value) { set_has_start(); start_ = value; // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.start) @@ -3760,11 +3810,11 @@ void DescriptorProto_ExtensionRange::clear_end() { end_ = 0; clear_has_end(); } - ::google::protobuf::int32 DescriptorProto_ExtensionRange::end() const { +::google::protobuf::int32 DescriptorProto_ExtensionRange::end() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.end) return end_; } - void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 value) { +void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 value) { set_has_end(); end_ = value; // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end) @@ -3788,11 +3838,11 @@ void DescriptorProto_ReservedRange::clear_start() { start_ = 0; clear_has_start(); } - ::google::protobuf::int32 DescriptorProto_ReservedRange::start() const { +::google::protobuf::int32 DescriptorProto_ReservedRange::start() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.start) return start_; } - void DescriptorProto_ReservedRange::set_start(::google::protobuf::int32 value) { +void DescriptorProto_ReservedRange::set_start(::google::protobuf::int32 value) { set_has_start(); start_ = value; // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.start) @@ -3812,11 +3862,11 @@ void DescriptorProto_ReservedRange::clear_end() { end_ = 0; clear_has_end(); } - ::google::protobuf::int32 DescriptorProto_ReservedRange::end() const { +::google::protobuf::int32 DescriptorProto_ReservedRange::end() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.end) return end_; } - void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 value) { +void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 value) { set_has_end(); end_ = value; // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end) @@ -3840,37 +3890,37 @@ void DescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& DescriptorProto::name() const { +const ::std::string& DescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void DescriptorProto::set_name(const ::std::string& value) { +void DescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name) } - void DescriptorProto::set_name(const char* value) { +void DescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.name) } - void DescriptorProto::set_name(const char* value, size_t size) { +void DescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.name) } - ::std::string* DescriptorProto::mutable_name() { +::std::string* DescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* DescriptorProto::release_name() { +::std::string* DescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void DescriptorProto::set_allocated_name(::std::string* name) { +void DescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -4076,7 +4126,8 @@ void DescriptorProto::clear_options() { } const ::google::protobuf::MessageOptions& DescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::MessageOptions::internal_default_instance(); } ::google::protobuf::MessageOptions* DescriptorProto::mutable_options() { set_has_options(); @@ -4141,49 +4192,49 @@ int DescriptorProto::reserved_name_size() const { void DescriptorProto::clear_reserved_name() { reserved_name_.Clear(); } - const ::std::string& DescriptorProto::reserved_name(int index) const { +const ::std::string& DescriptorProto::reserved_name(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_name) return reserved_name_.Get(index); } - ::std::string* DescriptorProto::mutable_reserved_name(int index) { +::std::string* DescriptorProto::mutable_reserved_name(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.reserved_name) return reserved_name_.Mutable(index); } - void DescriptorProto::set_reserved_name(int index, const ::std::string& value) { +void DescriptorProto::set_reserved_name(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) reserved_name_.Mutable(index)->assign(value); } - void DescriptorProto::set_reserved_name(int index, const char* value) { +void DescriptorProto::set_reserved_name(int index, const char* value) { reserved_name_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name) } - void DescriptorProto::set_reserved_name(int index, const char* value, size_t size) { +void DescriptorProto::set_reserved_name(int index, const char* value, size_t size) { reserved_name_.Mutable(index)->assign( reinterpret_cast(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.reserved_name) } - ::std::string* DescriptorProto::add_reserved_name() { +::std::string* DescriptorProto::add_reserved_name() { // @@protoc_insertion_point(field_add_mutable:google.protobuf.DescriptorProto.reserved_name) return reserved_name_.Add(); } - void DescriptorProto::add_reserved_name(const ::std::string& value) { +void DescriptorProto::add_reserved_name(const ::std::string& value) { reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) } - void DescriptorProto::add_reserved_name(const char* value) { +void DescriptorProto::add_reserved_name(const char* value) { reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name) } - void DescriptorProto::add_reserved_name(const char* value, size_t size) { +void DescriptorProto::add_reserved_name(const char* value, size_t size) { reserved_name_.Add()->assign(reinterpret_cast(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.DescriptorProto.reserved_name) } - const ::google::protobuf::RepeatedPtrField< ::std::string>& +const ::google::protobuf::RepeatedPtrField< ::std::string>& DescriptorProto::reserved_name() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_name) return reserved_name_; } - ::google::protobuf::RepeatedPtrField< ::std::string>* +::google::protobuf::RepeatedPtrField< ::std::string>* DescriptorProto::mutable_reserved_name() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_name) return &reserved_name_; @@ -4198,7 +4249,7 @@ const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor() return FieldDescriptorProto_Type_descriptor_; } bool FieldDescriptorProto_Type_IsValid(int value) { - switch(value) { + switch (value) { case 1: case 2: case 3: @@ -4251,7 +4302,7 @@ const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor( return FieldDescriptorProto_Label_descriptor_; } bool FieldDescriptorProto_Label_IsValid(int value) { - switch(value) { + switch (value) { case 1: case 2: case 3: @@ -4284,36 +4335,36 @@ const int FieldDescriptorProto::kOptionsFieldNumber; FieldDescriptorProto::FieldDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldDescriptorProto) } void FieldDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::FieldOptions*>(&::google::protobuf::FieldOptions::default_instance()); + options_ = const_cast< ::google::protobuf::FieldOptions*>( + ::google::protobuf::FieldOptions::internal_default_instance()); } FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldDescriptorProto) } void FieldDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - number_ = 0; - label_ = 1; - type_ = 1; type_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); extendee_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - oneof_index_ = 0; json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&number_, 0, reinterpret_cast(&oneof_index_) - + reinterpret_cast(&number_) + sizeof(oneof_index_)); + label_ = 1; + type_ = 1; } FieldDescriptorProto::~FieldDescriptorProto() { @@ -4327,9 +4378,7 @@ void FieldDescriptorProto::SharedDtor() { extendee_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); default_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); json_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void FieldDescriptorProto::SetCachedSize(int size) const { @@ -4343,11 +4392,11 @@ const ::google::protobuf::Descriptor* FieldDescriptorProto::descriptor() { } const FieldDescriptorProto& FieldDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -FieldDescriptorProto* FieldDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed FieldDescriptorProto::default_instance_; FieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena) const { FieldDescriptorProto* n = new FieldDescriptorProto; @@ -4359,11 +4408,27 @@ FieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena void FieldDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldDescriptorProto) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(FieldDescriptorProto, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + if (_has_bits_[0 / 32] & 255u) { + ZR_(number_, oneof_index_); if (has_name()) { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - number_ = 0; label_ = 1; type_ = 1; if (has_type_name()) { @@ -4375,7 +4440,6 @@ void FieldDescriptorProto::Clear() { if (has_default_value()) { default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - oneof_index_ = 0; } if (_has_bits_[8 / 32] & 768u) { if (has_json_name()) { @@ -4385,7 +4449,11 @@ void FieldDescriptorProto::Clear() { if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear(); } } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -4438,10 +4506,10 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_number: + set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &number_))); - set_has_number(); } else { goto handle_unusual; } @@ -4540,10 +4608,10 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( case 9: { if (tag == 72) { parse_oneof_index: + set_has_oneof_index(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &oneof_index_))); - set_has_oneof_index(); } else { goto handle_unusual; } @@ -4774,9 +4842,9 @@ void FieldDescriptorProto::SerializeWithCachedSizes( return target; } -int FieldDescriptorProto::ByteSize() const { +size_t FieldDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 255u) { // optional string name = 1; @@ -4855,18 +4923,17 @@ int FieldDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void FieldDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const FieldDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FieldDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -4874,15 +4941,21 @@ void FieldDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void FieldDescriptorProto::UnsafeMergeFrom(const FieldDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { set_has_name(); @@ -4923,7 +4996,8 @@ void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -4938,7 +5012,7 @@ void FieldDescriptorProto::CopyFrom(const FieldDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FieldDescriptorProto::IsInitialized() const { @@ -4994,37 +5068,37 @@ void FieldDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& FieldDescriptorProto::name() const { +const ::std::string& FieldDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_name(const ::std::string& value) { +void FieldDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name) } - void FieldDescriptorProto::set_name(const char* value) { +void FieldDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.name) } - void FieldDescriptorProto::set_name(const char* value, size_t size) { +void FieldDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.name) } - ::std::string* FieldDescriptorProto::mutable_name() { +::std::string* FieldDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FieldDescriptorProto::release_name() { +::std::string* FieldDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_allocated_name(::std::string* name) { +void FieldDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -5048,11 +5122,11 @@ void FieldDescriptorProto::clear_number() { number_ = 0; clear_has_number(); } - ::google::protobuf::int32 FieldDescriptorProto::number() const { +::google::protobuf::int32 FieldDescriptorProto::number() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.number) return number_; } - void FieldDescriptorProto::set_number(::google::protobuf::int32 value) { +void FieldDescriptorProto::set_number(::google::protobuf::int32 value) { set_has_number(); number_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.number) @@ -5072,11 +5146,11 @@ void FieldDescriptorProto::clear_label() { label_ = 1; clear_has_label(); } - ::google::protobuf::FieldDescriptorProto_Label FieldDescriptorProto::label() const { +::google::protobuf::FieldDescriptorProto_Label FieldDescriptorProto::label() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.label) return static_cast< ::google::protobuf::FieldDescriptorProto_Label >(label_); } - void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorProto_Label value) { +void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorProto_Label value) { assert(::google::protobuf::FieldDescriptorProto_Label_IsValid(value)); set_has_label(); label_ = value; @@ -5097,11 +5171,11 @@ void FieldDescriptorProto::clear_type() { type_ = 1; clear_has_type(); } - ::google::protobuf::FieldDescriptorProto_Type FieldDescriptorProto::type() const { +::google::protobuf::FieldDescriptorProto_Type FieldDescriptorProto::type() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type) return static_cast< ::google::protobuf::FieldDescriptorProto_Type >(type_); } - void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorProto_Type value) { +void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorProto_Type value) { assert(::google::protobuf::FieldDescriptorProto_Type_IsValid(value)); set_has_type(); type_ = value; @@ -5122,37 +5196,37 @@ void FieldDescriptorProto::clear_type_name() { type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_type_name(); } - const ::std::string& FieldDescriptorProto::type_name() const { +const ::std::string& FieldDescriptorProto::type_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name) return type_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_type_name(const ::std::string& value) { +void FieldDescriptorProto::set_type_name(const ::std::string& value) { set_has_type_name(); type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name) } - void FieldDescriptorProto::set_type_name(const char* value) { +void FieldDescriptorProto::set_type_name(const char* value) { set_has_type_name(); type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.type_name) } - void FieldDescriptorProto::set_type_name(const char* value, size_t size) { +void FieldDescriptorProto::set_type_name(const char* value, size_t size) { set_has_type_name(); type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.type_name) } - ::std::string* FieldDescriptorProto::mutable_type_name() { +::std::string* FieldDescriptorProto::mutable_type_name() { set_has_type_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.type_name) return type_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FieldDescriptorProto::release_type_name() { +::std::string* FieldDescriptorProto::release_type_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.type_name) clear_has_type_name(); return type_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_allocated_type_name(::std::string* type_name) { +void FieldDescriptorProto::set_allocated_type_name(::std::string* type_name) { if (type_name != NULL) { set_has_type_name(); } else { @@ -5176,37 +5250,37 @@ void FieldDescriptorProto::clear_extendee() { extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_extendee(); } - const ::std::string& FieldDescriptorProto::extendee() const { +const ::std::string& FieldDescriptorProto::extendee() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee) return extendee_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_extendee(const ::std::string& value) { +void FieldDescriptorProto::set_extendee(const ::std::string& value) { set_has_extendee(); extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee) } - void FieldDescriptorProto::set_extendee(const char* value) { +void FieldDescriptorProto::set_extendee(const char* value) { set_has_extendee(); extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.extendee) } - void FieldDescriptorProto::set_extendee(const char* value, size_t size) { +void FieldDescriptorProto::set_extendee(const char* value, size_t size) { set_has_extendee(); extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.extendee) } - ::std::string* FieldDescriptorProto::mutable_extendee() { +::std::string* FieldDescriptorProto::mutable_extendee() { set_has_extendee(); // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.extendee) return extendee_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FieldDescriptorProto::release_extendee() { +::std::string* FieldDescriptorProto::release_extendee() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.extendee) clear_has_extendee(); return extendee_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee) { +void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee) { if (extendee != NULL) { set_has_extendee(); } else { @@ -5230,37 +5304,37 @@ void FieldDescriptorProto::clear_default_value() { default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_default_value(); } - const ::std::string& FieldDescriptorProto::default_value() const { +const ::std::string& FieldDescriptorProto::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value) return default_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_default_value(const ::std::string& value) { +void FieldDescriptorProto::set_default_value(const ::std::string& value) { set_has_default_value(); default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value) } - void FieldDescriptorProto::set_default_value(const char* value) { +void FieldDescriptorProto::set_default_value(const char* value) { set_has_default_value(); default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.default_value) } - void FieldDescriptorProto::set_default_value(const char* value, size_t size) { +void FieldDescriptorProto::set_default_value(const char* value, size_t size) { set_has_default_value(); default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.default_value) } - ::std::string* FieldDescriptorProto::mutable_default_value() { +::std::string* FieldDescriptorProto::mutable_default_value() { set_has_default_value(); // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.default_value) return default_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FieldDescriptorProto::release_default_value() { +::std::string* FieldDescriptorProto::release_default_value() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.default_value) clear_has_default_value(); return default_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_allocated_default_value(::std::string* default_value) { +void FieldDescriptorProto::set_allocated_default_value(::std::string* default_value) { if (default_value != NULL) { set_has_default_value(); } else { @@ -5284,11 +5358,11 @@ void FieldDescriptorProto::clear_oneof_index() { oneof_index_ = 0; clear_has_oneof_index(); } - ::google::protobuf::int32 FieldDescriptorProto::oneof_index() const { +::google::protobuf::int32 FieldDescriptorProto::oneof_index() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.oneof_index) return oneof_index_; } - void FieldDescriptorProto::set_oneof_index(::google::protobuf::int32 value) { +void FieldDescriptorProto::set_oneof_index(::google::protobuf::int32 value) { set_has_oneof_index(); oneof_index_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.oneof_index) @@ -5308,37 +5382,37 @@ void FieldDescriptorProto::clear_json_name() { json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_json_name(); } - const ::std::string& FieldDescriptorProto::json_name() const { +const ::std::string& FieldDescriptorProto::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name) return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_json_name(const ::std::string& value) { +void FieldDescriptorProto::set_json_name(const ::std::string& value) { set_has_json_name(); json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name) } - void FieldDescriptorProto::set_json_name(const char* value) { +void FieldDescriptorProto::set_json_name(const char* value) { set_has_json_name(); json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.json_name) } - void FieldDescriptorProto::set_json_name(const char* value, size_t size) { +void FieldDescriptorProto::set_json_name(const char* value, size_t size) { set_has_json_name(); json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.json_name) } - ::std::string* FieldDescriptorProto::mutable_json_name() { +::std::string* FieldDescriptorProto::mutable_json_name() { set_has_json_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.json_name) return json_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FieldDescriptorProto::release_json_name() { +::std::string* FieldDescriptorProto::release_json_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.json_name) clear_has_json_name(); return json_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FieldDescriptorProto::set_allocated_json_name(::std::string* json_name) { +void FieldDescriptorProto::set_allocated_json_name(::std::string* json_name) { if (json_name != NULL) { set_has_json_name(); } else { @@ -5364,7 +5438,8 @@ void FieldDescriptorProto::clear_options() { } const ::google::protobuf::FieldOptions& FieldDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::FieldOptions::internal_default_instance(); } ::google::protobuf::FieldOptions* FieldDescriptorProto::mutable_options() { set_has_options(); @@ -5403,28 +5478,28 @@ const int OneofDescriptorProto::kOptionsFieldNumber; OneofDescriptorProto::OneofDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.OneofDescriptorProto) } void OneofDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::OneofOptions*>(&::google::protobuf::OneofOptions::default_instance()); + options_ = const_cast< ::google::protobuf::OneofOptions*>( + ::google::protobuf::OneofOptions::internal_default_instance()); } OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.OneofDescriptorProto) } void OneofDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } OneofDescriptorProto::~OneofDescriptorProto() { @@ -5434,9 +5509,7 @@ OneofDescriptorProto::~OneofDescriptorProto() { void OneofDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void OneofDescriptorProto::SetCachedSize(int size) const { @@ -5450,11 +5523,11 @@ const ::google::protobuf::Descriptor* OneofDescriptorProto::descriptor() { } const OneofDescriptorProto& OneofDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -OneofDescriptorProto* OneofDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed OneofDescriptorProto::default_instance_; OneofDescriptorProto* OneofDescriptorProto::New(::google::protobuf::Arena* arena) const { OneofDescriptorProto* n = new OneofDescriptorProto; @@ -5474,7 +5547,7 @@ void OneofDescriptorProto::Clear() { if (options_ != NULL) options_->::google::protobuf::OneofOptions::Clear(); } } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -5597,9 +5670,9 @@ void OneofDescriptorProto::SerializeWithCachedSizes( return target; } -int OneofDescriptorProto::ByteSize() const { +size_t OneofDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 3u) { // optional string name = 1; @@ -5622,18 +5695,17 @@ int OneofDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void OneofDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const OneofDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const OneofDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -5641,15 +5713,21 @@ void OneofDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.OneofDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void OneofDescriptorProto::MergeFrom(const OneofDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void OneofDescriptorProto::UnsafeMergeFrom(const OneofDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { set_has_name(); @@ -5660,7 +5738,8 @@ void OneofDescriptorProto::MergeFrom(const OneofDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -5675,7 +5754,7 @@ void OneofDescriptorProto::CopyFrom(const OneofDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool OneofDescriptorProto::IsInitialized() const { @@ -5723,37 +5802,37 @@ void OneofDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& OneofDescriptorProto::name() const { +const ::std::string& OneofDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void OneofDescriptorProto::set_name(const ::std::string& value) { +void OneofDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name) } - void OneofDescriptorProto::set_name(const char* value) { +void OneofDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.OneofDescriptorProto.name) } - void OneofDescriptorProto::set_name(const char* value, size_t size) { +void OneofDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.OneofDescriptorProto.name) } - ::std::string* OneofDescriptorProto::mutable_name() { +::std::string* OneofDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* OneofDescriptorProto::release_name() { +::std::string* OneofDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void OneofDescriptorProto::set_allocated_name(::std::string* name) { +void OneofDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -5779,7 +5858,8 @@ void OneofDescriptorProto::clear_options() { } const ::google::protobuf::OneofOptions& OneofDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::OneofOptions::internal_default_instance(); } ::google::protobuf::OneofOptions* OneofDescriptorProto::mutable_options() { set_has_options(); @@ -5819,28 +5899,28 @@ const int EnumDescriptorProto::kOptionsFieldNumber; EnumDescriptorProto::EnumDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumDescriptorProto) } void EnumDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::EnumOptions*>(&::google::protobuf::EnumOptions::default_instance()); + options_ = const_cast< ::google::protobuf::EnumOptions*>( + ::google::protobuf::EnumOptions::internal_default_instance()); } EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumDescriptorProto) } void EnumDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } EnumDescriptorProto::~EnumDescriptorProto() { @@ -5850,9 +5930,7 @@ EnumDescriptorProto::~EnumDescriptorProto() { void EnumDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void EnumDescriptorProto::SetCachedSize(int size) const { @@ -5866,11 +5944,11 @@ const ::google::protobuf::Descriptor* EnumDescriptorProto::descriptor() { } const EnumDescriptorProto& EnumDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -EnumDescriptorProto* EnumDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed EnumDescriptorProto::default_instance_; EnumDescriptorProto* EnumDescriptorProto::New(::google::protobuf::Arena* arena) const { EnumDescriptorProto* n = new EnumDescriptorProto; @@ -5891,7 +5969,7 @@ void EnumDescriptorProto::Clear() { } } value_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -6044,9 +6122,9 @@ void EnumDescriptorProto::SerializeWithCachedSizes( return target; } -int EnumDescriptorProto::ByteSize() const { +size_t EnumDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 5u) { // optional string name = 1; @@ -6065,11 +6143,14 @@ int EnumDescriptorProto::ByteSize() const { } // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - total_size += 1 * this->value_size(); - for (int i = 0; i < this->value_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->value(i)); + { + unsigned int count = this->value_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->value(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -6077,18 +6158,17 @@ int EnumDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void EnumDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const EnumDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const EnumDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -6096,15 +6176,21 @@ void EnumDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void EnumDescriptorProto::UnsafeMergeFrom(const EnumDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); value_.MergeFrom(from.value_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { @@ -6116,7 +6202,8 @@ void EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -6131,7 +6218,7 @@ void EnumDescriptorProto::CopyFrom(const EnumDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool EnumDescriptorProto::IsInitialized() const { @@ -6181,37 +6268,37 @@ void EnumDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& EnumDescriptorProto::name() const { +const ::std::string& EnumDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void EnumDescriptorProto::set_name(const ::std::string& value) { +void EnumDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name) } - void EnumDescriptorProto::set_name(const char* value) { +void EnumDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.EnumDescriptorProto.name) } - void EnumDescriptorProto::set_name(const char* value, size_t size) { +void EnumDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.name) } - ::std::string* EnumDescriptorProto::mutable_name() { +::std::string* EnumDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* EnumDescriptorProto::release_name() { +::std::string* EnumDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void EnumDescriptorProto::set_allocated_name(::std::string* name) { +void EnumDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -6267,7 +6354,8 @@ void EnumDescriptorProto::clear_options() { } const ::google::protobuf::EnumOptions& EnumDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::EnumOptions::internal_default_instance(); } ::google::protobuf::EnumOptions* EnumDescriptorProto::mutable_options() { set_has_options(); @@ -6307,29 +6395,29 @@ const int EnumValueDescriptorProto::kOptionsFieldNumber; EnumValueDescriptorProto::EnumValueDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValueDescriptorProto) } void EnumValueDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::EnumValueOptions*>(&::google::protobuf::EnumValueOptions::default_instance()); + options_ = const_cast< ::google::protobuf::EnumValueOptions*>( + ::google::protobuf::EnumValueOptions::internal_default_instance()); } EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueDescriptorProto) } void EnumValueDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - number_ = 0; options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + number_ = 0; } EnumValueDescriptorProto::~EnumValueDescriptorProto() { @@ -6339,9 +6427,7 @@ EnumValueDescriptorProto::~EnumValueDescriptorProto() { void EnumValueDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void EnumValueDescriptorProto::SetCachedSize(int size) const { @@ -6355,11 +6441,11 @@ const ::google::protobuf::Descriptor* EnumValueDescriptorProto::descriptor() { } const EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -EnumValueDescriptorProto* EnumValueDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed EnumValueDescriptorProto::default_instance_; EnumValueDescriptorProto* EnumValueDescriptorProto::New(::google::protobuf::Arena* arena) const { EnumValueDescriptorProto* n = new EnumValueDescriptorProto; @@ -6380,7 +6466,7 @@ void EnumValueDescriptorProto::Clear() { if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear(); } } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -6416,10 +6502,10 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_number: + set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &number_))); - set_has_number(); } else { goto handle_unusual; } @@ -6528,9 +6614,9 @@ void EnumValueDescriptorProto::SerializeWithCachedSizes( return target; } -int EnumValueDescriptorProto::ByteSize() const { +size_t EnumValueDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 7u) { // optional string name = 1; @@ -6560,18 +6646,17 @@ int EnumValueDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void EnumValueDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const EnumValueDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const EnumValueDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -6579,15 +6664,21 @@ void EnumValueDescriptorProto::MergeFrom(const ::google::protobuf::Message& from ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValueDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void EnumValueDescriptorProto::UnsafeMergeFrom(const EnumValueDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { set_has_name(); @@ -6601,7 +6692,8 @@ void EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -6616,7 +6708,7 @@ void EnumValueDescriptorProto::CopyFrom(const EnumValueDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool EnumValueDescriptorProto::IsInitialized() const { @@ -6665,37 +6757,37 @@ void EnumValueDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& EnumValueDescriptorProto::name() const { +const ::std::string& EnumValueDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void EnumValueDescriptorProto::set_name(const ::std::string& value) { +void EnumValueDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name) } - void EnumValueDescriptorProto::set_name(const char* value) { +void EnumValueDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValueDescriptorProto.name) } - void EnumValueDescriptorProto::set_name(const char* value, size_t size) { +void EnumValueDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValueDescriptorProto.name) } - ::std::string* EnumValueDescriptorProto::mutable_name() { +::std::string* EnumValueDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* EnumValueDescriptorProto::release_name() { +::std::string* EnumValueDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void EnumValueDescriptorProto::set_allocated_name(::std::string* name) { +void EnumValueDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -6719,11 +6811,11 @@ void EnumValueDescriptorProto::clear_number() { number_ = 0; clear_has_number(); } - ::google::protobuf::int32 EnumValueDescriptorProto::number() const { +::google::protobuf::int32 EnumValueDescriptorProto::number() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.number) return number_; } - void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value) { +void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value) { set_has_number(); number_ = value; // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.number) @@ -6745,7 +6837,8 @@ void EnumValueDescriptorProto::clear_options() { } const ::google::protobuf::EnumValueOptions& EnumValueDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::EnumValueOptions::internal_default_instance(); } ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::mutable_options() { set_has_options(); @@ -6785,28 +6878,28 @@ const int ServiceDescriptorProto::kOptionsFieldNumber; ServiceDescriptorProto::ServiceDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ServiceDescriptorProto) } void ServiceDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::ServiceOptions*>(&::google::protobuf::ServiceOptions::default_instance()); + options_ = const_cast< ::google::protobuf::ServiceOptions*>( + ::google::protobuf::ServiceOptions::internal_default_instance()); } ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceDescriptorProto) } void ServiceDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } ServiceDescriptorProto::~ServiceDescriptorProto() { @@ -6816,9 +6909,7 @@ ServiceDescriptorProto::~ServiceDescriptorProto() { void ServiceDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void ServiceDescriptorProto::SetCachedSize(int size) const { @@ -6832,11 +6923,11 @@ const ::google::protobuf::Descriptor* ServiceDescriptorProto::descriptor() { } const ServiceDescriptorProto& ServiceDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -ServiceDescriptorProto* ServiceDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ServiceDescriptorProto::default_instance_; ServiceDescriptorProto* ServiceDescriptorProto::New(::google::protobuf::Arena* arena) const { ServiceDescriptorProto* n = new ServiceDescriptorProto; @@ -6857,7 +6948,7 @@ void ServiceDescriptorProto::Clear() { } } method_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -7010,9 +7101,9 @@ void ServiceDescriptorProto::SerializeWithCachedSizes( return target; } -int ServiceDescriptorProto::ByteSize() const { +size_t ServiceDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 5u) { // optional string name = 1; @@ -7031,11 +7122,14 @@ int ServiceDescriptorProto::ByteSize() const { } // repeated .google.protobuf.MethodDescriptorProto method = 2; - total_size += 1 * this->method_size(); - for (int i = 0; i < this->method_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->method(i)); + { + unsigned int count = this->method_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->method(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -7043,18 +7137,17 @@ int ServiceDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void ServiceDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const ServiceDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ServiceDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -7062,15 +7155,21 @@ void ServiceDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ServiceDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void ServiceDescriptorProto::UnsafeMergeFrom(const ServiceDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); method_.MergeFrom(from.method_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { @@ -7082,7 +7181,8 @@ void ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -7097,7 +7197,7 @@ void ServiceDescriptorProto::CopyFrom(const ServiceDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ServiceDescriptorProto::IsInitialized() const { @@ -7147,37 +7247,37 @@ void ServiceDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& ServiceDescriptorProto::name() const { +const ::std::string& ServiceDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void ServiceDescriptorProto::set_name(const ::std::string& value) { +void ServiceDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name) } - void ServiceDescriptorProto::set_name(const char* value) { +void ServiceDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.ServiceDescriptorProto.name) } - void ServiceDescriptorProto::set_name(const char* value, size_t size) { +void ServiceDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.ServiceDescriptorProto.name) } - ::std::string* ServiceDescriptorProto::mutable_name() { +::std::string* ServiceDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* ServiceDescriptorProto::release_name() { +::std::string* ServiceDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void ServiceDescriptorProto::set_allocated_name(::std::string* name) { +void ServiceDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -7233,7 +7333,8 @@ void ServiceDescriptorProto::clear_options() { } const ::google::protobuf::ServiceOptions& ServiceDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::ServiceOptions::internal_default_instance(); } ::google::protobuf::ServiceOptions* ServiceDescriptorProto::mutable_options() { set_has_options(); @@ -7276,32 +7377,32 @@ const int MethodDescriptorProto::kServerStreamingFieldNumber; MethodDescriptorProto::MethodDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MethodDescriptorProto) } void MethodDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::MethodOptions*>(&::google::protobuf::MethodOptions::default_instance()); + options_ = const_cast< ::google::protobuf::MethodOptions*>( + ::google::protobuf::MethodOptions::internal_default_instance()); } MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodDescriptorProto) } void MethodDescriptorProto::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); input_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); output_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); options_ = NULL; - client_streaming_ = false; - server_streaming_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&client_streaming_, 0, reinterpret_cast(&server_streaming_) - + reinterpret_cast(&client_streaming_) + sizeof(server_streaming_)); } MethodDescriptorProto::~MethodDescriptorProto() { @@ -7313,9 +7414,7 @@ void MethodDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); input_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); output_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete options_; - } + delete options_; } void MethodDescriptorProto::SetCachedSize(int size) const { @@ -7329,11 +7428,11 @@ const ::google::protobuf::Descriptor* MethodDescriptorProto::descriptor() { } const MethodDescriptorProto& MethodDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -MethodDescriptorProto* MethodDescriptorProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed MethodDescriptorProto::default_instance_; MethodDescriptorProto* MethodDescriptorProto::New(::google::protobuf::Arena* arena) const { MethodDescriptorProto* n = new MethodDescriptorProto; @@ -7380,7 +7479,7 @@ void MethodDescriptorProto::Clear() { #undef ZR_HELPER_ #undef ZR_ - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -7463,10 +7562,10 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( case 5: { if (tag == 40) { parse_client_streaming: + set_has_client_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &client_streaming_))); - set_has_client_streaming(); } else { goto handle_unusual; } @@ -7478,10 +7577,10 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( case 6: { if (tag == 48) { parse_server_streaming: + set_has_server_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &server_streaming_))); - set_has_server_streaming(); } else { goto handle_unusual; } @@ -7629,9 +7728,9 @@ void MethodDescriptorProto::SerializeWithCachedSizes( return target; } -int MethodDescriptorProto::ByteSize() const { +size_t MethodDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodDescriptorProto) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 63u) { // optional string name = 1; @@ -7678,18 +7777,17 @@ int MethodDescriptorProto::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void MethodDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const MethodDescriptorProto* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const MethodDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -7697,15 +7795,21 @@ void MethodDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MethodDescriptorProto) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void MethodDescriptorProto::UnsafeMergeFrom(const MethodDescriptorProto& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { set_has_name(); @@ -7730,7 +7834,8 @@ void MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -7745,7 +7850,7 @@ void MethodDescriptorProto::CopyFrom(const MethodDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodDescriptorProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool MethodDescriptorProto::IsInitialized() const { @@ -7797,37 +7902,37 @@ void MethodDescriptorProto::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } - const ::std::string& MethodDescriptorProto::name() const { +const ::std::string& MethodDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name) return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void MethodDescriptorProto::set_name(const ::std::string& value) { +void MethodDescriptorProto::set_name(const ::std::string& value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name) } - void MethodDescriptorProto::set_name(const char* value) { +void MethodDescriptorProto::set_name(const char* value) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.name) } - void MethodDescriptorProto::set_name(const char* value, size_t size) { +void MethodDescriptorProto::set_name(const char* value, size_t size) { set_has_name(); name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.name) } - ::std::string* MethodDescriptorProto::mutable_name() { +::std::string* MethodDescriptorProto::mutable_name() { set_has_name(); // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.name) return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* MethodDescriptorProto::release_name() { +::std::string* MethodDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.name) clear_has_name(); return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void MethodDescriptorProto::set_allocated_name(::std::string* name) { +void MethodDescriptorProto::set_allocated_name(::std::string* name) { if (name != NULL) { set_has_name(); } else { @@ -7851,37 +7956,37 @@ void MethodDescriptorProto::clear_input_type() { input_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_input_type(); } - const ::std::string& MethodDescriptorProto::input_type() const { +const ::std::string& MethodDescriptorProto::input_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type) return input_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void MethodDescriptorProto::set_input_type(const ::std::string& value) { +void MethodDescriptorProto::set_input_type(const ::std::string& value) { set_has_input_type(); input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type) } - void MethodDescriptorProto::set_input_type(const char* value) { +void MethodDescriptorProto::set_input_type(const char* value) { set_has_input_type(); input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.input_type) } - void MethodDescriptorProto::set_input_type(const char* value, size_t size) { +void MethodDescriptorProto::set_input_type(const char* value, size_t size) { set_has_input_type(); input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.input_type) } - ::std::string* MethodDescriptorProto::mutable_input_type() { +::std::string* MethodDescriptorProto::mutable_input_type() { set_has_input_type(); // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.input_type) return input_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* MethodDescriptorProto::release_input_type() { +::std::string* MethodDescriptorProto::release_input_type() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.input_type) clear_has_input_type(); return input_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void MethodDescriptorProto::set_allocated_input_type(::std::string* input_type) { +void MethodDescriptorProto::set_allocated_input_type(::std::string* input_type) { if (input_type != NULL) { set_has_input_type(); } else { @@ -7905,37 +8010,37 @@ void MethodDescriptorProto::clear_output_type() { output_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_output_type(); } - const ::std::string& MethodDescriptorProto::output_type() const { +const ::std::string& MethodDescriptorProto::output_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type) return output_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void MethodDescriptorProto::set_output_type(const ::std::string& value) { +void MethodDescriptorProto::set_output_type(const ::std::string& value) { set_has_output_type(); output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type) } - void MethodDescriptorProto::set_output_type(const char* value) { +void MethodDescriptorProto::set_output_type(const char* value) { set_has_output_type(); output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.output_type) } - void MethodDescriptorProto::set_output_type(const char* value, size_t size) { +void MethodDescriptorProto::set_output_type(const char* value, size_t size) { set_has_output_type(); output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.output_type) } - ::std::string* MethodDescriptorProto::mutable_output_type() { +::std::string* MethodDescriptorProto::mutable_output_type() { set_has_output_type(); // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.output_type) return output_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* MethodDescriptorProto::release_output_type() { +::std::string* MethodDescriptorProto::release_output_type() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.output_type) clear_has_output_type(); return output_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void MethodDescriptorProto::set_allocated_output_type(::std::string* output_type) { +void MethodDescriptorProto::set_allocated_output_type(::std::string* output_type) { if (output_type != NULL) { set_has_output_type(); } else { @@ -7961,7 +8066,8 @@ void MethodDescriptorProto::clear_options() { } const ::google::protobuf::MethodOptions& MethodDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::MethodOptions::internal_default_instance(); } ::google::protobuf::MethodOptions* MethodDescriptorProto::mutable_options() { set_has_options(); @@ -8003,11 +8109,11 @@ void MethodDescriptorProto::clear_client_streaming() { client_streaming_ = false; clear_has_client_streaming(); } - bool MethodDescriptorProto::client_streaming() const { +bool MethodDescriptorProto::client_streaming() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.client_streaming) return client_streaming_; } - void MethodDescriptorProto::set_client_streaming(bool value) { +void MethodDescriptorProto::set_client_streaming(bool value) { set_has_client_streaming(); client_streaming_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.client_streaming) @@ -8027,11 +8133,11 @@ void MethodDescriptorProto::clear_server_streaming() { server_streaming_ = false; clear_has_server_streaming(); } - bool MethodDescriptorProto::server_streaming() const { +bool MethodDescriptorProto::server_streaming() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.server_streaming) return server_streaming_; } - void MethodDescriptorProto::set_server_streaming(bool value) { +void MethodDescriptorProto::set_server_streaming(bool value) { set_has_server_streaming(); server_streaming_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.server_streaming) @@ -8046,7 +8152,7 @@ const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor() return FileOptions_OptimizeMode_descriptor_; } bool FileOptions_OptimizeMode_IsValid(int value) { - switch(value) { + switch (value) { case 1: case 2: case 3: @@ -8068,7 +8174,6 @@ const int FileOptions::OptimizeMode_ARRAYSIZE; const int FileOptions::kJavaPackageFieldNumber; const int FileOptions::kJavaOuterClassnameFieldNumber; const int FileOptions::kJavaMultipleFilesFieldNumber; -const int FileOptions::kJavaGenerateEqualsAndHashFieldNumber; const int FileOptions::kJavaStringCheckUtf8FieldNumber; const int FileOptions::kOptimizeForFieldNumber; const int FileOptions::kGoPackageFieldNumber; @@ -8084,6 +8189,7 @@ const int FileOptions::kUninterpretedOptionFieldNumber; FileOptions::FileOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileOptions) } @@ -8095,28 +8201,20 @@ FileOptions::FileOptions(const FileOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileOptions) } void FileOptions::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; java_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); java_outer_classname_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - java_multiple_files_ = false; - java_generate_equals_and_hash_ = false; - java_string_check_utf8_ = false; - optimize_for_ = 1; go_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - cc_generic_services_ = false; - java_generic_services_ = false; - py_generic_services_ = false; - deprecated_ = false; - cc_enable_arenas_ = false; objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&java_multiple_files_, 0, reinterpret_cast(&cc_enable_arenas_) - + reinterpret_cast(&java_multiple_files_) + sizeof(cc_enable_arenas_)); + optimize_for_ = 1; } FileOptions::~FileOptions() { @@ -8130,8 +8228,6 @@ void FileOptions::SharedDtor() { go_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); objc_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void FileOptions::SetCachedSize(int size) const { @@ -8145,11 +8241,11 @@ const ::google::protobuf::Descriptor* FileOptions::descriptor() { } const FileOptions& FileOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -FileOptions* FileOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed FileOptions::default_instance_; FileOptions* FileOptions::New(::google::protobuf::Arena* arena) const { FileOptions* n = new FileOptions; @@ -8179,7 +8275,7 @@ void FileOptions::Clear() { } while (0) if (_has_bits_[0 / 32] & 255u) { - ZR_(java_multiple_files_, cc_generic_services_); + ZR_(java_multiple_files_, java_generic_services_); if (has_java_package()) { java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } @@ -8191,8 +8287,8 @@ void FileOptions::Clear() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } } - if (_has_bits_[8 / 32] & 16128u) { - ZR_(java_generic_services_, cc_enable_arenas_); + if (_has_bits_[8 / 32] & 7936u) { + ZR_(py_generic_services_, cc_enable_arenas_); if (has_objc_class_prefix()) { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } @@ -8205,7 +8301,7 @@ void FileOptions::Clear() { #undef ZR_ uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -8278,10 +8374,10 @@ bool FileOptions::MergePartialFromCodedStream( case 10: { if (tag == 80) { parse_java_multiple_files: + set_has_java_multiple_files(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &java_multiple_files_))); - set_has_java_multiple_files(); } else { goto handle_unusual; } @@ -8310,10 +8406,10 @@ bool FileOptions::MergePartialFromCodedStream( case 16: { if (tag == 128) { parse_cc_generic_services: + set_has_cc_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &cc_generic_services_))); - set_has_cc_generic_services(); } else { goto handle_unusual; } @@ -8325,10 +8421,10 @@ bool FileOptions::MergePartialFromCodedStream( case 17: { if (tag == 136) { parse_java_generic_services: + set_has_java_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &java_generic_services_))); - set_has_java_generic_services(); } else { goto handle_unusual; } @@ -8340,29 +8436,14 @@ bool FileOptions::MergePartialFromCodedStream( case 18: { if (tag == 144) { parse_py_generic_services: + set_has_py_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &py_generic_services_))); - set_has_py_generic_services(); } else { goto handle_unusual; } - if (input->ExpectTag(160)) goto parse_java_generate_equals_and_hash; - break; - } - - // optional bool java_generate_equals_and_hash = 20 [default = false]; - case 20: { - if (tag == 160) { - parse_java_generate_equals_and_hash: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &java_generate_equals_and_hash_))); - set_has_java_generate_equals_and_hash(); - } else { - goto handle_unusual; - } - if (input->ExpectTag(184)) goto parse_deprecated; + if (input->ExpectTag(184)) goto parse_deprecated; break; } @@ -8370,10 +8451,10 @@ bool FileOptions::MergePartialFromCodedStream( case 23: { if (tag == 184) { parse_deprecated: + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -8385,10 +8466,10 @@ bool FileOptions::MergePartialFromCodedStream( case 27: { if (tag == 216) { parse_java_string_check_utf8: + set_has_java_string_check_utf8(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &java_string_check_utf8_))); - set_has_java_string_check_utf8(); } else { goto handle_unusual; } @@ -8400,10 +8481,10 @@ bool FileOptions::MergePartialFromCodedStream( case 31: { if (tag == 248) { parse_cc_enable_arenas: + set_has_cc_enable_arenas(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &cc_enable_arenas_))); - set_has_cc_enable_arenas(); } else { goto handle_unusual; } @@ -8470,7 +8551,7 @@ bool FileOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -8548,11 +8629,6 @@ void FileOptions::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(18, this->py_generic_services(), output); } - // optional bool java_generate_equals_and_hash = 20 [default = false]; - if (has_java_generate_equals_and_hash()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(20, this->java_generate_equals_and_hash(), output); - } - // optional bool deprecated = 23 [default = false]; if (has_deprecated()) { ::google::protobuf::internal::WireFormatLite::WriteBool(23, this->deprecated(), output); @@ -8668,11 +8744,6 @@ void FileOptions::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(18, this->py_generic_services(), target); } - // optional bool java_generate_equals_and_hash = 20 [default = false]; - if (has_java_generate_equals_and_hash()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(20, this->java_generate_equals_and_hash(), target); - } - // optional bool deprecated = 23 [default = false]; if (has_deprecated()) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(23, this->deprecated(), target); @@ -8729,9 +8800,9 @@ void FileOptions::SerializeWithCachedSizes( return target; } -int FileOptions::ByteSize() const { +size_t FileOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileOptions) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 255u) { // optional string java_package = 1; @@ -8753,11 +8824,6 @@ int FileOptions::ByteSize() const { total_size += 1 + 1; } - // optional bool java_generate_equals_and_hash = 20 [default = false]; - if (has_java_generate_equals_and_hash()) { - total_size += 2 + 1; - } - // optional bool java_string_check_utf8 = 27 [default = false]; if (has_java_string_check_utf8()) { total_size += 2 + 1; @@ -8781,13 +8847,13 @@ int FileOptions::ByteSize() const { total_size += 2 + 1; } - } - if (_has_bits_[8 / 32] & 16128u) { // optional bool java_generic_services = 17 [default = false]; if (has_java_generic_services()) { total_size += 2 + 1; } + } + if (_has_bits_[8 / 32] & 7936u) { // optional bool py_generic_services = 18 [default = false]; if (has_py_generic_services()) { total_size += 2 + 1; @@ -8819,11 +8885,14 @@ int FileOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -8833,18 +8902,17 @@ int FileOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void FileOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const FileOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FileOptions* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -8852,15 +8920,21 @@ void FileOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void FileOptions::MergeFrom(const FileOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void FileOptions::UnsafeMergeFrom(const FileOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_java_package()) { @@ -8874,9 +8948,6 @@ void FileOptions::MergeFrom(const FileOptions& from) { if (from.has_java_multiple_files()) { set_java_multiple_files(from.java_multiple_files()); } - if (from.has_java_generate_equals_and_hash()) { - set_java_generate_equals_and_hash(from.java_generate_equals_and_hash()); - } if (from.has_java_string_check_utf8()) { set_java_string_check_utf8(from.java_string_check_utf8()); } @@ -8890,11 +8961,11 @@ void FileOptions::MergeFrom(const FileOptions& from) { if (from.has_cc_generic_services()) { set_cc_generic_services(from.cc_generic_services()); } - } - if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (from.has_java_generic_services()) { set_java_generic_services(from.java_generic_services()); } + } + if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (from.has_py_generic_services()) { set_py_generic_services(from.py_generic_services()); } @@ -8915,7 +8986,8 @@ void FileOptions::MergeFrom(const FileOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -8930,14 +9002,16 @@ void FileOptions::CopyFrom(const FileOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FileOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; + if (!_extensions_.IsInitialized()) { + return false; + } return true; } @@ -8949,7 +9023,6 @@ void FileOptions::InternalSwap(FileOptions* other) { java_package_.Swap(&other->java_package_); java_outer_classname_.Swap(&other->java_outer_classname_); std::swap(java_multiple_files_, other->java_multiple_files_); - std::swap(java_generate_equals_and_hash_, other->java_generate_equals_and_hash_); std::swap(java_string_check_utf8_, other->java_string_check_utf8_); std::swap(optimize_for_, other->optimize_for_); go_package_.Swap(&other->go_package_); @@ -8992,37 +9065,37 @@ void FileOptions::clear_java_package() { java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_java_package(); } - const ::std::string& FileOptions::java_package() const { +const ::std::string& FileOptions::java_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package) return java_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_java_package(const ::std::string& value) { +void FileOptions::set_java_package(const ::std::string& value) { set_has_java_package(); java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package) } - void FileOptions::set_java_package(const char* value) { +void FileOptions::set_java_package(const char* value) { set_has_java_package(); java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_package) } - void FileOptions::set_java_package(const char* value, size_t size) { +void FileOptions::set_java_package(const char* value, size_t size) { set_has_java_package(); java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_package) } - ::std::string* FileOptions::mutable_java_package() { +::std::string* FileOptions::mutable_java_package() { set_has_java_package(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_package) return java_package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileOptions::release_java_package() { +::std::string* FileOptions::release_java_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_package) clear_has_java_package(); return java_package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_allocated_java_package(::std::string* java_package) { +void FileOptions::set_allocated_java_package(::std::string* java_package) { if (java_package != NULL) { set_has_java_package(); } else { @@ -9046,37 +9119,37 @@ void FileOptions::clear_java_outer_classname() { java_outer_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_java_outer_classname(); } - const ::std::string& FileOptions::java_outer_classname() const { +const ::std::string& FileOptions::java_outer_classname() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname) return java_outer_classname_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_java_outer_classname(const ::std::string& value) { +void FileOptions::set_java_outer_classname(const ::std::string& value) { set_has_java_outer_classname(); java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname) } - void FileOptions::set_java_outer_classname(const char* value) { +void FileOptions::set_java_outer_classname(const char* value) { set_has_java_outer_classname(); java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_outer_classname) } - void FileOptions::set_java_outer_classname(const char* value, size_t size) { +void FileOptions::set_java_outer_classname(const char* value, size_t size) { set_has_java_outer_classname(); java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_outer_classname) } - ::std::string* FileOptions::mutable_java_outer_classname() { +::std::string* FileOptions::mutable_java_outer_classname() { set_has_java_outer_classname(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_outer_classname) return java_outer_classname_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileOptions::release_java_outer_classname() { +::std::string* FileOptions::release_java_outer_classname() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_outer_classname) clear_has_java_outer_classname(); return java_outer_classname_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_classname) { +void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_classname) { if (java_outer_classname != NULL) { set_has_java_outer_classname(); } else { @@ -9100,59 +9173,35 @@ void FileOptions::clear_java_multiple_files() { java_multiple_files_ = false; clear_has_java_multiple_files(); } - bool FileOptions::java_multiple_files() const { +bool FileOptions::java_multiple_files() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_multiple_files) return java_multiple_files_; } - void FileOptions::set_java_multiple_files(bool value) { +void FileOptions::set_java_multiple_files(bool value) { set_has_java_multiple_files(); java_multiple_files_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_multiple_files) } -// optional bool java_generate_equals_and_hash = 20 [default = false]; -bool FileOptions::has_java_generate_equals_and_hash() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000008u; -} -void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000008u; -} -void FileOptions::clear_java_generate_equals_and_hash() { - java_generate_equals_and_hash_ = false; - clear_has_java_generate_equals_and_hash(); -} - bool FileOptions::java_generate_equals_and_hash() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generate_equals_and_hash) - return java_generate_equals_and_hash_; -} - void FileOptions::set_java_generate_equals_and_hash(bool value) { - set_has_java_generate_equals_and_hash(); - java_generate_equals_and_hash_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generate_equals_and_hash) -} - // optional bool java_string_check_utf8 = 27 [default = false]; bool FileOptions::has_java_string_check_utf8() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000008u; } void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000008u; } void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; clear_has_java_string_check_utf8(); } - bool FileOptions::java_string_check_utf8() const { +bool FileOptions::java_string_check_utf8() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_string_check_utf8) return java_string_check_utf8_; } - void FileOptions::set_java_string_check_utf8(bool value) { +void FileOptions::set_java_string_check_utf8(bool value) { set_has_java_string_check_utf8(); java_string_check_utf8_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_string_check_utf8) @@ -9160,23 +9209,23 @@ void FileOptions::clear_java_string_check_utf8() { // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; bool FileOptions::has_optimize_for() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000010u; } void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000010u; } void FileOptions::clear_optimize_for() { optimize_for_ = 1; clear_has_optimize_for(); } - ::google::protobuf::FileOptions_OptimizeMode FileOptions::optimize_for() const { +::google::protobuf::FileOptions_OptimizeMode FileOptions::optimize_for() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.optimize_for) return static_cast< ::google::protobuf::FileOptions_OptimizeMode >(optimize_for_); } - void FileOptions::set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value) { +void FileOptions::set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value) { assert(::google::protobuf::FileOptions_OptimizeMode_IsValid(value)); set_has_optimize_for(); optimize_for_ = value; @@ -9185,49 +9234,49 @@ void FileOptions::clear_optimize_for() { // optional string go_package = 11; bool FileOptions::has_go_package() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } void FileOptions::set_has_go_package() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000020u; } void FileOptions::clear_has_go_package() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000020u; } void FileOptions::clear_go_package() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_go_package(); } - const ::std::string& FileOptions::go_package() const { +const ::std::string& FileOptions::go_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package) return go_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_go_package(const ::std::string& value) { +void FileOptions::set_go_package(const ::std::string& value) { set_has_go_package(); go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package) } - void FileOptions::set_go_package(const char* value) { +void FileOptions::set_go_package(const char* value) { set_has_go_package(); go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.go_package) } - void FileOptions::set_go_package(const char* value, size_t size) { +void FileOptions::set_go_package(const char* value, size_t size) { set_has_go_package(); go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.go_package) } - ::std::string* FileOptions::mutable_go_package() { +::std::string* FileOptions::mutable_go_package() { set_has_go_package(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.go_package) return go_package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileOptions::release_go_package() { +::std::string* FileOptions::release_go_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.go_package) clear_has_go_package(); return go_package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_allocated_go_package(::std::string* go_package) { +void FileOptions::set_allocated_go_package(::std::string* go_package) { if (go_package != NULL) { set_has_go_package(); } else { @@ -9239,23 +9288,23 @@ void FileOptions::clear_go_package() { // optional bool cc_generic_services = 16 [default = false]; bool FileOptions::has_cc_generic_services() const { - return (_has_bits_[0] & 0x00000080u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000040u; } void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000040u; } void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; clear_has_cc_generic_services(); } - bool FileOptions::cc_generic_services() const { +bool FileOptions::cc_generic_services() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_generic_services) return cc_generic_services_; } - void FileOptions::set_cc_generic_services(bool value) { +void FileOptions::set_cc_generic_services(bool value) { set_has_cc_generic_services(); cc_generic_services_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_generic_services) @@ -9263,23 +9312,23 @@ void FileOptions::clear_cc_generic_services() { // optional bool java_generic_services = 17 [default = false]; bool FileOptions::has_java_generic_services() const { - return (_has_bits_[0] & 0x00000100u) != 0; + return (_has_bits_[0] & 0x00000080u) != 0; } void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000080u; } void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000080u; } void FileOptions::clear_java_generic_services() { java_generic_services_ = false; clear_has_java_generic_services(); } - bool FileOptions::java_generic_services() const { +bool FileOptions::java_generic_services() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generic_services) return java_generic_services_; } - void FileOptions::set_java_generic_services(bool value) { +void FileOptions::set_java_generic_services(bool value) { set_has_java_generic_services(); java_generic_services_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generic_services) @@ -9287,23 +9336,23 @@ void FileOptions::clear_java_generic_services() { // optional bool py_generic_services = 18 [default = false]; bool FileOptions::has_py_generic_services() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000100u) != 0; } void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000100u; } void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000100u; } void FileOptions::clear_py_generic_services() { py_generic_services_ = false; clear_has_py_generic_services(); } - bool FileOptions::py_generic_services() const { +bool FileOptions::py_generic_services() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.py_generic_services) return py_generic_services_; } - void FileOptions::set_py_generic_services(bool value) { +void FileOptions::set_py_generic_services(bool value) { set_has_py_generic_services(); py_generic_services_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.py_generic_services) @@ -9311,23 +9360,23 @@ void FileOptions::clear_py_generic_services() { // optional bool deprecated = 23 [default = false]; bool FileOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00000200u) != 0; } void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00000200u; } void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00000200u; } void FileOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool FileOptions::deprecated() const { +bool FileOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.deprecated) return deprecated_; } - void FileOptions::set_deprecated(bool value) { +void FileOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.deprecated) @@ -9335,23 +9384,23 @@ void FileOptions::clear_deprecated() { // optional bool cc_enable_arenas = 31 [default = false]; bool FileOptions::has_cc_enable_arenas() const { - return (_has_bits_[0] & 0x00000800u) != 0; + return (_has_bits_[0] & 0x00000400u) != 0; } void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00000400u; } void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00000400u; } void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; clear_has_cc_enable_arenas(); } - bool FileOptions::cc_enable_arenas() const { +bool FileOptions::cc_enable_arenas() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_enable_arenas) return cc_enable_arenas_; } - void FileOptions::set_cc_enable_arenas(bool value) { +void FileOptions::set_cc_enable_arenas(bool value) { set_has_cc_enable_arenas(); cc_enable_arenas_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_enable_arenas) @@ -9359,49 +9408,49 @@ void FileOptions::clear_cc_enable_arenas() { // optional string objc_class_prefix = 36; bool FileOptions::has_objc_class_prefix() const { - return (_has_bits_[0] & 0x00001000u) != 0; + return (_has_bits_[0] & 0x00000800u) != 0; } void FileOptions::set_has_objc_class_prefix() { - _has_bits_[0] |= 0x00001000u; + _has_bits_[0] |= 0x00000800u; } void FileOptions::clear_has_objc_class_prefix() { - _has_bits_[0] &= ~0x00001000u; + _has_bits_[0] &= ~0x00000800u; } void FileOptions::clear_objc_class_prefix() { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_objc_class_prefix(); } - const ::std::string& FileOptions::objc_class_prefix() const { +const ::std::string& FileOptions::objc_class_prefix() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix) return objc_class_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_objc_class_prefix(const ::std::string& value) { +void FileOptions::set_objc_class_prefix(const ::std::string& value) { set_has_objc_class_prefix(); objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix) } - void FileOptions::set_objc_class_prefix(const char* value) { +void FileOptions::set_objc_class_prefix(const char* value) { set_has_objc_class_prefix(); objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.objc_class_prefix) } - void FileOptions::set_objc_class_prefix(const char* value, size_t size) { +void FileOptions::set_objc_class_prefix(const char* value, size_t size) { set_has_objc_class_prefix(); objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.objc_class_prefix) } - ::std::string* FileOptions::mutable_objc_class_prefix() { +::std::string* FileOptions::mutable_objc_class_prefix() { set_has_objc_class_prefix(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.objc_class_prefix) return objc_class_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileOptions::release_objc_class_prefix() { +::std::string* FileOptions::release_objc_class_prefix() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.objc_class_prefix) clear_has_objc_class_prefix(); return objc_class_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_class_prefix) { +void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_class_prefix) { if (objc_class_prefix != NULL) { set_has_objc_class_prefix(); } else { @@ -9413,49 +9462,49 @@ void FileOptions::clear_objc_class_prefix() { // optional string csharp_namespace = 37; bool FileOptions::has_csharp_namespace() const { - return (_has_bits_[0] & 0x00002000u) != 0; + return (_has_bits_[0] & 0x00001000u) != 0; } void FileOptions::set_has_csharp_namespace() { - _has_bits_[0] |= 0x00002000u; + _has_bits_[0] |= 0x00001000u; } void FileOptions::clear_has_csharp_namespace() { - _has_bits_[0] &= ~0x00002000u; + _has_bits_[0] &= ~0x00001000u; } void FileOptions::clear_csharp_namespace() { csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_csharp_namespace(); } - const ::std::string& FileOptions::csharp_namespace() const { +const ::std::string& FileOptions::csharp_namespace() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace) return csharp_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_csharp_namespace(const ::std::string& value) { +void FileOptions::set_csharp_namespace(const ::std::string& value) { set_has_csharp_namespace(); csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace) } - void FileOptions::set_csharp_namespace(const char* value) { +void FileOptions::set_csharp_namespace(const char* value) { set_has_csharp_namespace(); csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_namespace) } - void FileOptions::set_csharp_namespace(const char* value, size_t size) { +void FileOptions::set_csharp_namespace(const char* value, size_t size) { set_has_csharp_namespace(); csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_namespace) } - ::std::string* FileOptions::mutable_csharp_namespace() { +::std::string* FileOptions::mutable_csharp_namespace() { set_has_csharp_namespace(); // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_namespace) return csharp_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* FileOptions::release_csharp_namespace() { +::std::string* FileOptions::release_csharp_namespace() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.csharp_namespace) clear_has_csharp_namespace(); return csharp_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_namespace) { +void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_namespace) { if (csharp_namespace != NULL) { set_has_csharp_namespace(); } else { @@ -9509,6 +9558,7 @@ const int MessageOptions::kUninterpretedOptionFieldNumber; MessageOptions::MessageOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MessageOptions) } @@ -9520,17 +9570,14 @@ MessageOptions::MessageOptions(const MessageOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.MessageOptions) } void MessageOptions::SharedCtor() { _cached_size_ = 0; - message_set_wire_format_ = false; - no_standard_descriptor_accessor_ = false; - deprecated_ = false; - map_entry_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&message_set_wire_format_, 0, reinterpret_cast(&map_entry_) - + reinterpret_cast(&message_set_wire_format_) + sizeof(map_entry_)); } MessageOptions::~MessageOptions() { @@ -9539,8 +9586,6 @@ MessageOptions::~MessageOptions() { } void MessageOptions::SharedDtor() { - if (this != default_instance_) { - } } void MessageOptions::SetCachedSize(int size) const { @@ -9554,11 +9599,11 @@ const ::google::protobuf::Descriptor* MessageOptions::descriptor() { } const MessageOptions& MessageOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -MessageOptions* MessageOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed MessageOptions::default_instance_; MessageOptions* MessageOptions::New(::google::protobuf::Arena* arena) const { MessageOptions* n = new MessageOptions; @@ -9593,7 +9638,7 @@ void MessageOptions::Clear() { #undef ZR_ uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -9612,10 +9657,10 @@ bool MessageOptions::MergePartialFromCodedStream( // optional bool message_set_wire_format = 1 [default = false]; case 1: { if (tag == 8) { + set_has_message_set_wire_format(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &message_set_wire_format_))); - set_has_message_set_wire_format(); } else { goto handle_unusual; } @@ -9627,10 +9672,10 @@ bool MessageOptions::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_no_standard_descriptor_accessor: + set_has_no_standard_descriptor_accessor(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &no_standard_descriptor_accessor_))); - set_has_no_standard_descriptor_accessor(); } else { goto handle_unusual; } @@ -9642,10 +9687,10 @@ bool MessageOptions::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_deprecated: + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -9657,10 +9702,10 @@ bool MessageOptions::MergePartialFromCodedStream( case 7: { if (tag == 56) { parse_map_entry: + set_has_map_entry(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &map_entry_))); - set_has_map_entry(); } else { goto handle_unusual; } @@ -9693,7 +9738,7 @@ bool MessageOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -9795,9 +9840,9 @@ void MessageOptions::SerializeWithCachedSizes( return target; } -int MessageOptions::ByteSize() const { +size_t MessageOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MessageOptions) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 15u) { // optional bool message_set_wire_format = 1 [default = false]; @@ -9822,11 +9867,14 @@ int MessageOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -9836,18 +9884,17 @@ int MessageOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void MessageOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MessageOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const MessageOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const MessageOptions* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -9855,15 +9902,21 @@ void MessageOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MessageOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void MessageOptions::MergeFrom(const MessageOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MessageOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void MessageOptions::UnsafeMergeFrom(const MessageOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_message_set_wire_format()) { @@ -9881,7 +9934,8 @@ void MessageOptions::MergeFrom(const MessageOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -9896,14 +9950,16 @@ void MessageOptions::CopyFrom(const MessageOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MessageOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool MessageOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; + if (!_extensions_.IsInitialized()) { + return false; + } return true; } @@ -9948,11 +10004,11 @@ void MessageOptions::clear_message_set_wire_format() { message_set_wire_format_ = false; clear_has_message_set_wire_format(); } - bool MessageOptions::message_set_wire_format() const { +bool MessageOptions::message_set_wire_format() const { // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.message_set_wire_format) return message_set_wire_format_; } - void MessageOptions::set_message_set_wire_format(bool value) { +void MessageOptions::set_message_set_wire_format(bool value) { set_has_message_set_wire_format(); message_set_wire_format_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.message_set_wire_format) @@ -9972,11 +10028,11 @@ void MessageOptions::clear_no_standard_descriptor_accessor() { no_standard_descriptor_accessor_ = false; clear_has_no_standard_descriptor_accessor(); } - bool MessageOptions::no_standard_descriptor_accessor() const { +bool MessageOptions::no_standard_descriptor_accessor() const { // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.no_standard_descriptor_accessor) return no_standard_descriptor_accessor_; } - void MessageOptions::set_no_standard_descriptor_accessor(bool value) { +void MessageOptions::set_no_standard_descriptor_accessor(bool value) { set_has_no_standard_descriptor_accessor(); no_standard_descriptor_accessor_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.no_standard_descriptor_accessor) @@ -9996,11 +10052,11 @@ void MessageOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool MessageOptions::deprecated() const { +bool MessageOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.deprecated) return deprecated_; } - void MessageOptions::set_deprecated(bool value) { +void MessageOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.deprecated) @@ -10020,11 +10076,11 @@ void MessageOptions::clear_map_entry() { map_entry_ = false; clear_has_map_entry(); } - bool MessageOptions::map_entry() const { +bool MessageOptions::map_entry() const { // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.map_entry) return map_entry_; } - void MessageOptions::set_map_entry(bool value) { +void MessageOptions::set_map_entry(bool value) { set_has_map_entry(); map_entry_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.map_entry) @@ -10069,7 +10125,7 @@ const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor() { return FieldOptions_CType_descriptor_; } bool FieldOptions_CType_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -10092,7 +10148,7 @@ const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor() { return FieldOptions_JSType_descriptor_; } bool FieldOptions_JSType_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -10122,6 +10178,7 @@ const int FieldOptions::kUninterpretedOptionFieldNumber; FieldOptions::FieldOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldOptions) } @@ -10133,19 +10190,14 @@ FieldOptions::FieldOptions(const FieldOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldOptions) } void FieldOptions::SharedCtor() { _cached_size_ = 0; - ctype_ = 0; - packed_ = false; - jstype_ = 0; - lazy_ = false; - deprecated_ = false; - weak_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&ctype_, 0, reinterpret_cast(&weak_) - + reinterpret_cast(&ctype_) + sizeof(weak_)); } FieldOptions::~FieldOptions() { @@ -10154,8 +10206,6 @@ FieldOptions::~FieldOptions() { } void FieldOptions::SharedDtor() { - if (this != default_instance_) { - } } void FieldOptions::SetCachedSize(int size) const { @@ -10169,11 +10219,11 @@ const ::google::protobuf::Descriptor* FieldOptions::descriptor() { } const FieldOptions& FieldOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -FieldOptions* FieldOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed FieldOptions::default_instance_; FieldOptions* FieldOptions::New(::google::protobuf::Arena* arena) const { FieldOptions* n = new FieldOptions; @@ -10202,16 +10252,13 @@ void FieldOptions::Clear() { ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ } while (0) - if (_has_bits_[0 / 32] & 63u) { - ZR_(ctype_, jstype_); - ZR_(packed_, weak_); - } + ZR_(ctype_, weak_); #undef ZR_HELPER_ #undef ZR_ uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -10250,10 +10297,10 @@ bool FieldOptions::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_packed: + set_has_packed(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &packed_))); - set_has_packed(); } else { goto handle_unusual; } @@ -10265,10 +10312,10 @@ bool FieldOptions::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_deprecated: + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -10280,10 +10327,10 @@ bool FieldOptions::MergePartialFromCodedStream( case 5: { if (tag == 40) { parse_lazy: + set_has_lazy(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &lazy_))); - set_has_lazy(); } else { goto handle_unusual; } @@ -10315,10 +10362,10 @@ bool FieldOptions::MergePartialFromCodedStream( case 10: { if (tag == 80) { parse_weak: + set_has_weak(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &weak_))); - set_has_weak(); } else { goto handle_unusual; } @@ -10351,7 +10398,7 @@ bool FieldOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -10477,9 +10524,9 @@ void FieldOptions::SerializeWithCachedSizes( return target; } -int FieldOptions::ByteSize() const { +size_t FieldOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldOptions) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 63u) { // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; @@ -10516,11 +10563,14 @@ int FieldOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -10530,18 +10580,17 @@ int FieldOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void FieldOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const FieldOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FieldOptions* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -10549,15 +10598,21 @@ void FieldOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void FieldOptions::MergeFrom(const FieldOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void FieldOptions::UnsafeMergeFrom(const FieldOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_ctype()) { @@ -10581,7 +10636,8 @@ void FieldOptions::MergeFrom(const FieldOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -10596,14 +10652,16 @@ void FieldOptions::CopyFrom(const FieldOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FieldOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; + if (!_extensions_.IsInitialized()) { + return false; + } return true; } @@ -10650,11 +10708,11 @@ void FieldOptions::clear_ctype() { ctype_ = 0; clear_has_ctype(); } - ::google::protobuf::FieldOptions_CType FieldOptions::ctype() const { +::google::protobuf::FieldOptions_CType FieldOptions::ctype() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.ctype) return static_cast< ::google::protobuf::FieldOptions_CType >(ctype_); } - void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value) { +void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value) { assert(::google::protobuf::FieldOptions_CType_IsValid(value)); set_has_ctype(); ctype_ = value; @@ -10675,11 +10733,11 @@ void FieldOptions::clear_packed() { packed_ = false; clear_has_packed(); } - bool FieldOptions::packed() const { +bool FieldOptions::packed() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.packed) return packed_; } - void FieldOptions::set_packed(bool value) { +void FieldOptions::set_packed(bool value) { set_has_packed(); packed_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.packed) @@ -10699,11 +10757,11 @@ void FieldOptions::clear_jstype() { jstype_ = 0; clear_has_jstype(); } - ::google::protobuf::FieldOptions_JSType FieldOptions::jstype() const { +::google::protobuf::FieldOptions_JSType FieldOptions::jstype() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.jstype) return static_cast< ::google::protobuf::FieldOptions_JSType >(jstype_); } - void FieldOptions::set_jstype(::google::protobuf::FieldOptions_JSType value) { +void FieldOptions::set_jstype(::google::protobuf::FieldOptions_JSType value) { assert(::google::protobuf::FieldOptions_JSType_IsValid(value)); set_has_jstype(); jstype_ = value; @@ -10724,11 +10782,11 @@ void FieldOptions::clear_lazy() { lazy_ = false; clear_has_lazy(); } - bool FieldOptions::lazy() const { +bool FieldOptions::lazy() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.lazy) return lazy_; } - void FieldOptions::set_lazy(bool value) { +void FieldOptions::set_lazy(bool value) { set_has_lazy(); lazy_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.lazy) @@ -10748,11 +10806,11 @@ void FieldOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool FieldOptions::deprecated() const { +bool FieldOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.deprecated) return deprecated_; } - void FieldOptions::set_deprecated(bool value) { +void FieldOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.deprecated) @@ -10772,11 +10830,11 @@ void FieldOptions::clear_weak() { weak_ = false; clear_has_weak(); } - bool FieldOptions::weak() const { +bool FieldOptions::weak() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.weak) return weak_; } - void FieldOptions::set_weak(bool value) { +void FieldOptions::set_weak(bool value) { set_has_weak(); weak_ = value; // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.weak) @@ -10822,6 +10880,7 @@ const int OneofOptions::kUninterpretedOptionFieldNumber; OneofOptions::OneofOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.OneofOptions) } @@ -10833,13 +10892,12 @@ OneofOptions::OneofOptions(const OneofOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.OneofOptions) } void OneofOptions::SharedCtor() { _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } OneofOptions::~OneofOptions() { @@ -10848,8 +10906,6 @@ OneofOptions::~OneofOptions() { } void OneofOptions::SharedDtor() { - if (this != default_instance_) { - } } void OneofOptions::SetCachedSize(int size) const { @@ -10863,11 +10919,11 @@ const ::google::protobuf::Descriptor* OneofOptions::descriptor() { } const OneofOptions& OneofOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -OneofOptions* OneofOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed OneofOptions::default_instance_; OneofOptions* OneofOptions::New(::google::protobuf::Arena* arena) const { OneofOptions* n = new OneofOptions; @@ -10881,7 +10937,7 @@ void OneofOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.OneofOptions) _extensions_.Clear(); uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -10921,7 +10977,7 @@ bool OneofOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -10983,16 +11039,19 @@ void OneofOptions::SerializeWithCachedSizes( return target; } -int OneofOptions::ByteSize() const { +size_t OneofOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofOptions) - int total_size = 0; + size_t total_size = 0; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -11002,18 +11061,17 @@ int OneofOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void OneofOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const OneofOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const OneofOptions* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -11021,19 +11079,26 @@ void OneofOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.OneofOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void OneofOptions::MergeFrom(const OneofOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void OneofOptions::UnsafeMergeFrom(const OneofOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -11048,14 +11113,16 @@ void OneofOptions::CopyFrom(const OneofOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool OneofOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; + if (!_extensions_.IsInitialized()) { + return false; + } return true; } @@ -11124,6 +11191,7 @@ const int EnumOptions::kUninterpretedOptionFieldNumber; EnumOptions::EnumOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumOptions) } @@ -11135,15 +11203,14 @@ EnumOptions::EnumOptions(const EnumOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumOptions) } void EnumOptions::SharedCtor() { _cached_size_ = 0; - allow_alias_ = false; - deprecated_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&allow_alias_, 0, reinterpret_cast(&deprecated_) - + reinterpret_cast(&allow_alias_) + sizeof(deprecated_)); } EnumOptions::~EnumOptions() { @@ -11152,8 +11219,6 @@ EnumOptions::~EnumOptions() { } void EnumOptions::SharedDtor() { - if (this != default_instance_) { - } } void EnumOptions::SetCachedSize(int size) const { @@ -11167,11 +11232,11 @@ const ::google::protobuf::Descriptor* EnumOptions::descriptor() { } const EnumOptions& EnumOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -EnumOptions* EnumOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed EnumOptions::default_instance_; EnumOptions* EnumOptions::New(::google::protobuf::Arena* arena) const { EnumOptions* n = new EnumOptions; @@ -11206,7 +11271,7 @@ void EnumOptions::Clear() { #undef ZR_ uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -11225,10 +11290,10 @@ bool EnumOptions::MergePartialFromCodedStream( // optional bool allow_alias = 2; case 2: { if (tag == 16) { + set_has_allow_alias(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &allow_alias_))); - set_has_allow_alias(); } else { goto handle_unusual; } @@ -11240,10 +11305,10 @@ bool EnumOptions::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_deprecated: + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -11276,7 +11341,7 @@ bool EnumOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -11358,9 +11423,9 @@ void EnumOptions::SerializeWithCachedSizes( return target; } -int EnumOptions::ByteSize() const { +size_t EnumOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumOptions) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[0 / 32] & 3u) { // optional bool allow_alias = 2; @@ -11375,11 +11440,14 @@ int EnumOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -11389,18 +11457,17 @@ int EnumOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void EnumOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const EnumOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const EnumOptions* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -11408,15 +11475,21 @@ void EnumOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void EnumOptions::MergeFrom(const EnumOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void EnumOptions::UnsafeMergeFrom(const EnumOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_allow_alias()) { @@ -11428,7 +11501,8 @@ void EnumOptions::MergeFrom(const EnumOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -11443,14 +11517,16 @@ void EnumOptions::CopyFrom(const EnumOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool EnumOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; + if (!_extensions_.IsInitialized()) { + return false; + } return true; } @@ -11493,11 +11569,11 @@ void EnumOptions::clear_allow_alias() { allow_alias_ = false; clear_has_allow_alias(); } - bool EnumOptions::allow_alias() const { +bool EnumOptions::allow_alias() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.allow_alias) return allow_alias_; } - void EnumOptions::set_allow_alias(bool value) { +void EnumOptions::set_allow_alias(bool value) { set_has_allow_alias(); allow_alias_ = value; // @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.allow_alias) @@ -11517,11 +11593,11 @@ void EnumOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool EnumOptions::deprecated() const { +bool EnumOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.deprecated) return deprecated_; } - void EnumOptions::set_deprecated(bool value) { +void EnumOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.deprecated) @@ -11568,6 +11644,7 @@ const int EnumValueOptions::kUninterpretedOptionFieldNumber; EnumValueOptions::EnumValueOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValueOptions) } @@ -11579,14 +11656,13 @@ EnumValueOptions::EnumValueOptions(const EnumValueOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueOptions) } void EnumValueOptions::SharedCtor() { _cached_size_ = 0; deprecated_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } EnumValueOptions::~EnumValueOptions() { @@ -11595,8 +11671,6 @@ EnumValueOptions::~EnumValueOptions() { } void EnumValueOptions::SharedDtor() { - if (this != default_instance_) { - } } void EnumValueOptions::SetCachedSize(int size) const { @@ -11610,11 +11684,11 @@ const ::google::protobuf::Descriptor* EnumValueOptions::descriptor() { } const EnumValueOptions& EnumValueOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -EnumValueOptions* EnumValueOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed EnumValueOptions::default_instance_; EnumValueOptions* EnumValueOptions::New(::google::protobuf::Arena* arena) const { EnumValueOptions* n = new EnumValueOptions; @@ -11629,7 +11703,7 @@ void EnumValueOptions::Clear() { _extensions_.Clear(); deprecated_ = false; uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -11648,10 +11722,10 @@ bool EnumValueOptions::MergePartialFromCodedStream( // optional bool deprecated = 1 [default = false]; case 1: { if (tag == 8) { + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -11684,7 +11758,7 @@ bool EnumValueOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -11756,9 +11830,9 @@ void EnumValueOptions::SerializeWithCachedSizes( return target; } -int EnumValueOptions::ByteSize() const { +size_t EnumValueOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueOptions) - int total_size = 0; + size_t total_size = 0; // optional bool deprecated = 1 [default = false]; if (has_deprecated()) { @@ -11766,11 +11840,14 @@ int EnumValueOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -11780,18 +11857,17 @@ int EnumValueOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void EnumValueOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const EnumValueOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const EnumValueOptions* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -11799,15 +11875,21 @@ void EnumValueOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValueOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void EnumValueOptions::MergeFrom(const EnumValueOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void EnumValueOptions::UnsafeMergeFrom(const EnumValueOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_deprecated()) { @@ -11816,7 +11898,8 @@ void EnumValueOptions::MergeFrom(const EnumValueOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -11831,14 +11914,16 @@ void EnumValueOptions::CopyFrom(const EnumValueOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool EnumValueOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; + if (!_extensions_.IsInitialized()) { + return false; + } return true; } @@ -11880,11 +11965,11 @@ void EnumValueOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool EnumValueOptions::deprecated() const { +bool EnumValueOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.deprecated) return deprecated_; } - void EnumValueOptions::set_deprecated(bool value) { +void EnumValueOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.EnumValueOptions.deprecated) @@ -11931,6 +12016,7 @@ const int ServiceOptions::kUninterpretedOptionFieldNumber; ServiceOptions::ServiceOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ServiceOptions) } @@ -11942,14 +12028,13 @@ ServiceOptions::ServiceOptions(const ServiceOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceOptions) } void ServiceOptions::SharedCtor() { _cached_size_ = 0; deprecated_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } ServiceOptions::~ServiceOptions() { @@ -11958,8 +12043,6 @@ ServiceOptions::~ServiceOptions() { } void ServiceOptions::SharedDtor() { - if (this != default_instance_) { - } } void ServiceOptions::SetCachedSize(int size) const { @@ -11973,11 +12056,11 @@ const ::google::protobuf::Descriptor* ServiceOptions::descriptor() { } const ServiceOptions& ServiceOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -ServiceOptions* ServiceOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ServiceOptions::default_instance_; ServiceOptions* ServiceOptions::New(::google::protobuf::Arena* arena) const { ServiceOptions* n = new ServiceOptions; @@ -11992,7 +12075,7 @@ void ServiceOptions::Clear() { _extensions_.Clear(); deprecated_ = false; uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -12011,10 +12094,10 @@ bool ServiceOptions::MergePartialFromCodedStream( // optional bool deprecated = 33 [default = false]; case 33: { if (tag == 264) { + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -12047,7 +12130,7 @@ bool ServiceOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -12119,9 +12202,9 @@ void ServiceOptions::SerializeWithCachedSizes( return target; } -int ServiceOptions::ByteSize() const { +size_t ServiceOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceOptions) - int total_size = 0; + size_t total_size = 0; // optional bool deprecated = 33 [default = false]; if (has_deprecated()) { @@ -12129,11 +12212,14 @@ int ServiceOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -12143,18 +12229,17 @@ int ServiceOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void ServiceOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const ServiceOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ServiceOptions* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -12162,15 +12247,21 @@ void ServiceOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ServiceOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void ServiceOptions::MergeFrom(const ServiceOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void ServiceOptions::UnsafeMergeFrom(const ServiceOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_deprecated()) { @@ -12179,7 +12270,8 @@ void ServiceOptions::MergeFrom(const ServiceOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -12194,14 +12286,16 @@ void ServiceOptions::CopyFrom(const ServiceOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ServiceOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; + if (!_extensions_.IsInitialized()) { + return false; + } return true; } @@ -12243,11 +12337,11 @@ void ServiceOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool ServiceOptions::deprecated() const { +bool ServiceOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.deprecated) return deprecated_; } - void ServiceOptions::set_deprecated(bool value) { +void ServiceOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.ServiceOptions.deprecated) @@ -12294,6 +12388,7 @@ const int MethodOptions::kUninterpretedOptionFieldNumber; MethodOptions::MethodOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MethodOptions) } @@ -12305,14 +12400,13 @@ MethodOptions::MethodOptions(const MethodOptions& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodOptions) } void MethodOptions::SharedCtor() { _cached_size_ = 0; deprecated_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } MethodOptions::~MethodOptions() { @@ -12321,8 +12415,6 @@ MethodOptions::~MethodOptions() { } void MethodOptions::SharedDtor() { - if (this != default_instance_) { - } } void MethodOptions::SetCachedSize(int size) const { @@ -12336,11 +12428,11 @@ const ::google::protobuf::Descriptor* MethodOptions::descriptor() { } const MethodOptions& MethodOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -MethodOptions* MethodOptions::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed MethodOptions::default_instance_; MethodOptions* MethodOptions::New(::google::protobuf::Arena* arena) const { MethodOptions* n = new MethodOptions; @@ -12355,7 +12447,7 @@ void MethodOptions::Clear() { _extensions_.Clear(); deprecated_ = false; uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -12374,10 +12466,10 @@ bool MethodOptions::MergePartialFromCodedStream( // optional bool deprecated = 33 [default = false]; case 33: { if (tag == 264) { + set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &deprecated_))); - set_has_deprecated(); } else { goto handle_unusual; } @@ -12410,7 +12502,7 @@ bool MethodOptions::MergePartialFromCodedStream( goto success; } if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, + DO_(_extensions_.ParseField(tag, input, internal_default_instance(), mutable_unknown_fields())); continue; } @@ -12482,9 +12574,9 @@ void MethodOptions::SerializeWithCachedSizes( return target; } -int MethodOptions::ByteSize() const { +size_t MethodOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodOptions) - int total_size = 0; + size_t total_size = 0; // optional bool deprecated = 33 [default = false]; if (has_deprecated()) { @@ -12492,11 +12584,14 @@ int MethodOptions::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } } total_size += _extensions_.ByteSize(); @@ -12506,18 +12601,17 @@ int MethodOptions::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void MethodOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const MethodOptions* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const MethodOptions* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -12525,15 +12619,21 @@ void MethodOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MethodOptions) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void MethodOptions::MergeFrom(const MethodOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void MethodOptions::UnsafeMergeFrom(const MethodOptions& from) { + GOOGLE_DCHECK(&from != this); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_deprecated()) { @@ -12542,7 +12642,8 @@ void MethodOptions::MergeFrom(const MethodOptions& from) { } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -12557,14 +12658,16 @@ void MethodOptions::CopyFrom(const MethodOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodOptions) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool MethodOptions::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) return false; + if (!_extensions_.IsInitialized()) { + return false; + } return true; } @@ -12606,11 +12709,11 @@ void MethodOptions::clear_deprecated() { deprecated_ = false; clear_has_deprecated(); } - bool MethodOptions::deprecated() const { +bool MethodOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.deprecated) return deprecated_; } - void MethodOptions::set_deprecated(bool value) { +void MethodOptions::set_deprecated(bool value) { set_has_deprecated(); deprecated_ = value; // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.deprecated) @@ -12657,6 +12760,7 @@ const int UninterpretedOption_NamePart::kIsExtensionFieldNumber; UninterpretedOption_NamePart::UninterpretedOption_NamePart() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption.NamePart) } @@ -12668,16 +12772,14 @@ UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOp : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart) } void UninterpretedOption_NamePart::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; name_part_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); is_extension_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } UninterpretedOption_NamePart::~UninterpretedOption_NamePart() { @@ -12687,8 +12789,6 @@ UninterpretedOption_NamePart::~UninterpretedOption_NamePart() { void UninterpretedOption_NamePart::SharedDtor() { name_part_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void UninterpretedOption_NamePart::SetCachedSize(int size) const { @@ -12702,11 +12802,11 @@ const ::google::protobuf::Descriptor* UninterpretedOption_NamePart::descriptor() } const UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -UninterpretedOption_NamePart* UninterpretedOption_NamePart::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed UninterpretedOption_NamePart::default_instance_; UninterpretedOption_NamePart* UninterpretedOption_NamePart::New(::google::protobuf::Arena* arena) const { UninterpretedOption_NamePart* n = new UninterpretedOption_NamePart; @@ -12724,7 +12824,7 @@ void UninterpretedOption_NamePart::Clear() { } is_extension_ = false; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -12760,10 +12860,10 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_is_extension: + set_has_is_extension(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &is_extension_))); - set_has_is_extension(); } else { goto handle_unusual; } @@ -12846,9 +12946,9 @@ void UninterpretedOption_NamePart::SerializeWithCachedSizes( return target; } -int UninterpretedOption_NamePart::RequiredFieldsByteSizeFallback() const { +size_t UninterpretedOption_NamePart::RequiredFieldsByteSizeFallback() const { // @@protoc_insertion_point(required_fields_byte_size_fallback_start:google.protobuf.UninterpretedOption.NamePart) - int total_size = 0; + size_t total_size = 0; if (has_name_part()) { // required string name_part = 1; @@ -12864,9 +12964,9 @@ int UninterpretedOption_NamePart::RequiredFieldsByteSizeFallback() const { return total_size; } -int UninterpretedOption_NamePart::ByteSize() const { +size_t UninterpretedOption_NamePart::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption.NamePart) - int total_size = 0; + size_t total_size = 0; if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. // required string name_part = 1; @@ -12885,18 +12985,17 @@ int UninterpretedOption_NamePart::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void UninterpretedOption_NamePart::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UninterpretedOption.NamePart) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const UninterpretedOption_NamePart* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const UninterpretedOption_NamePart* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -12904,15 +13003,21 @@ void UninterpretedOption_NamePart::MergeFrom(const ::google::protobuf::Message& ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UninterpretedOption.NamePart) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void UninterpretedOption_NamePart::UnsafeMergeFrom(const UninterpretedOption_NamePart& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name_part()) { set_has_name_part(); @@ -12923,7 +13028,8 @@ void UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -12938,7 +13044,7 @@ void UninterpretedOption_NamePart::CopyFrom(const UninterpretedOption_NamePart& // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption.NamePart) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool UninterpretedOption_NamePart::IsInitialized() const { @@ -12982,6 +13088,7 @@ const int UninterpretedOption::kAggregateValueFieldNumber; UninterpretedOption::UninterpretedOption() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption) } @@ -12993,20 +13100,17 @@ UninterpretedOption::UninterpretedOption(const UninterpretedOption& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption) } void UninterpretedOption::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; identifier_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - positive_int_value_ = GOOGLE_ULONGLONG(0); - negative_int_value_ = GOOGLE_LONGLONG(0); - double_value_ = 0; string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); aggregate_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&positive_int_value_, 0, reinterpret_cast(&double_value_) - + reinterpret_cast(&positive_int_value_) + sizeof(double_value_)); } UninterpretedOption::~UninterpretedOption() { @@ -13018,8 +13122,6 @@ void UninterpretedOption::SharedDtor() { identifier_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); aggregate_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void UninterpretedOption::SetCachedSize(int size) const { @@ -13033,11 +13135,11 @@ const ::google::protobuf::Descriptor* UninterpretedOption::descriptor() { } const UninterpretedOption& UninterpretedOption::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -UninterpretedOption* UninterpretedOption::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed UninterpretedOption::default_instance_; UninterpretedOption* UninterpretedOption::New(::google::protobuf::Arena* arena) const { UninterpretedOption* n = new UninterpretedOption; @@ -13082,7 +13184,7 @@ void UninterpretedOption::Clear() { #undef ZR_ name_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -13135,10 +13237,10 @@ bool UninterpretedOption::MergePartialFromCodedStream( case 4: { if (tag == 32) { parse_positive_int_value: + set_has_positive_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( input, &positive_int_value_))); - set_has_positive_int_value(); } else { goto handle_unusual; } @@ -13150,10 +13252,10 @@ bool UninterpretedOption::MergePartialFromCodedStream( case 5: { if (tag == 40) { parse_negative_int_value: + set_has_negative_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( input, &negative_int_value_))); - set_has_negative_int_value(); } else { goto handle_unusual; } @@ -13165,10 +13267,10 @@ bool UninterpretedOption::MergePartialFromCodedStream( case 6: { if (tag == 49) { parse_double_value: + set_has_double_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( input, &double_value_))); - set_has_double_value(); } else { goto handle_unusual; } @@ -13348,9 +13450,9 @@ void UninterpretedOption::SerializeWithCachedSizes( return target; } -int UninterpretedOption::ByteSize() const { +size_t UninterpretedOption::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[1 / 32] & 126u) { // optional string identifier_value = 3; @@ -13395,11 +13497,14 @@ int UninterpretedOption::ByteSize() const { } // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - total_size += 1 * this->name_size(); - for (int i = 0; i < this->name_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->name(i)); + { + unsigned int count = this->name_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->name(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -13407,18 +13512,17 @@ int UninterpretedOption::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void UninterpretedOption::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UninterpretedOption) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const UninterpretedOption* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const UninterpretedOption* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -13426,15 +13530,21 @@ void UninterpretedOption::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UninterpretedOption) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void UninterpretedOption::MergeFrom(const UninterpretedOption& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void UninterpretedOption::UnsafeMergeFrom(const UninterpretedOption& from) { + GOOGLE_DCHECK(&from != this); name_.MergeFrom(from.name_); if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) { if (from.has_identifier_value()) { @@ -13460,7 +13570,8 @@ void UninterpretedOption::MergeFrom(const UninterpretedOption& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -13475,7 +13586,7 @@ void UninterpretedOption::CopyFrom(const UninterpretedOption& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool UninterpretedOption::IsInitialized() const { @@ -13526,37 +13637,37 @@ void UninterpretedOption_NamePart::clear_name_part() { name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name_part(); } - const ::std::string& UninterpretedOption_NamePart::name_part() const { +const ::std::string& UninterpretedOption_NamePart::name_part() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part) return name_part_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) { +void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) { set_has_name_part(); name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part) } - void UninterpretedOption_NamePart::set_name_part(const char* value) { +void UninterpretedOption_NamePart::set_name_part(const char* value) { set_has_name_part(); name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.NamePart.name_part) } - void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) { +void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) { set_has_name_part(); name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part) } - ::std::string* UninterpretedOption_NamePart::mutable_name_part() { +::std::string* UninterpretedOption_NamePart::mutable_name_part() { set_has_name_part(); // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.NamePart.name_part) return name_part_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* UninterpretedOption_NamePart::release_name_part() { +::std::string* UninterpretedOption_NamePart::release_name_part() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part) clear_has_name_part(); return name_part_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) { +void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) { if (name_part != NULL) { set_has_name_part(); } else { @@ -13580,11 +13691,11 @@ void UninterpretedOption_NamePart::clear_is_extension() { is_extension_ = false; clear_has_is_extension(); } - bool UninterpretedOption_NamePart::is_extension() const { +bool UninterpretedOption_NamePart::is_extension() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.is_extension) return is_extension_; } - void UninterpretedOption_NamePart::set_is_extension(bool value) { +void UninterpretedOption_NamePart::set_is_extension(bool value) { set_has_is_extension(); is_extension_ = value; // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension) @@ -13638,37 +13749,37 @@ void UninterpretedOption::clear_identifier_value() { identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_identifier_value(); } - const ::std::string& UninterpretedOption::identifier_value() const { +const ::std::string& UninterpretedOption::identifier_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value) return identifier_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption::set_identifier_value(const ::std::string& value) { +void UninterpretedOption::set_identifier_value(const ::std::string& value) { set_has_identifier_value(); identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value) } - void UninterpretedOption::set_identifier_value(const char* value) { +void UninterpretedOption::set_identifier_value(const char* value) { set_has_identifier_value(); identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.identifier_value) } - void UninterpretedOption::set_identifier_value(const char* value, size_t size) { +void UninterpretedOption::set_identifier_value(const char* value, size_t size) { set_has_identifier_value(); identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.identifier_value) } - ::std::string* UninterpretedOption::mutable_identifier_value() { +::std::string* UninterpretedOption::mutable_identifier_value() { set_has_identifier_value(); // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.identifier_value) return identifier_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* UninterpretedOption::release_identifier_value() { +::std::string* UninterpretedOption::release_identifier_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.identifier_value) clear_has_identifier_value(); return identifier_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption::set_allocated_identifier_value(::std::string* identifier_value) { +void UninterpretedOption::set_allocated_identifier_value(::std::string* identifier_value) { if (identifier_value != NULL) { set_has_identifier_value(); } else { @@ -13692,11 +13803,11 @@ void UninterpretedOption::clear_positive_int_value() { positive_int_value_ = GOOGLE_ULONGLONG(0); clear_has_positive_int_value(); } - ::google::protobuf::uint64 UninterpretedOption::positive_int_value() const { +::google::protobuf::uint64 UninterpretedOption::positive_int_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.positive_int_value) return positive_int_value_; } - void UninterpretedOption::set_positive_int_value(::google::protobuf::uint64 value) { +void UninterpretedOption::set_positive_int_value(::google::protobuf::uint64 value) { set_has_positive_int_value(); positive_int_value_ = value; // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.positive_int_value) @@ -13716,11 +13827,11 @@ void UninterpretedOption::clear_negative_int_value() { negative_int_value_ = GOOGLE_LONGLONG(0); clear_has_negative_int_value(); } - ::google::protobuf::int64 UninterpretedOption::negative_int_value() const { +::google::protobuf::int64 UninterpretedOption::negative_int_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.negative_int_value) return negative_int_value_; } - void UninterpretedOption::set_negative_int_value(::google::protobuf::int64 value) { +void UninterpretedOption::set_negative_int_value(::google::protobuf::int64 value) { set_has_negative_int_value(); negative_int_value_ = value; // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.negative_int_value) @@ -13740,11 +13851,11 @@ void UninterpretedOption::clear_double_value() { double_value_ = 0; clear_has_double_value(); } - double UninterpretedOption::double_value() const { +double UninterpretedOption::double_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.double_value) return double_value_; } - void UninterpretedOption::set_double_value(double value) { +void UninterpretedOption::set_double_value(double value) { set_has_double_value(); double_value_ = value; // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.double_value) @@ -13764,37 +13875,37 @@ void UninterpretedOption::clear_string_value() { string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_string_value(); } - const ::std::string& UninterpretedOption::string_value() const { +const ::std::string& UninterpretedOption::string_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value) return string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption::set_string_value(const ::std::string& value) { +void UninterpretedOption::set_string_value(const ::std::string& value) { set_has_string_value(); string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value) } - void UninterpretedOption::set_string_value(const char* value) { +void UninterpretedOption::set_string_value(const char* value) { set_has_string_value(); string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.string_value) } - void UninterpretedOption::set_string_value(const void* value, size_t size) { +void UninterpretedOption::set_string_value(const void* value, size_t size) { set_has_string_value(); string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.string_value) } - ::std::string* UninterpretedOption::mutable_string_value() { +::std::string* UninterpretedOption::mutable_string_value() { set_has_string_value(); // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.string_value) return string_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* UninterpretedOption::release_string_value() { +::std::string* UninterpretedOption::release_string_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.string_value) clear_has_string_value(); return string_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption::set_allocated_string_value(::std::string* string_value) { +void UninterpretedOption::set_allocated_string_value(::std::string* string_value) { if (string_value != NULL) { set_has_string_value(); } else { @@ -13818,37 +13929,37 @@ void UninterpretedOption::clear_aggregate_value() { aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_aggregate_value(); } - const ::std::string& UninterpretedOption::aggregate_value() const { +const ::std::string& UninterpretedOption::aggregate_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value) return aggregate_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption::set_aggregate_value(const ::std::string& value) { +void UninterpretedOption::set_aggregate_value(const ::std::string& value) { set_has_aggregate_value(); aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value) } - void UninterpretedOption::set_aggregate_value(const char* value) { +void UninterpretedOption::set_aggregate_value(const char* value) { set_has_aggregate_value(); aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.aggregate_value) } - void UninterpretedOption::set_aggregate_value(const char* value, size_t size) { +void UninterpretedOption::set_aggregate_value(const char* value, size_t size) { set_has_aggregate_value(); aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.aggregate_value) } - ::std::string* UninterpretedOption::mutable_aggregate_value() { +::std::string* UninterpretedOption::mutable_aggregate_value() { set_has_aggregate_value(); // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.aggregate_value) return aggregate_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* UninterpretedOption::release_aggregate_value() { +::std::string* UninterpretedOption::release_aggregate_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.aggregate_value) clear_has_aggregate_value(); return aggregate_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void UninterpretedOption::set_allocated_aggregate_value(::std::string* aggregate_value) { +void UninterpretedOption::set_allocated_aggregate_value(::std::string* aggregate_value) { if (aggregate_value != NULL) { set_has_aggregate_value(); } else { @@ -13872,6 +13983,7 @@ const int SourceCodeInfo_Location::kLeadingDetachedCommentsFieldNumber; SourceCodeInfo_Location::SourceCodeInfo_Location() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo.Location) } @@ -13883,16 +13995,14 @@ SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location) } void SourceCodeInfo_Location::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; leading_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); trailing_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } SourceCodeInfo_Location::~SourceCodeInfo_Location() { @@ -13903,8 +14013,6 @@ SourceCodeInfo_Location::~SourceCodeInfo_Location() { void SourceCodeInfo_Location::SharedDtor() { leading_comments_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); trailing_comments_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void SourceCodeInfo_Location::SetCachedSize(int size) const { @@ -13918,11 +14026,11 @@ const ::google::protobuf::Descriptor* SourceCodeInfo_Location::descriptor() { } const SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -SourceCodeInfo_Location* SourceCodeInfo_Location::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed SourceCodeInfo_Location::default_instance_; SourceCodeInfo_Location* SourceCodeInfo_Location::New(::google::protobuf::Arena* arena) const { SourceCodeInfo_Location* n = new SourceCodeInfo_Location; @@ -13945,7 +14053,7 @@ void SourceCodeInfo_Location::Clear() { path_.Clear(); span_.Clear(); leading_detached_comments_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -14203,9 +14311,9 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( return target; } -int SourceCodeInfo_Location::ByteSize() const { +size_t SourceCodeInfo_Location::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo.Location) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[2 / 32] & 12u) { // optional string leading_comments = 3; @@ -14225,8 +14333,9 @@ int SourceCodeInfo_Location::ByteSize() const { } // repeated int32 path = 1 [packed = true]; { - int data_size = 0; - for (int i = 0; i < this->path_size(); i++) { + size_t data_size = 0; + unsigned int count = this->path_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int32Size(this->path(i)); } @@ -14234,16 +14343,18 @@ int SourceCodeInfo_Location::ByteSize() const { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); } + int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _path_cached_byte_size_ = data_size; + _path_cached_byte_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); total_size += data_size; } // repeated int32 span = 2 [packed = true]; { - int data_size = 0; - for (int i = 0; i < this->span_size(); i++) { + size_t data_size = 0; + unsigned int count = this->span_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int32Size(this->span(i)); } @@ -14251,14 +14362,16 @@ int SourceCodeInfo_Location::ByteSize() const { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); } + int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _span_cached_byte_size_ = data_size; + _span_cached_byte_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); total_size += data_size; } // repeated string leading_detached_comments = 6; - total_size += 1 * this->leading_detached_comments_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->leading_detached_comments_size()); for (int i = 0; i < this->leading_detached_comments_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->leading_detached_comments(i)); @@ -14269,18 +14382,17 @@ int SourceCodeInfo_Location::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void SourceCodeInfo_Location::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo.Location) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const SourceCodeInfo_Location* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const SourceCodeInfo_Location* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -14288,18 +14400,24 @@ void SourceCodeInfo_Location::MergeFrom(const ::google::protobuf::Message& from) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo.Location) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } - path_.MergeFrom(from.path_); - span_.MergeFrom(from.span_); - leading_detached_comments_.MergeFrom(from.leading_detached_comments_); +} + +void SourceCodeInfo_Location::UnsafeMergeFrom(const SourceCodeInfo_Location& from) { + GOOGLE_DCHECK(&from != this); + path_.UnsafeMergeFrom(from.path_); + span_.UnsafeMergeFrom(from.span_); + leading_detached_comments_.UnsafeMergeFrom(from.leading_detached_comments_); if (from._has_bits_[2 / 32] & (0xffu << (2 % 32))) { if (from.has_leading_comments()) { set_has_leading_comments(); @@ -14311,7 +14429,8 @@ void SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) { } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -14326,7 +14445,7 @@ void SourceCodeInfo_Location::CopyFrom(const SourceCodeInfo_Location& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo.Location) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool SourceCodeInfo_Location::IsInitialized() const { @@ -14366,6 +14485,7 @@ const int SourceCodeInfo::kLocationFieldNumber; SourceCodeInfo::SourceCodeInfo() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo) } @@ -14377,13 +14497,12 @@ SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo) } void SourceCodeInfo::SharedCtor() { _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } SourceCodeInfo::~SourceCodeInfo() { @@ -14392,8 +14511,6 @@ SourceCodeInfo::~SourceCodeInfo() { } void SourceCodeInfo::SharedDtor() { - if (this != default_instance_) { - } } void SourceCodeInfo::SetCachedSize(int size) const { @@ -14407,11 +14524,11 @@ const ::google::protobuf::Descriptor* SourceCodeInfo::descriptor() { } const SourceCodeInfo& SourceCodeInfo::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -SourceCodeInfo* SourceCodeInfo::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed SourceCodeInfo::default_instance_; SourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const { SourceCodeInfo* n = new SourceCodeInfo; @@ -14424,7 +14541,7 @@ SourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const { void SourceCodeInfo::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo) location_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -14513,16 +14630,19 @@ void SourceCodeInfo::SerializeWithCachedSizes( return target; } -int SourceCodeInfo::ByteSize() const { +size_t SourceCodeInfo::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo) - int total_size = 0; + size_t total_size = 0; // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - total_size += 1 * this->location_size(); - for (int i = 0; i < this->location_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->location(i)); + { + unsigned int count = this->location_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->location(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -14530,18 +14650,17 @@ int SourceCodeInfo::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void SourceCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const SourceCodeInfo* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const SourceCodeInfo* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -14549,18 +14668,25 @@ void SourceCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void SourceCodeInfo::MergeFrom(const SourceCodeInfo& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void SourceCodeInfo::UnsafeMergeFrom(const SourceCodeInfo& from) { + GOOGLE_DCHECK(&from != this); location_.MergeFrom(from.location_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -14575,7 +14701,7 @@ void SourceCodeInfo::CopyFrom(const SourceCodeInfo& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool SourceCodeInfo::IsInitialized() const { @@ -14612,24 +14738,24 @@ int SourceCodeInfo_Location::path_size() const { void SourceCodeInfo_Location::clear_path() { path_.Clear(); } - ::google::protobuf::int32 SourceCodeInfo_Location::path(int index) const { +::google::protobuf::int32 SourceCodeInfo_Location::path(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.path) return path_.Get(index); } - void SourceCodeInfo_Location::set_path(int index, ::google::protobuf::int32 value) { +void SourceCodeInfo_Location::set_path(int index, ::google::protobuf::int32 value) { path_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.path) } - void SourceCodeInfo_Location::add_path(::google::protobuf::int32 value) { +void SourceCodeInfo_Location::add_path(::google::protobuf::int32 value) { path_.Add(value); // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.path) } - const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& SourceCodeInfo_Location::path() const { // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.path) return path_; } - ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* SourceCodeInfo_Location::mutable_path() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.path) return &path_; @@ -14642,24 +14768,24 @@ int SourceCodeInfo_Location::span_size() const { void SourceCodeInfo_Location::clear_span() { span_.Clear(); } - ::google::protobuf::int32 SourceCodeInfo_Location::span(int index) const { +::google::protobuf::int32 SourceCodeInfo_Location::span(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.span) return span_.Get(index); } - void SourceCodeInfo_Location::set_span(int index, ::google::protobuf::int32 value) { +void SourceCodeInfo_Location::set_span(int index, ::google::protobuf::int32 value) { span_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.span) } - void SourceCodeInfo_Location::add_span(::google::protobuf::int32 value) { +void SourceCodeInfo_Location::add_span(::google::protobuf::int32 value) { span_.Add(value); // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.span) } - const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& SourceCodeInfo_Location::span() const { // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.span) return span_; } - ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* SourceCodeInfo_Location::mutable_span() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.span) return &span_; @@ -14679,37 +14805,37 @@ void SourceCodeInfo_Location::clear_leading_comments() { leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_leading_comments(); } - const ::std::string& SourceCodeInfo_Location::leading_comments() const { +const ::std::string& SourceCodeInfo_Location::leading_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments) return leading_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) { +void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) { set_has_leading_comments(); leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments) } - void SourceCodeInfo_Location::set_leading_comments(const char* value) { +void SourceCodeInfo_Location::set_leading_comments(const char* value) { set_has_leading_comments(); leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_comments) } - void SourceCodeInfo_Location::set_leading_comments(const char* value, size_t size) { +void SourceCodeInfo_Location::set_leading_comments(const char* value, size_t size) { set_has_leading_comments(); leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_comments) } - ::std::string* SourceCodeInfo_Location::mutable_leading_comments() { +::std::string* SourceCodeInfo_Location::mutable_leading_comments() { set_has_leading_comments(); // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.leading_comments) return leading_comments_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* SourceCodeInfo_Location::release_leading_comments() { +::std::string* SourceCodeInfo_Location::release_leading_comments() { // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.leading_comments) clear_has_leading_comments(); return leading_comments_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void SourceCodeInfo_Location::set_allocated_leading_comments(::std::string* leading_comments) { +void SourceCodeInfo_Location::set_allocated_leading_comments(::std::string* leading_comments) { if (leading_comments != NULL) { set_has_leading_comments(); } else { @@ -14733,37 +14859,37 @@ void SourceCodeInfo_Location::clear_trailing_comments() { trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_trailing_comments(); } - const ::std::string& SourceCodeInfo_Location::trailing_comments() const { +const ::std::string& SourceCodeInfo_Location::trailing_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments) return trailing_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) { +void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) { set_has_trailing_comments(); trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments) } - void SourceCodeInfo_Location::set_trailing_comments(const char* value) { +void SourceCodeInfo_Location::set_trailing_comments(const char* value) { set_has_trailing_comments(); trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.trailing_comments) } - void SourceCodeInfo_Location::set_trailing_comments(const char* value, size_t size) { +void SourceCodeInfo_Location::set_trailing_comments(const char* value, size_t size) { set_has_trailing_comments(); trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.trailing_comments) } - ::std::string* SourceCodeInfo_Location::mutable_trailing_comments() { +::std::string* SourceCodeInfo_Location::mutable_trailing_comments() { set_has_trailing_comments(); // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.trailing_comments) return trailing_comments_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* SourceCodeInfo_Location::release_trailing_comments() { +::std::string* SourceCodeInfo_Location::release_trailing_comments() { // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.trailing_comments) clear_has_trailing_comments(); return trailing_comments_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void SourceCodeInfo_Location::set_allocated_trailing_comments(::std::string* trailing_comments) { +void SourceCodeInfo_Location::set_allocated_trailing_comments(::std::string* trailing_comments) { if (trailing_comments != NULL) { set_has_trailing_comments(); } else { @@ -14780,49 +14906,49 @@ int SourceCodeInfo_Location::leading_detached_comments_size() const { void SourceCodeInfo_Location::clear_leading_detached_comments() { leading_detached_comments_.Clear(); } - const ::std::string& SourceCodeInfo_Location::leading_detached_comments(int index) const { +const ::std::string& SourceCodeInfo_Location::leading_detached_comments(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) return leading_detached_comments_.Get(index); } - ::std::string* SourceCodeInfo_Location::mutable_leading_detached_comments(int index) { +::std::string* SourceCodeInfo_Location::mutable_leading_detached_comments(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) return leading_detached_comments_.Mutable(index); } - void SourceCodeInfo_Location::set_leading_detached_comments(int index, const ::std::string& value) { +void SourceCodeInfo_Location::set_leading_detached_comments(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) leading_detached_comments_.Mutable(index)->assign(value); } - void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) { +void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) { leading_detached_comments_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } - void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value, size_t size) { +void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value, size_t size) { leading_detached_comments_.Mutable(index)->assign( reinterpret_cast(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } - ::std::string* SourceCodeInfo_Location::add_leading_detached_comments() { +::std::string* SourceCodeInfo_Location::add_leading_detached_comments() { // @@protoc_insertion_point(field_add_mutable:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) return leading_detached_comments_.Add(); } - void SourceCodeInfo_Location::add_leading_detached_comments(const ::std::string& value) { +void SourceCodeInfo_Location::add_leading_detached_comments(const ::std::string& value) { leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } - void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) { +void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) { leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } - void SourceCodeInfo_Location::add_leading_detached_comments(const char* value, size_t size) { +void SourceCodeInfo_Location::add_leading_detached_comments(const char* value, size_t size) { leading_detached_comments_.Add()->assign(reinterpret_cast(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } - const ::google::protobuf::RepeatedPtrField< ::std::string>& +const ::google::protobuf::RepeatedPtrField< ::std::string>& SourceCodeInfo_Location::leading_detached_comments() const { // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) return leading_detached_comments_; } - ::google::protobuf::RepeatedPtrField< ::std::string>* +::google::protobuf::RepeatedPtrField< ::std::string>* SourceCodeInfo_Location::mutable_leading_detached_comments() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) return &leading_detached_comments_; @@ -14875,6 +15001,7 @@ const int GeneratedCodeInfo_Annotation::kEndFieldNumber; GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo.Annotation) } @@ -14886,17 +15013,15 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeIn : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo.Annotation) } void GeneratedCodeInfo_Annotation::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; source_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - begin_ = 0; - end_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&begin_, 0, reinterpret_cast(&end_) - + reinterpret_cast(&begin_) + sizeof(end_)); } GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() { @@ -14906,8 +15031,6 @@ GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() { void GeneratedCodeInfo_Annotation::SharedDtor() { source_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const { @@ -14921,11 +15044,11 @@ const ::google::protobuf::Descriptor* GeneratedCodeInfo_Annotation::descriptor() } const GeneratedCodeInfo_Annotation& GeneratedCodeInfo_Annotation::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed GeneratedCodeInfo_Annotation::default_instance_; GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::New(::google::protobuf::Arena* arena) const { GeneratedCodeInfo_Annotation* n = new GeneratedCodeInfo_Annotation; @@ -14964,7 +15087,7 @@ void GeneratedCodeInfo_Annotation::Clear() { #undef ZR_ path_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -15018,10 +15141,10 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_begin: + set_has_begin(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &begin_))); - set_has_begin(); } else { goto handle_unusual; } @@ -15033,10 +15156,10 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( case 4: { if (tag == 32) { parse_end: + set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &end_))); - set_has_end(); } else { goto handle_unusual; } @@ -15153,9 +15276,9 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes( return target; } -int GeneratedCodeInfo_Annotation::ByteSize() const { +size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo.Annotation) - int total_size = 0; + size_t total_size = 0; if (_has_bits_[1 / 32] & 14u) { // optional string source_file = 2; @@ -15182,8 +15305,9 @@ int GeneratedCodeInfo_Annotation::ByteSize() const { } // repeated int32 path = 1 [packed = true]; { - int data_size = 0; - for (int i = 0; i < this->path_size(); i++) { + size_t data_size = 0; + unsigned int count = this->path_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int32Size(this->path(i)); } @@ -15191,8 +15315,9 @@ int GeneratedCodeInfo_Annotation::ByteSize() const { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); } + int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _path_cached_byte_size_ = data_size; + _path_cached_byte_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); total_size += data_size; } @@ -15202,18 +15327,17 @@ int GeneratedCodeInfo_Annotation::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void GeneratedCodeInfo_Annotation::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const GeneratedCodeInfo_Annotation* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const GeneratedCodeInfo_Annotation* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -15221,16 +15345,22 @@ void GeneratedCodeInfo_Annotation::MergeFrom(const ::google::protobuf::Message& ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.GeneratedCodeInfo.Annotation) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void GeneratedCodeInfo_Annotation::MergeFrom(const GeneratedCodeInfo_Annotation& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } - path_.MergeFrom(from.path_); +} + +void GeneratedCodeInfo_Annotation::UnsafeMergeFrom(const GeneratedCodeInfo_Annotation& from) { + GOOGLE_DCHECK(&from != this); + path_.UnsafeMergeFrom(from.path_); if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) { if (from.has_source_file()) { set_has_source_file(); @@ -15244,7 +15374,8 @@ void GeneratedCodeInfo_Annotation::MergeFrom(const GeneratedCodeInfo_Annotation& } } if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -15259,7 +15390,7 @@ void GeneratedCodeInfo_Annotation::CopyFrom(const GeneratedCodeInfo_Annotation& // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo.Annotation) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool GeneratedCodeInfo_Annotation::IsInitialized() const { @@ -15298,6 +15429,7 @@ const int GeneratedCodeInfo::kAnnotationFieldNumber; GeneratedCodeInfo::GeneratedCodeInfo() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo) } @@ -15309,13 +15441,12 @@ GeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo) } void GeneratedCodeInfo::SharedCtor() { _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } GeneratedCodeInfo::~GeneratedCodeInfo() { @@ -15324,8 +15455,6 @@ GeneratedCodeInfo::~GeneratedCodeInfo() { } void GeneratedCodeInfo::SharedDtor() { - if (this != default_instance_) { - } } void GeneratedCodeInfo::SetCachedSize(int size) const { @@ -15339,11 +15468,11 @@ const ::google::protobuf::Descriptor* GeneratedCodeInfo::descriptor() { } const GeneratedCodeInfo& GeneratedCodeInfo::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); } -GeneratedCodeInfo* GeneratedCodeInfo::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed GeneratedCodeInfo::default_instance_; GeneratedCodeInfo* GeneratedCodeInfo::New(::google::protobuf::Arena* arena) const { GeneratedCodeInfo* n = new GeneratedCodeInfo; @@ -15356,7 +15485,7 @@ GeneratedCodeInfo* GeneratedCodeInfo::New(::google::protobuf::Arena* arena) cons void GeneratedCodeInfo::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo) annotation_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _has_bits_.Clear(); if (_internal_metadata_.have_unknown_fields()) { mutable_unknown_fields()->Clear(); } @@ -15445,16 +15574,19 @@ void GeneratedCodeInfo::SerializeWithCachedSizes( return target; } -int GeneratedCodeInfo::ByteSize() const { +size_t GeneratedCodeInfo::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo) - int total_size = 0; + size_t total_size = 0; // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; - total_size += 1 * this->annotation_size(); - for (int i = 0; i < this->annotation_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->annotation(i)); + { + unsigned int count = this->annotation_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->annotation(i)); + } } if (_internal_metadata_.have_unknown_fields()) { @@ -15462,18 +15594,17 @@ int GeneratedCodeInfo::ByteSize() const { ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void GeneratedCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.GeneratedCodeInfo) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const GeneratedCodeInfo* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const GeneratedCodeInfo* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -15481,18 +15612,25 @@ void GeneratedCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.GeneratedCodeInfo) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void GeneratedCodeInfo::MergeFrom(const GeneratedCodeInfo& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void GeneratedCodeInfo::UnsafeMergeFrom(const GeneratedCodeInfo& from) { + GOOGLE_DCHECK(&from != this); annotation_.MergeFrom(from.annotation_); if (from._internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } } @@ -15507,7 +15645,7 @@ void GeneratedCodeInfo::CopyFrom(const GeneratedCodeInfo& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool GeneratedCodeInfo::IsInitialized() const { @@ -15544,24 +15682,24 @@ int GeneratedCodeInfo_Annotation::path_size() const { void GeneratedCodeInfo_Annotation::clear_path() { path_.Clear(); } - ::google::protobuf::int32 GeneratedCodeInfo_Annotation::path(int index) const { +::google::protobuf::int32 GeneratedCodeInfo_Annotation::path(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.path) return path_.Get(index); } - void GeneratedCodeInfo_Annotation::set_path(int index, ::google::protobuf::int32 value) { +void GeneratedCodeInfo_Annotation::set_path(int index, ::google::protobuf::int32 value) { path_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path) } - void GeneratedCodeInfo_Annotation::add_path(::google::protobuf::int32 value) { +void GeneratedCodeInfo_Annotation::add_path(::google::protobuf::int32 value) { path_.Add(value); // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.Annotation.path) } - const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& GeneratedCodeInfo_Annotation::path() const { // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.Annotation.path) return path_; } - ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* GeneratedCodeInfo_Annotation::mutable_path() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.Annotation.path) return &path_; @@ -15581,37 +15719,37 @@ void GeneratedCodeInfo_Annotation::clear_source_file() { source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_source_file(); } - const ::std::string& GeneratedCodeInfo_Annotation::source_file() const { +const ::std::string& GeneratedCodeInfo_Annotation::source_file() const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file) return source_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) { +void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) { set_has_source_file(); source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } - void GeneratedCodeInfo_Annotation::set_source_file(const char* value) { +void GeneratedCodeInfo_Annotation::set_source_file(const char* value) { set_has_source_file(); source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } - void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) { +void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) { set_has_source_file(); source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } - ::std::string* GeneratedCodeInfo_Annotation::mutable_source_file() { +::std::string* GeneratedCodeInfo_Annotation::mutable_source_file() { set_has_source_file(); // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.Annotation.source_file) return source_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* GeneratedCodeInfo_Annotation::release_source_file() { +::std::string* GeneratedCodeInfo_Annotation::release_source_file() { // @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file) clear_has_source_file(); return source_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::string* source_file) { +void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::string* source_file) { if (source_file != NULL) { set_has_source_file(); } else { @@ -15635,11 +15773,11 @@ void GeneratedCodeInfo_Annotation::clear_begin() { begin_ = 0; clear_has_begin(); } - ::google::protobuf::int32 GeneratedCodeInfo_Annotation::begin() const { +::google::protobuf::int32 GeneratedCodeInfo_Annotation::begin() const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.begin) return begin_; } - void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 value) { +void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 value) { set_has_begin(); begin_ = value; // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.begin) @@ -15659,11 +15797,11 @@ void GeneratedCodeInfo_Annotation::clear_end() { end_ = 0; clear_has_end(); } - ::google::protobuf::int32 GeneratedCodeInfo_Annotation::end() const { +::google::protobuf::int32 GeneratedCodeInfo_Annotation::end() const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.end) return end_; } - void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 value) { +void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 value) { set_has_end(); end_ = value; // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end) diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index f5f97f37..13f60520 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -35,6 +35,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); @@ -204,6 +205,10 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message static const ::google::protobuf::Descriptor* descriptor(); static const FileDescriptorSet& default_instance(); + static inline const FileDescriptorSet* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(FileDescriptorSet* other); // implements Message ---------------------------------------------- @@ -218,7 +223,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -234,6 +239,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(FileDescriptorSet* other); + void UnsafeMergeFrom(const FileDescriptorSet& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -265,15 +271,16 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > file_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static FileDescriptorSet* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -300,6 +307,10 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const FileDescriptorProto& default_instance(); + static inline const FileDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(FileDescriptorProto* other); // implements Message ---------------------------------------------- @@ -314,7 +325,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -330,6 +341,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(FileDescriptorProto* other); + void UnsafeMergeFrom(const FileDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -501,10 +513,8 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag inline void clear_has_syntax(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::internal::ArenaStringPtr name_; - ::google::protobuf::internal::ArenaStringPtr package_; ::google::protobuf::RepeatedPtrField< ::std::string> dependency_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > public_dependency_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > weak_dependency_; @@ -512,15 +522,18 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto > enum_type_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto > service_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > extension_; + ::google::protobuf::internal::ArenaStringPtr name_; + ::google::protobuf::internal::ArenaStringPtr package_; + ::google::protobuf::internal::ArenaStringPtr syntax_; ::google::protobuf::FileOptions* options_; ::google::protobuf::SourceCodeInfo* source_code_info_; - ::google::protobuf::internal::ArenaStringPtr syntax_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static FileDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -547,6 +560,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto_ExtensionRange& default_instance(); + static inline const DescriptorProto_ExtensionRange* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(DescriptorProto_ExtensionRange* other); // implements Message ---------------------------------------------- @@ -561,7 +578,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -577,6 +594,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(DescriptorProto_ExtensionRange* other); + void UnsafeMergeFrom(const DescriptorProto_ExtensionRange& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -614,16 +632,17 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto inline void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::int32 start_; ::google::protobuf::int32 end_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static DescriptorProto_ExtensionRange* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -650,6 +669,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto_ReservedRange& default_instance(); + static inline const DescriptorProto_ReservedRange* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(DescriptorProto_ReservedRange* other); // implements Message ---------------------------------------------- @@ -664,7 +687,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -680,6 +703,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(DescriptorProto_ReservedRange* other); + void UnsafeMergeFrom(const DescriptorProto_ReservedRange& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -717,16 +741,17 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob inline void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::int32 start_; ::google::protobuf::int32 end_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static DescriptorProto_ReservedRange* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -753,6 +778,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto& default_instance(); + static inline const DescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(DescriptorProto* other); // implements Message ---------------------------------------------- @@ -767,7 +796,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -783,6 +812,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(DescriptorProto* other); + void UnsafeMergeFrom(const DescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -930,24 +960,25 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* inline void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > extension_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto > nested_type_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto > enum_type_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange > extension_range_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto > oneof_decl_; - ::google::protobuf::MessageOptions* options_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange > reserved_range_; ::google::protobuf::RepeatedPtrField< ::std::string> reserved_name_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + ::google::protobuf::internal::ArenaStringPtr name_; + ::google::protobuf::MessageOptions* options_; + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static DescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -974,6 +1005,10 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa static const ::google::protobuf::Descriptor* descriptor(); static const FieldDescriptorProto& default_instance(); + static inline const FieldDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(FieldDescriptorProto* other); // implements Message ---------------------------------------------- @@ -988,7 +1023,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1004,6 +1039,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(FieldDescriptorProto* other); + void UnsafeMergeFrom(const FieldDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -1226,24 +1262,25 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa inline void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; - ::google::protobuf::int32 number_; - int label_; ::google::protobuf::internal::ArenaStringPtr type_name_; ::google::protobuf::internal::ArenaStringPtr extendee_; - int type_; - ::google::protobuf::int32 oneof_index_; ::google::protobuf::internal::ArenaStringPtr default_value_; ::google::protobuf::internal::ArenaStringPtr json_name_; ::google::protobuf::FieldOptions* options_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + ::google::protobuf::int32 number_; + ::google::protobuf::int32 oneof_index_; + int label_; + int type_; + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static FieldDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -1270,6 +1307,10 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa static const ::google::protobuf::Descriptor* descriptor(); static const OneofDescriptorProto& default_instance(); + static inline const OneofDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(OneofDescriptorProto* other); // implements Message ---------------------------------------------- @@ -1284,7 +1325,7 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1300,6 +1341,7 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(OneofDescriptorProto* other); + void UnsafeMergeFrom(const OneofDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -1344,16 +1386,17 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa inline void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::OneofOptions* options_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static OneofDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -1380,6 +1423,10 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const EnumDescriptorProto& default_instance(); + static inline const EnumDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(EnumDescriptorProto* other); // implements Message ---------------------------------------------- @@ -1394,7 +1441,7 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1410,6 +1457,7 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(EnumDescriptorProto* other); + void UnsafeMergeFrom(const EnumDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -1466,17 +1514,18 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag inline void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto > value_; + ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::EnumOptions* options_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static EnumDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -1503,6 +1552,10 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M static const ::google::protobuf::Descriptor* descriptor(); static const EnumValueDescriptorProto& default_instance(); + static inline const EnumValueDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(EnumValueDescriptorProto* other); // implements Message ---------------------------------------------- @@ -1517,7 +1570,7 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1533,6 +1586,7 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(EnumValueDescriptorProto* other); + void UnsafeMergeFrom(const EnumValueDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -1586,17 +1640,18 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M inline void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::EnumValueOptions* options_; ::google::protobuf::int32 number_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static EnumValueDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -1623,6 +1678,10 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes static const ::google::protobuf::Descriptor* descriptor(); static const ServiceDescriptorProto& default_instance(); + static inline const ServiceDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(ServiceDescriptorProto* other); // implements Message ---------------------------------------------- @@ -1637,7 +1696,7 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1653,6 +1712,7 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(ServiceDescriptorProto* other); + void UnsafeMergeFrom(const ServiceDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -1709,17 +1769,18 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes inline void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto > method_; + ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::ServiceOptions* options_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static ServiceDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -1746,6 +1807,10 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess static const ::google::protobuf::Descriptor* descriptor(); static const MethodDescriptorProto& default_instance(); + static inline const MethodDescriptorProto* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(MethodDescriptorProto* other); // implements Message ---------------------------------------------- @@ -1760,7 +1825,7 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1776,6 +1841,7 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(MethodDescriptorProto* other); + void UnsafeMergeFrom(const MethodDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -1866,7 +1932,7 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess inline void clear_has_server_streaming(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr input_type_; @@ -1874,12 +1940,13 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess ::google::protobuf::MethodOptions* options_; bool client_streaming_; bool server_streaming_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static MethodDescriptorProto* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -1906,6 +1973,10 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const FileOptions& default_instance(); + static inline const FileOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(FileOptions* other); // implements Message ---------------------------------------------- @@ -1920,7 +1991,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -1936,6 +2007,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(FileOptions* other); + void UnsafeMergeFrom(const FileOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2010,13 +2082,6 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p bool java_multiple_files() const; void set_java_multiple_files(bool value); - // optional bool java_generate_equals_and_hash = 20 [default = false]; - bool has_java_generate_equals_and_hash() const; - void clear_java_generate_equals_and_hash(); - static const int kJavaGenerateEqualsAndHashFieldNumber = 20; - bool java_generate_equals_and_hash() const; - void set_java_generate_equals_and_hash(bool value); - // optional bool java_string_check_utf8 = 27 [default = false]; bool has_java_string_check_utf8() const; void clear_java_string_check_utf8(); @@ -2123,8 +2188,6 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p inline void clear_has_java_outer_classname(); inline void set_has_java_multiple_files(); inline void clear_has_java_multiple_files(); - inline void set_has_java_generate_equals_and_hash(); - inline void clear_has_java_generate_equals_and_hash(); inline void set_has_java_string_check_utf8(); inline void clear_has_java_string_check_utf8(); inline void set_has_optimize_for(); @@ -2149,29 +2212,29 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; ::google::protobuf::internal::ArenaStringPtr java_package_; ::google::protobuf::internal::ArenaStringPtr java_outer_classname_; - bool java_multiple_files_; - bool java_generate_equals_and_hash_; - bool java_string_check_utf8_; - bool cc_generic_services_; - int optimize_for_; ::google::protobuf::internal::ArenaStringPtr go_package_; ::google::protobuf::internal::ArenaStringPtr objc_class_prefix_; ::google::protobuf::internal::ArenaStringPtr csharp_namespace_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; + bool java_multiple_files_; + bool java_string_check_utf8_; + bool cc_generic_services_; bool java_generic_services_; bool py_generic_services_; bool deprecated_; bool cc_enable_arenas_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + int optimize_for_; + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static FileOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -2198,6 +2261,10 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const MessageOptions& default_instance(); + static inline const MessageOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(MessageOptions* other); // implements Message ---------------------------------------------- @@ -2212,7 +2279,7 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -2228,6 +2295,7 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(MessageOptions* other); + void UnsafeMergeFrom(const MessageOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2298,19 +2366,20 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool message_set_wire_format_; bool no_standard_descriptor_accessor_; bool deprecated_; bool map_entry_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static MessageOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -2337,6 +2406,10 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ static const ::google::protobuf::Descriptor* descriptor(); static const FieldOptions& default_instance(); + static inline const FieldOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(FieldOptions* other); // implements Message ---------------------------------------------- @@ -2351,7 +2424,7 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -2367,6 +2440,7 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(FieldOptions* other); + void UnsafeMergeFrom(const FieldOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2511,21 +2585,22 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; int ctype_; int jstype_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool packed_; bool lazy_; bool deprecated_; bool weak_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static FieldOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -2552,6 +2627,10 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ static const ::google::protobuf::Descriptor* descriptor(); static const OneofOptions& default_instance(); + static inline const OneofOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(OneofOptions* other); // implements Message ---------------------------------------------- @@ -2566,7 +2645,7 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -2582,6 +2661,7 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(OneofOptions* other); + void UnsafeMergeFrom(const OneofOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2616,15 +2696,16 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static OneofOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -2651,6 +2732,10 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const EnumOptions& default_instance(); + static inline const EnumOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(EnumOptions* other); // implements Message ---------------------------------------------- @@ -2665,7 +2750,7 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -2681,6 +2766,7 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(EnumOptions* other); + void UnsafeMergeFrom(const EnumOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2733,17 +2819,18 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool allow_alias_; bool deprecated_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static EnumOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -2770,6 +2857,10 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / static const ::google::protobuf::Descriptor* descriptor(); static const EnumValueOptions& default_instance(); + static inline const EnumValueOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(EnumValueOptions* other); // implements Message ---------------------------------------------- @@ -2784,7 +2875,7 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -2800,6 +2891,7 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(EnumValueOptions* other); + void UnsafeMergeFrom(const EnumValueOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2843,16 +2935,17 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static EnumValueOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -2879,6 +2972,10 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const ServiceOptions& default_instance(); + static inline const ServiceOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(ServiceOptions* other); // implements Message ---------------------------------------------- @@ -2893,7 +2990,7 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -2909,6 +3006,7 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(ServiceOptions* other); + void UnsafeMergeFrom(const ServiceOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -2952,16 +3050,17 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static ServiceOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -2988,6 +3087,10 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ static const ::google::protobuf::Descriptor* descriptor(); static const MethodOptions& default_instance(); + static inline const MethodOptions* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(MethodOptions* other); // implements Message ---------------------------------------------- @@ -3002,7 +3105,7 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3018,6 +3121,7 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(MethodOptions* other); + void UnsafeMergeFrom(const MethodOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3061,16 +3165,17 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ ::google::protobuf::internal::ExtensionSet _extensions_; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static MethodOptions* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -3097,6 +3202,10 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu static const ::google::protobuf::Descriptor* descriptor(); static const UninterpretedOption_NamePart& default_instance(); + static inline const UninterpretedOption_NamePart* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(UninterpretedOption_NamePart* other); // implements Message ---------------------------------------------- @@ -3111,7 +3220,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3127,6 +3236,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(UninterpretedOption_NamePart* other); + void UnsafeMergeFrom(const UninterpretedOption_NamePart& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3168,20 +3278,21 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu inline void set_has_is_extension(); inline void clear_has_is_extension(); - // helper for ByteSize() - int RequiredFieldsByteSizeFallback() const; + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_part_; bool is_extension_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static UninterpretedOption_NamePart* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -3208,6 +3319,10 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const UninterpretedOption& default_instance(); + static inline const UninterpretedOption* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(UninterpretedOption* other); // implements Message ---------------------------------------------- @@ -3222,7 +3337,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3238,6 +3353,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(UninterpretedOption* other); + void UnsafeMergeFrom(const UninterpretedOption& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3340,21 +3456,22 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag inline void clear_has_aggregate_value(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart > name_; ::google::protobuf::internal::ArenaStringPtr identifier_value_; + ::google::protobuf::internal::ArenaStringPtr string_value_; + ::google::protobuf::internal::ArenaStringPtr aggregate_value_; ::google::protobuf::uint64 positive_int_value_; ::google::protobuf::int64 negative_int_value_; double double_value_; - ::google::protobuf::internal::ArenaStringPtr string_value_; - ::google::protobuf::internal::ArenaStringPtr aggregate_value_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static UninterpretedOption* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -3381,6 +3498,10 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me static const ::google::protobuf::Descriptor* descriptor(); static const SourceCodeInfo_Location& default_instance(); + static inline const SourceCodeInfo_Location* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(SourceCodeInfo_Location* other); // implements Message ---------------------------------------------- @@ -3395,7 +3516,7 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3411,6 +3532,7 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(SourceCodeInfo_Location* other); + void UnsafeMergeFrom(const SourceCodeInfo_Location& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3498,21 +3620,22 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me inline void clear_has_trailing_comments(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > path_; mutable int _path_cached_byte_size_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > span_; mutable int _span_cached_byte_size_; + ::google::protobuf::RepeatedPtrField< ::std::string> leading_detached_comments_; ::google::protobuf::internal::ArenaStringPtr leading_comments_; ::google::protobuf::internal::ArenaStringPtr trailing_comments_; - ::google::protobuf::RepeatedPtrField< ::std::string> leading_detached_comments_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static SourceCodeInfo_Location* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -3539,6 +3662,10 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const SourceCodeInfo& default_instance(); + static inline const SourceCodeInfo* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(SourceCodeInfo* other); // implements Message ---------------------------------------------- @@ -3553,7 +3680,7 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3569,6 +3696,7 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(SourceCodeInfo* other); + void UnsafeMergeFrom(const SourceCodeInfo& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3602,15 +3730,16 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location > location_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static SourceCodeInfo* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -3637,6 +3766,10 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu static const ::google::protobuf::Descriptor* descriptor(); static const GeneratedCodeInfo_Annotation& default_instance(); + static inline const GeneratedCodeInfo_Annotation* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(GeneratedCodeInfo_Annotation* other); // implements Message ---------------------------------------------- @@ -3651,7 +3784,7 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3667,6 +3800,7 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(GeneratedCodeInfo_Annotation* other); + void UnsafeMergeFrom(const GeneratedCodeInfo_Annotation& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3730,19 +3864,20 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu inline void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > path_; mutable int _path_cached_byte_size_; ::google::protobuf::internal::ArenaStringPtr source_file_; ::google::protobuf::int32 begin_; ::google::protobuf::int32 end_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static GeneratedCodeInfo_Annotation* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -3769,6 +3904,10 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message static const ::google::protobuf::Descriptor* descriptor(); static const GeneratedCodeInfo& default_instance(); + static inline const GeneratedCodeInfo* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(GeneratedCodeInfo* other); // implements Message ---------------------------------------------- @@ -3783,7 +3922,7 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -3799,6 +3938,7 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(GeneratedCodeInfo* other); + void UnsafeMergeFrom(const GeneratedCodeInfo& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -3832,15 +3972,16 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - ::google::protobuf::uint32 _has_bits_[1]; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation > annotation_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); void InitAsDefaultInstance(); - static GeneratedCodeInfo* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // =================================================================== @@ -4243,7 +4384,8 @@ inline void FileDescriptorProto::clear_options() { } inline const ::google::protobuf::FileOptions& FileDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::FileOptions::internal_default_instance(); } inline ::google::protobuf::FileOptions* FileDescriptorProto::mutable_options() { set_has_options(); @@ -4287,7 +4429,8 @@ inline void FileDescriptorProto::clear_source_code_info() { } inline const ::google::protobuf::SourceCodeInfo& FileDescriptorProto::source_code_info() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.source_code_info) - return source_code_info_ != NULL ? *source_code_info_ : *default_instance_->source_code_info_; + return source_code_info_ != NULL ? *source_code_info_ + : *::google::protobuf::SourceCodeInfo::internal_default_instance(); } inline ::google::protobuf::SourceCodeInfo* FileDescriptorProto::mutable_source_code_info() { set_has_source_code_info(); @@ -4727,7 +4870,8 @@ inline void DescriptorProto::clear_options() { } inline const ::google::protobuf::MessageOptions& DescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::MessageOptions::internal_default_instance(); } inline ::google::protobuf::MessageOptions* DescriptorProto::mutable_options() { set_has_options(); @@ -5228,7 +5372,8 @@ inline void FieldDescriptorProto::clear_options() { } inline const ::google::protobuf::FieldOptions& FieldDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::FieldOptions::internal_default_instance(); } inline ::google::protobuf::FieldOptions* FieldDescriptorProto::mutable_options() { set_has_options(); @@ -5330,7 +5475,8 @@ inline void OneofDescriptorProto::clear_options() { } inline const ::google::protobuf::OneofOptions& OneofDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::OneofOptions::internal_default_instance(); } inline ::google::protobuf::OneofOptions* OneofDescriptorProto::mutable_options() { set_has_options(); @@ -5462,7 +5608,8 @@ inline void EnumDescriptorProto::clear_options() { } inline const ::google::protobuf::EnumOptions& EnumDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::EnumOptions::internal_default_instance(); } inline ::google::protobuf::EnumOptions* EnumDescriptorProto::mutable_options() { set_has_options(); @@ -5588,7 +5735,8 @@ inline void EnumValueDescriptorProto::clear_options() { } inline const ::google::protobuf::EnumValueOptions& EnumValueDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::EnumValueOptions::internal_default_instance(); } inline ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::mutable_options() { set_has_options(); @@ -5720,7 +5868,8 @@ inline void ServiceDescriptorProto::clear_options() { } inline const ::google::protobuf::ServiceOptions& ServiceDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::ServiceOptions::internal_default_instance(); } inline ::google::protobuf::ServiceOptions* ServiceDescriptorProto::mutable_options() { set_has_options(); @@ -5930,7 +6079,8 @@ inline void MethodDescriptorProto::clear_options() { } inline const ::google::protobuf::MethodOptions& MethodDescriptorProto::options() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.options) - return options_ != NULL ? *options_ : *default_instance_->options_; + return options_ != NULL ? *options_ + : *::google::protobuf::MethodOptions::internal_default_instance(); } inline ::google::protobuf::MethodOptions* MethodDescriptorProto::mutable_options() { set_has_options(); @@ -6142,39 +6292,15 @@ inline void FileOptions::set_java_multiple_files(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_multiple_files) } -// optional bool java_generate_equals_and_hash = 20 [default = false]; -inline bool FileOptions::has_java_generate_equals_and_hash() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -inline void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000008u; -} -inline void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000008u; -} -inline void FileOptions::clear_java_generate_equals_and_hash() { - java_generate_equals_and_hash_ = false; - clear_has_java_generate_equals_and_hash(); -} -inline bool FileOptions::java_generate_equals_and_hash() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generate_equals_and_hash) - return java_generate_equals_and_hash_; -} -inline void FileOptions::set_java_generate_equals_and_hash(bool value) { - set_has_java_generate_equals_and_hash(); - java_generate_equals_and_hash_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generate_equals_and_hash) -} - // optional bool java_string_check_utf8 = 27 [default = false]; inline bool FileOptions::has_java_string_check_utf8() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } inline void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000008u; } inline void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000008u; } inline void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; @@ -6192,13 +6318,13 @@ inline void FileOptions::set_java_string_check_utf8(bool value) { // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; inline bool FileOptions::has_optimize_for() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } inline void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000010u; } inline void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000010u; } inline void FileOptions::clear_optimize_for() { optimize_for_ = 1; @@ -6217,13 +6343,13 @@ inline void FileOptions::set_optimize_for(::google::protobuf::FileOptions_Optimi // optional string go_package = 11; inline bool FileOptions::has_go_package() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } inline void FileOptions::set_has_go_package() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000020u; } inline void FileOptions::clear_has_go_package() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000020u; } inline void FileOptions::clear_go_package() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -6271,13 +6397,13 @@ inline void FileOptions::set_allocated_go_package(::std::string* go_package) { // optional bool cc_generic_services = 16 [default = false]; inline bool FileOptions::has_cc_generic_services() const { - return (_has_bits_[0] & 0x00000080u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } inline void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000040u; } inline void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000040u; } inline void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; @@ -6295,13 +6421,13 @@ inline void FileOptions::set_cc_generic_services(bool value) { // optional bool java_generic_services = 17 [default = false]; inline bool FileOptions::has_java_generic_services() const { - return (_has_bits_[0] & 0x00000100u) != 0; + return (_has_bits_[0] & 0x00000080u) != 0; } inline void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000080u; } inline void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000080u; } inline void FileOptions::clear_java_generic_services() { java_generic_services_ = false; @@ -6319,13 +6445,13 @@ inline void FileOptions::set_java_generic_services(bool value) { // optional bool py_generic_services = 18 [default = false]; inline bool FileOptions::has_py_generic_services() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000100u) != 0; } inline void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000100u; } inline void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000100u; } inline void FileOptions::clear_py_generic_services() { py_generic_services_ = false; @@ -6343,13 +6469,13 @@ inline void FileOptions::set_py_generic_services(bool value) { // optional bool deprecated = 23 [default = false]; inline bool FileOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00000200u) != 0; } inline void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00000200u; } inline void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00000200u; } inline void FileOptions::clear_deprecated() { deprecated_ = false; @@ -6367,13 +6493,13 @@ inline void FileOptions::set_deprecated(bool value) { // optional bool cc_enable_arenas = 31 [default = false]; inline bool FileOptions::has_cc_enable_arenas() const { - return (_has_bits_[0] & 0x00000800u) != 0; + return (_has_bits_[0] & 0x00000400u) != 0; } inline void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00000400u; } inline void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00000400u; } inline void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; @@ -6391,13 +6517,13 @@ inline void FileOptions::set_cc_enable_arenas(bool value) { // optional string objc_class_prefix = 36; inline bool FileOptions::has_objc_class_prefix() const { - return (_has_bits_[0] & 0x00001000u) != 0; + return (_has_bits_[0] & 0x00000800u) != 0; } inline void FileOptions::set_has_objc_class_prefix() { - _has_bits_[0] |= 0x00001000u; + _has_bits_[0] |= 0x00000800u; } inline void FileOptions::clear_has_objc_class_prefix() { - _has_bits_[0] &= ~0x00001000u; + _has_bits_[0] &= ~0x00000800u; } inline void FileOptions::clear_objc_class_prefix() { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -6445,13 +6571,13 @@ inline void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_cla // optional string csharp_namespace = 37; inline bool FileOptions::has_csharp_namespace() const { - return (_has_bits_[0] & 0x00002000u) != 0; + return (_has_bits_[0] & 0x00001000u) != 0; } inline void FileOptions::set_has_csharp_namespace() { - _has_bits_[0] |= 0x00002000u; + _has_bits_[0] |= 0x00001000u; } inline void FileOptions::clear_has_csharp_namespace() { - _has_bits_[0] &= ~0x00002000u; + _has_bits_[0] &= ~0x00001000u; } inline void FileOptions::clear_csharp_namespace() { csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index 28410d4a..23a9fe92 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -45,7 +45,6 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "DescriptorProtos"; option csharp_namespace = "Google.Protobuf.Reflection"; option objc_class_prefix = "GPB"; -option java_generate_equals_and_hash = true; // descriptor.proto must be optimized for speed because reflection-based // algorithms don't work during bootstrapping. @@ -306,19 +305,10 @@ message FileOptions { // top-level extensions defined in the file. optional bool java_multiple_files = 10 [default=false]; - // If set true, then the Java code generator will generate equals() and - // hashCode() methods for all messages defined in the .proto file. - // This increases generated code size, potentially substantially for large - // protos, which may harm a memory-constrained application. - // - In the full runtime this is a speed optimization, as the - // AbstractMessage base class includes reflection-based implementations of - // these methods. - // - In the lite runtime, setting this option changes the semantics of - // equals() and hashCode() to more closely match those of the full runtime; - // the generated methods compute their results based on field values rather - // than object identity. (Implementations should not assume that hashcodes - // will be consistent across runtimes or versions of the protocol compiler.) - optional bool java_generate_equals_and_hash = 20 [default=false]; + // BEGIN PROTOBUF-OPENSOURCE + // // This option does nothing. + // optional bool java_generate_equals_and_hash = 20 [deprecated=true]; + // END PROTOBUF-OPENSOURCE // If set true, then the Java2 code generator will generate code that // throws an exception whenever an attempt is made to assign a non-UTF-8 @@ -448,6 +438,8 @@ message MessageOptions { // Clients can define custom options in extensions of this message. See above. extensions 1000 to max; + + reserved 8; // javalite_serializable } message FieldOptions { @@ -471,7 +463,6 @@ message FieldOptions { // false will avoid using packed encoding. optional bool packed = 2; - // The jstype option determines the JavaScript type used for values of the // field. The option is permitted only for 64 bit integral and fixed types // (int64, uint64, sint64, fixed64, sfixed64). By default these types are @@ -512,7 +503,7 @@ message FieldOptions { // // // Note that implementations may choose not to check required fields within - // a lazy sub-message. That is, calling IsInitialized() on the outher message + // a lazy sub-message. That is, calling IsInitialized() on the outer message // may return true even if the inner message has missing required fields. // This is necessary because otherwise the inner message would have to be // parsed in order to perform the check, defeating the purpose of lazy @@ -538,6 +529,8 @@ message FieldOptions { // Clients can define custom options in extensions of this message. See above. extensions 1000 to max; + + reserved 4; // removed jtype } message OneofOptions { diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index 4183138f..07953416 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -773,9 +773,9 @@ TEST_F(DescriptorTest, FieldFullName) { TEST_F(DescriptorTest, FieldJsonName) { EXPECT_EQ("fieldName1", message4_->field(0)->json_name()); EXPECT_EQ("fieldName2", message4_->field(1)->json_name()); - EXPECT_EQ("fieldName3", message4_->field(2)->json_name()); - EXPECT_EQ("fieldName4", message4_->field(3)->json_name()); - EXPECT_EQ("fIELDNAME5", message4_->field(4)->json_name()); + EXPECT_EQ("FieldName3", message4_->field(2)->json_name()); + EXPECT_EQ("FieldName4", message4_->field(3)->json_name()); + EXPECT_EQ("FIELDNAME5", message4_->field(4)->json_name()); EXPECT_EQ("@type", message4_->field(5)->json_name()); DescriptorProto proto; @@ -793,10 +793,20 @@ TEST_F(DescriptorTest, FieldJsonName) { ASSERT_EQ(6, proto.field_size()); EXPECT_EQ("fieldName1", proto.field(0).json_name()); EXPECT_EQ("fieldName2", proto.field(1).json_name()); - EXPECT_EQ("fieldName3", proto.field(2).json_name()); - EXPECT_EQ("fieldName4", proto.field(3).json_name()); - EXPECT_EQ("fIELDNAME5", proto.field(4).json_name()); + EXPECT_EQ("FieldName3", proto.field(2).json_name()); + EXPECT_EQ("FieldName4", proto.field(3).json_name()); + EXPECT_EQ("FIELDNAME5", proto.field(4).json_name()); EXPECT_EQ("@type", proto.field(5).json_name()); + + // Test generated descriptor. + const Descriptor* generated = protobuf_unittest::TestJsonName::descriptor(); + ASSERT_EQ(6, generated->field_count()); + EXPECT_EQ("fieldName1", generated->field(0)->json_name()); + EXPECT_EQ("fieldName2", generated->field(1)->json_name()); + EXPECT_EQ("FieldName3", generated->field(2)->json_name()); + EXPECT_EQ("FieldName4", generated->field(3)->json_name()); + EXPECT_EQ("FIELDNAME5", generated->field(4)->json_name()); + EXPECT_EQ("@type", generated->field(5)->json_name()); } TEST_F(DescriptorTest, FieldFile) { @@ -5553,6 +5563,60 @@ TEST_F(ValidationErrorTest, MapEntryConflictsWithEnum) { "with an existing enum type.\n"); } +TEST_F(ValidationErrorTest, EnumValuesConflictWhenPrefixesStripped) { + BuildFileWithErrors( + "name: 'foo.proto' " + "enum_type {" + " name: 'FooEnum' " + " value { name: 'FOO_ENUM_BAZ' number: 0 }" + " value { name: 'BAZ' number: 1 }" + "}", + "foo.proto: BAZ: NAME: When enum name is stripped and label is " + "PascalCased (Baz), this value label conflicts with FOO_ENUM_BAZ\n"); + + BuildFileWithErrors( + "name: 'foo.proto' " + "enum_type {" + " name: 'FooEnum' " + " value { name: 'FOOENUM_BAZ' number: 0 }" + " value { name: 'BAZ' number: 1 }" + "}", + "foo.proto: BAZ: NAME: When enum name is stripped and label is " + "PascalCased (Baz), this value label conflicts with FOOENUM_BAZ\n"); + + BuildFileWithErrors( + "name: 'foo.proto' " + "enum_type {" + " name: 'FooEnum' " + " value { name: 'FOO_ENUM_BAR_BAZ' number: 0 }" + " value { name: 'BAR__BAZ' number: 1 }" + "}", + "foo.proto: BAR__BAZ: NAME: When enum name is stripped and label is " + "PascalCased (BarBaz), this value label conflicts with " + "FOO_ENUM_BAR_BAZ\n"); + + BuildFileWithErrors( + "name: 'foo.proto' " + "enum_type {" + " name: 'FooEnum' " + " value { name: 'FOO_ENUM__BAR_BAZ' number: 0 }" + " value { name: 'BAR_BAZ' number: 1 }" + "}", + "foo.proto: BAR_BAZ: NAME: When enum name is stripped and label is " + "PascalCased (BarBaz), this value label conflicts with " + "FOO_ENUM__BAR_BAZ\n"); + + // This isn't an error because the underscore will cause the PascalCase to + // differ by case (BarBaz vs. Barbaz). + BuildFile( + "name: 'foo.proto' " + "enum_type {" + " name: 'FooEnum' " + " value { name: 'BAR_BAZ' number: 0 }" + " value { name: 'BARBAZ' number: 1 }" + "}"); +} + TEST_F(ValidationErrorTest, MapEntryConflictsWithOneof) { FileDescriptorProto file_proto; FillValidMapEntry(&file_proto); diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index 884f6ccb..0e1be63c 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -44,20 +44,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto() { Duration_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Duration_descriptor_, - Duration::default_instance_, + Duration::internal_default_instance(), Duration_offsets_, -1, -1, -1, sizeof(Duration), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_)); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { +void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto); } @@ -66,37 +65,48 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Duration_descriptor_, &Duration::default_instance()); + Duration_descriptor_, Duration::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto() { - delete Duration::default_instance_; delete Duration_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + Duration::default_instance_.DefaultConstruct(); + Duration::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\036google/protobuf/duration.proto\022\017google" ".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r" "\n\005nanos\030\002 \001(\005B|\n\023com.google.protobufB\rDu" "rationProtoP\001Z*github.com/golang/protobu" - "f/ptypes/duration\240\001\001\242\002\003GPB\252\002\036Google.Prot" + "f/ptypes/duration\370\001\001\242\002\003GPB\252\002\036Google.Prot" "obuf.WellKnownTypesb\006proto3", 227); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/duration.proto", &protobuf_RegisterTypes); - Duration::default_instance_ = new Duration(); - Duration::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto() { @@ -104,6 +114,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fduration_2eproto_; +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; +static void MergeFromFail(int line) { + ::google::protobuf::internal::MergeFromFail(__FILE__, line); +} + +} // namespace + + // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -113,27 +133,36 @@ const int Duration::kNanosFieldNumber; Duration::Duration() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Duration) } +Duration::Duration(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Duration) +} void Duration::InitAsDefaultInstance() { - _is_default_instance_ = true; } Duration::Duration(const Duration& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Duration) } void Duration::SharedCtor() { - _is_default_instance_ = false; + ::memset(&seconds_, 0, reinterpret_cast(&nanos_) - + reinterpret_cast(&seconds_) + sizeof(nanos_)); _cached_size_ = 0; - seconds_ = GOOGLE_LONGLONG(0); - nanos_ = 0; } Duration::~Duration() { @@ -142,10 +171,19 @@ Duration::~Duration() { } void Duration::SharedDtor() { - if (this != default_instance_) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + } +void Duration::ArenaDtor(void* object) { + Duration* _this = reinterpret_cast< Duration* >(object); + (void)_this; +} +void Duration::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Duration::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -157,18 +195,14 @@ const ::google::protobuf::Descriptor* Duration::descriptor() { } const Duration& Duration::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); + return *internal_default_instance(); } -Duration* Duration::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Duration::default_instance_; Duration* Duration::New(::google::protobuf::Arena* arena) const { - Duration* n = new Duration; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage(arena); } void Duration::Clear() { @@ -209,10 +243,10 @@ bool Duration::MergePartialFromCodedStream( // optional int64 seconds = 1; case 1: { if (tag == 8) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( input, &seconds_))); - } else { goto handle_unusual; } @@ -224,10 +258,10 @@ bool Duration::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_nanos: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &nanos_))); - } else { goto handle_unusual; } @@ -290,9 +324,9 @@ void Duration::SerializeWithCachedSizes( return target; } -int Duration::ByteSize() const { +size_t Duration::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Duration) - int total_size = 0; + size_t total_size = 0; // optional int64 seconds = 1; if (this->seconds() != 0) { @@ -308,18 +342,17 @@ int Duration::ByteSize() const { this->nanos()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Duration::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Duration) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Duration* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Duration* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -327,15 +360,21 @@ void Duration::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Duration) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Duration::MergeFrom(const Duration& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Duration) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Duration::UnsafeMergeFrom(const Duration& from) { + GOOGLE_DCHECK(&from != this); if (from.seconds() != 0) { set_seconds(from.seconds()); } @@ -355,7 +394,7 @@ void Duration::CopyFrom(const Duration& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Duration) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Duration::IsInitialized() const { @@ -365,6 +404,18 @@ bool Duration::IsInitialized() const { void Duration::Swap(Duration* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + Duration temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void Duration::UnsafeArenaSwap(Duration* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void Duration::InternalSwap(Duration* other) { @@ -389,11 +440,11 @@ void Duration::InternalSwap(Duration* other) { void Duration::clear_seconds() { seconds_ = GOOGLE_LONGLONG(0); } - ::google::protobuf::int64 Duration::seconds() const { +::google::protobuf::int64 Duration::seconds() const { // @@protoc_insertion_point(field_get:google.protobuf.Duration.seconds) return seconds_; } - void Duration::set_seconds(::google::protobuf::int64 value) { +void Duration::set_seconds(::google::protobuf::int64 value) { seconds_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds) @@ -403,11 +454,11 @@ void Duration::clear_seconds() { void Duration::clear_nanos() { nanos_ = 0; } - ::google::protobuf::int32 Duration::nanos() const { +::google::protobuf::int32 Duration::nanos() const { // @@protoc_insertion_point(field_get:google.protobuf.Duration.nanos) return nanos_; } - void Duration::set_nanos(::google::protobuf::int32 value) { +void Duration::set_nanos(::google::protobuf::int32 value) { nanos_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos) diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index 44307347..fe135b1e 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -34,6 +34,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto(); @@ -53,9 +54,18 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot return *this; } + inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } + inline void* GetMaybeArenaPointer() const { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const Duration& default_instance(); + static inline const Duration* internal_default_instance() { + return &default_instance_.get(); + } + + void UnsafeArenaSwap(Duration* other); void Swap(Duration* other); // implements Message ---------------------------------------------- @@ -70,7 +80,7 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -86,6 +96,12 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Duration* other); + void UnsafeMergeFrom(const Duration& from); + protected: + explicit Duration(::google::protobuf::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -117,16 +133,19 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; + friend class ::google::protobuf::Arena; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::int64 seconds_; ::google::protobuf::int32 nanos_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto(); void InitAsDefaultInstance(); - static Duration* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/duration.proto b/src/google/protobuf/duration.proto index 96c1796d..7f461f40 100644 --- a/src/google/protobuf/duration.proto +++ b/src/google/protobuf/duration.proto @@ -33,11 +33,11 @@ syntax = "proto3"; package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option cc_enable_arenas = true; option go_package = "github.com/golang/protobuf/ptypes/duration"; option java_package = "com.google.protobuf"; option java_outer_classname = "DurationProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; // A Duration represents a signed, fixed-length span of time represented @@ -81,6 +81,12 @@ option objc_class_prefix = "GPB"; // end.nanos -= 1000000000; // } // +// Example 3: Compute Duration from datetime.timedelta in Python. +// +// td = datetime.timedelta(days=3, minutes=10) +// duration = Duration() +// duration.FromTimedelta(td) +// // message Duration { diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc index 5d914bf6..f51bc9d6 100644 --- a/src/google/protobuf/dynamic_message.cc +++ b/src/google/protobuf/dynamic_message.cc @@ -223,7 +223,6 @@ class DynamicMessage : public Message { int oneof_case_offset; int unknown_fields_offset; int extensions_offset; - int is_default_instance_offset; // Not owned by the TypeInfo. DynamicMessageFactory* factory; // The factory that created this object. @@ -332,11 +331,6 @@ void DynamicMessage::SharedCtor() { uint32(0); } - if (type_info_->is_default_instance_offset != -1) { - *reinterpret_cast( - OffsetToPointer(type_info_->is_default_instance_offset)) = false; - } - new(OffsetToPointer(type_info_->unknown_fields_offset)) UnknownFieldSet; if (type_info_->extensions_offset != -1) { @@ -556,14 +550,6 @@ void DynamicMessage::CrossLinkPrototypes() { factory->GetPrototypeNoLock(field->message_type()); } } - - // Set as the default instance -- this affects field-presence semantics for - // proto3. - if (type_info_->is_default_instance_offset != -1) { - void* is_default_instance_ptr = - OffsetToPointer(type_info_->is_default_instance_offset); - *reinterpret_cast(is_default_instance_ptr) = true; - } } Message* DynamicMessage::New() const { @@ -683,15 +669,6 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( size = AlignOffset(size); } - // The is_default_instance member, if any. - if (type->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) { - type_info->is_default_instance_offset = size; - size += sizeof(bool); - size = AlignOffset(size); - } else { - type_info->is_default_instance_offset = -1; - } - // The oneof_case, if any. It is an array of uint32s. if (type->oneof_decl_count() > 0) { type_info->oneof_case_offset = size; @@ -769,35 +746,18 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( ConstructDefaultOneofInstance(type_info->type, type_info->offsets.get(), type_info->default_oneof_instance); - type_info->reflection.reset( - new GeneratedMessageReflection( - type_info->type, - type_info->prototype, - type_info->offsets.get(), - type_info->has_bits_offset, - type_info->unknown_fields_offset, - type_info->extensions_offset, - type_info->default_oneof_instance, - type_info->oneof_case_offset, - type_info->pool, - this, - type_info->size, - -1 /* arena_offset */, - type_info->is_default_instance_offset)); + type_info->reflection.reset(new GeneratedMessageReflection( + type_info->type, type_info->prototype, type_info->offsets.get(), + type_info->has_bits_offset, type_info->unknown_fields_offset, + type_info->extensions_offset, type_info->default_oneof_instance, + type_info->oneof_case_offset, type_info->pool, this, type_info->size, + -1 /* arena_offset */)); } else { - type_info->reflection.reset( - new GeneratedMessageReflection( - type_info->type, - type_info->prototype, - type_info->offsets.get(), - type_info->has_bits_offset, - type_info->unknown_fields_offset, - type_info->extensions_offset, - type_info->pool, - this, - type_info->size, - -1 /* arena_offset */, - type_info->is_default_instance_offset)); + type_info->reflection.reset(new GeneratedMessageReflection( + type_info->type, type_info->prototype, type_info->offsets.get(), + type_info->has_bits_offset, type_info->unknown_fields_offset, + type_info->extensions_offset, type_info->pool, this, type_info->size, + -1 /* arena_offset */)); } // Cross link prototypes. prototype->CrossLinkPrototypes(); diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index 7ef97790..45bba99b 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -42,20 +42,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto() { Empty_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Empty_descriptor_, - Empty::default_instance_, + Empty::internal_default_instance(), Empty_offsets_, -1, -1, -1, sizeof(Empty), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_)); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { +void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto); } @@ -64,36 +63,47 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Empty_descriptor_, &Empty::default_instance()); + Empty_descriptor_, Empty::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto() { - delete Empty::default_instance_; delete Empty_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + Empty::default_instance_.DefaultConstruct(); + Empty::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\033google/protobuf/empty.proto\022\017google.pr" - "otobuf\"\007\n\005EmptyBy\n\023com.google.protobufB\n" + "otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n" "EmptyProtoP\001Z\'github.com/golang/protobuf" - "/ptypes/empty\240\001\001\370\001\001\242\002\003GPB\252\002\036Google.Proto" - "buf.WellKnownTypesb\006proto3", 186); + "/ptypes/empty\370\001\001\242\002\003GPB\252\002\036Google.Protobuf" + ".WellKnownTypesb\006proto3", 183); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/empty.proto", &protobuf_RegisterTypes); - Empty::default_instance_ = new Empty(); - Empty::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto() { @@ -101,6 +111,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fempty_2eproto_; +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; +static void MergeFromFail(int line) { + ::google::protobuf::internal::MergeFromFail(__FILE__, line); +} + +} // namespace + + // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -108,32 +128,33 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto { Empty::Empty() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Empty) } - Empty::Empty(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Empty) } void Empty::InitAsDefaultInstance() { - _is_default_instance_ = true; } Empty::Empty(const Empty& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Empty) } void Empty::SharedCtor() { - _is_default_instance_ = false; _cached_size_ = 0; } @@ -143,12 +164,11 @@ Empty::~Empty() { } void Empty::SharedDtor() { - if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { return; } - if (this != default_instance_) { - } } void Empty::ArenaDtor(void* object) { @@ -168,11 +188,11 @@ const ::google::protobuf::Descriptor* Empty::descriptor() { } const Empty& Empty::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); + return *internal_default_instance(); } -Empty* Empty::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Empty::default_instance_; Empty* Empty::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage(arena); @@ -222,22 +242,21 @@ void Empty::SerializeWithCachedSizes( return target; } -int Empty::ByteSize() const { +size_t Empty::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Empty) - int total_size = 0; + size_t total_size = 0; + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Empty::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Empty) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Empty* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Empty* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -245,17 +264,23 @@ void Empty::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Empty) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Empty::MergeFrom(const Empty& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Empty) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } } +void Empty::UnsafeMergeFrom(const Empty& from) { + GOOGLE_DCHECK(&from != this); +} + void Empty::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Empty) if (&from == this) return; @@ -267,7 +292,7 @@ void Empty::CopyFrom(const Empty& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Empty) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Empty::IsInitialized() const { @@ -281,7 +306,7 @@ void Empty::Swap(Empty* other) { InternalSwap(other); } else { Empty temp; - temp.MergeFrom(*this); + temp.UnsafeMergeFrom(*this); CopyFrom(*other); other->CopyFrom(temp); } diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index a4059fac..37b0c144 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -34,6 +34,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto(); @@ -60,6 +61,10 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ static const ::google::protobuf::Descriptor* descriptor(); static const Empty& default_instance(); + static inline const Empty* internal_default_instance() { + return &default_instance_.get(); + } + void UnsafeArenaSwap(Empty* other); void Swap(Empty* other); @@ -75,7 +80,7 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -91,6 +96,7 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Empty* other); + void UnsafeMergeFrom(const Empty& from); protected: explicit Empty(::google::protobuf::Arena* arena); private: @@ -118,14 +124,14 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool _is_default_instance_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto(); void InitAsDefaultInstance(); - static Empty* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/empty.proto b/src/google/protobuf/empty.proto index 37f4cd10..03cacd23 100644 --- a/src/google/protobuf/empty.proto +++ b/src/google/protobuf/empty.proto @@ -37,7 +37,6 @@ option go_package = "github.com/golang/protobuf/ptypes/empty"; option java_package = "com.google.protobuf"; option java_outer_classname = "EmptyProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; option cc_enable_arenas = true; diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc index 7d20a0f8..ad164e3e 100644 --- a/src/google/protobuf/extension_set.cc +++ b/src/google/protobuf/extension_set.cc @@ -1354,8 +1354,8 @@ void ExtensionSet::SerializeWithCachedSizes( } } -int ExtensionSet::ByteSize() const { - int total_size = 0; +size_t ExtensionSet::ByteSize() const { + size_t total_size = 0; for (ExtensionMap::const_iterator iter = extensions_.begin(); iter != extensions_.end(); ++iter) { @@ -1536,8 +1536,8 @@ void ExtensionSet::Extension::SerializeFieldWithCachedSizes( } } -int ExtensionSet::Extension::ByteSize(int number) const { - int result = 0; +size_t ExtensionSet::Extension::ByteSize(int number) const { + size_t result = 0; if (is_repeated) { if (is_packed) { @@ -1563,7 +1563,7 @@ int ExtensionSet::Extension::ByteSize(int number) const { #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ case WireFormatLite::TYPE_##UPPERCASE: \ result += WireFormatLite::k##CAMELCASE##Size * \ - repeated_##LOWERCASE##_value->size(); \ + FromIntSize(repeated_##LOWERCASE##_value->size()); \ break HANDLE_TYPE( FIXED32, Fixed32, uint32); HANDLE_TYPE( FIXED64, Fixed64, uint64); @@ -1582,7 +1582,7 @@ int ExtensionSet::Extension::ByteSize(int number) const { break; } - cached_size = result; + cached_size = ToCachedSize(result); if (result > 0) { result += io::CodedOutputStream::VarintSize32(result); result += io::CodedOutputStream::VarintSize32( @@ -1590,12 +1590,13 @@ int ExtensionSet::Extension::ByteSize(int number) const { WireFormatLite::WIRETYPE_LENGTH_DELIMITED)); } } else { - int tag_size = WireFormatLite::TagSize(number, real_type(type)); + size_t tag_size = WireFormatLite::TagSize(number, real_type(type)); switch (real_type(type)) { #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ case WireFormatLite::TYPE_##UPPERCASE: \ - result += tag_size * repeated_##LOWERCASE##_value->size(); \ + result += tag_size * \ + FromIntSize(repeated_##LOWERCASE##_value->size()); \ for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \ result += WireFormatLite::CAMELCASE##Size( \ repeated_##LOWERCASE##_value->Get(i)); \ @@ -1619,7 +1620,7 @@ int ExtensionSet::Extension::ByteSize(int number) const { #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ case WireFormatLite::TYPE_##UPPERCASE: \ result += (tag_size + WireFormatLite::k##CAMELCASE##Size) * \ - repeated_##LOWERCASE##_value->size(); \ + FromIntSize(repeated_##LOWERCASE##_value->size()); \ break HANDLE_TYPE( FIXED32, Fixed32, uint32); HANDLE_TYPE( FIXED64, Fixed64, uint64); @@ -1652,7 +1653,7 @@ int ExtensionSet::Extension::ByteSize(int number) const { #undef HANDLE_TYPE case WireFormatLite::TYPE_MESSAGE: { if (is_lazy) { - int size = lazymessage_value->ByteSize(); + size_t size = lazymessage_value->ByteSize(); result += io::CodedOutputStream::VarintSize32(size) + size; } else { result += WireFormatLite::MessageSize(*message_value); diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h index 3e1d1ef5..f5aa8de9 100644 --- a/src/google/protobuf/extension_set.h +++ b/src/google/protobuf/extension_set.h @@ -423,10 +423,10 @@ class LIBPROTOBUF_EXPORT ExtensionSet { uint8* SerializeMessageSetWithCachedSizesToArray(uint8* target) const; // Returns the total serialized size of all the extensions. - int ByteSize() const; + size_t ByteSize() const; // Like ByteSize() but uses MessageSet format. - int MessageSetByteSize() const; + size_t MessageSetByteSize() const; // Returns (an estimate of) the total number of bytes used for storing the // extensions in memory, excluding sizeof(*this). If the ExtensionSet is @@ -551,8 +551,8 @@ class LIBPROTOBUF_EXPORT ExtensionSet { int number, bool deterministic, uint8* target) const; - int ByteSize(int number) const; - int MessageSetItemByteSize(int number) const; + size_t ByteSize(int number) const; + size_t MessageSetItemByteSize(int number) const; void Clear(); int GetSize() const; void Free(); diff --git a/src/google/protobuf/extension_set_heavy.cc b/src/google/protobuf/extension_set_heavy.cc index b26a246c..1bbc8fef 100644 --- a/src/google/protobuf/extension_set_heavy.cc +++ b/src/google/protobuf/extension_set_heavy.cc @@ -749,7 +749,7 @@ void ExtensionSet::Extension::SerializeMessageSetItemWithCachedSizes( output->WriteTag(WireFormatLite::kMessageSetItemEndTag); } -int ExtensionSet::Extension::MessageSetItemByteSize(int number) const { +size_t ExtensionSet::Extension::MessageSetItemByteSize(int number) const { if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) { // Not a valid MessageSet extension, but compute the byte size for it the // normal way. @@ -758,13 +758,13 @@ int ExtensionSet::Extension::MessageSetItemByteSize(int number) const { if (is_cleared) return 0; - int our_size = WireFormatLite::kMessageSetItemTagsSize; + size_t our_size = WireFormatLite::kMessageSetItemTagsSize; // type_id our_size += io::CodedOutputStream::VarintSize32(number); // message - int message_size = 0; + size_t message_size = 0; if (is_lazy) { message_size = lazymessage_value->ByteSize(); } else { @@ -785,8 +785,8 @@ void ExtensionSet::SerializeMessageSetWithCachedSizes( } } -int ExtensionSet::MessageSetByteSize() const { - int total_size = 0; +size_t ExtensionSet::MessageSetByteSize() const { + size_t total_size = 0; for (ExtensionMap::const_iterator iter = extensions_.begin(); iter != extensions_.end(); ++iter) { diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc index 688afedb..a70a2ff6 100644 --- a/src/google/protobuf/extension_set_unittest.cc +++ b/src/google/protobuf/extension_set_unittest.cc @@ -796,7 +796,7 @@ TEST(ExtensionSetTest, SpaceUsedExcludingSelf) { } \ int expected_size = sizeof(cpptype) * (16 - \ kMinRepeatedFieldAllocationSize) + empty_repeated_field_size; \ - EXPECT_EQ(expected_size, message.SpaceUsed()) << #type; \ + EXPECT_LE(expected_size, message.SpaceUsed()) << #type; \ } while (0) TEST_REPEATED_EXTENSIONS_SPACE_USED(int32 , int32 , 101); diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index d2acc38b..ffe513d3 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -43,20 +43,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto() { FieldMask_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FieldMask_descriptor_, - FieldMask::default_instance_, + FieldMask::internal_default_instance(), FieldMask_offsets_, -1, -1, -1, sizeof(FieldMask), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_)); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { +void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto); } @@ -65,36 +64,48 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldMask_descriptor_, &FieldMask::default_instance()); + FieldMask_descriptor_, FieldMask::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto() { - delete FieldMask::default_instance_; delete FieldMask_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::internal::GetEmptyString(); + FieldMask::default_instance_.DefaultConstruct(); + FieldMask::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n google/protobuf/field_mask.proto\022\017goog" "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB" - "Q\n\023com.google.protobufB\016FieldMaskProtoP\001" - "\240\001\001\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTyp" - "esb\006proto3", 170); + "N\n\023com.google.protobufB\016FieldMaskProtoP\001" + "\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb" + "\006proto3", 167); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/field_mask.proto", &protobuf_RegisterTypes); - FieldMask::default_instance_ = new FieldMask(); - FieldMask::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto() { @@ -102,6 +113,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2ffield_5fmask_2eproto_; +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; +static void MergeFromFail(int line) { + ::google::protobuf::internal::MergeFromFail(__FILE__, line); +} + +} // namespace + + // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -110,25 +131,23 @@ const int FieldMask::kPathsFieldNumber; FieldMask::FieldMask() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldMask) } void FieldMask::InitAsDefaultInstance() { - _is_default_instance_ = true; } FieldMask::FieldMask(const FieldMask& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldMask) } void FieldMask::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; } @@ -138,8 +157,6 @@ FieldMask::~FieldMask() { } void FieldMask::SharedDtor() { - if (this != default_instance_) { - } } void FieldMask::SetCachedSize(int size) const { @@ -153,11 +170,11 @@ const ::google::protobuf::Descriptor* FieldMask::descriptor() { } const FieldMask& FieldMask::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); + return *internal_default_instance(); } -FieldMask* FieldMask::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed FieldMask::default_instance_; FieldMask* FieldMask::New(::google::protobuf::Arena* arena) const { FieldMask* n = new FieldMask; @@ -256,29 +273,29 @@ void FieldMask::SerializeWithCachedSizes( return target; } -int FieldMask::ByteSize() const { +size_t FieldMask::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldMask) - int total_size = 0; + size_t total_size = 0; // repeated string paths = 1; - total_size += 1 * this->paths_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->paths_size()); for (int i = 0; i < this->paths_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->paths(i)); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void FieldMask::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldMask) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const FieldMask* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const FieldMask* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -286,16 +303,22 @@ void FieldMask::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldMask) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void FieldMask::MergeFrom(const FieldMask& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldMask) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } - paths_.MergeFrom(from.paths_); +} + +void FieldMask::UnsafeMergeFrom(const FieldMask& from) { + GOOGLE_DCHECK(&from != this); + paths_.UnsafeMergeFrom(from.paths_); } void FieldMask::CopyFrom(const ::google::protobuf::Message& from) { @@ -309,7 +332,7 @@ void FieldMask::CopyFrom(const FieldMask& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldMask) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FieldMask::IsInitialized() const { @@ -345,49 +368,49 @@ int FieldMask::paths_size() const { void FieldMask::clear_paths() { paths_.Clear(); } - const ::std::string& FieldMask::paths(int index) const { +const ::std::string& FieldMask::paths(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FieldMask.paths) return paths_.Get(index); } - ::std::string* FieldMask::mutable_paths(int index) { +::std::string* FieldMask::mutable_paths(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FieldMask.paths) return paths_.Mutable(index); } - void FieldMask::set_paths(int index, const ::std::string& value) { +void FieldMask::set_paths(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) paths_.Mutable(index)->assign(value); } - void FieldMask::set_paths(int index, const char* value) { +void FieldMask::set_paths(int index, const char* value) { paths_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths) } - void FieldMask::set_paths(int index, const char* value, size_t size) { +void FieldMask::set_paths(int index, const char* value, size_t size) { paths_.Mutable(index)->assign( reinterpret_cast(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldMask.paths) } - ::std::string* FieldMask::add_paths() { +::std::string* FieldMask::add_paths() { // @@protoc_insertion_point(field_add_mutable:google.protobuf.FieldMask.paths) return paths_.Add(); } - void FieldMask::add_paths(const ::std::string& value) { +void FieldMask::add_paths(const ::std::string& value) { paths_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) } - void FieldMask::add_paths(const char* value) { +void FieldMask::add_paths(const char* value) { paths_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths) } - void FieldMask::add_paths(const char* value, size_t size) { +void FieldMask::add_paths(const char* value, size_t size) { paths_.Add()->assign(reinterpret_cast(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.FieldMask.paths) } - const ::google::protobuf::RepeatedPtrField< ::std::string>& +const ::google::protobuf::RepeatedPtrField< ::std::string>& FieldMask::paths() const { // @@protoc_insertion_point(field_list:google.protobuf.FieldMask.paths) return paths_; } - ::google::protobuf::RepeatedPtrField< ::std::string>* +::google::protobuf::RepeatedPtrField< ::std::string>* FieldMask::mutable_paths() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldMask.paths) return &paths_; diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 460e1338..dd83fca5 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -34,6 +34,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto(); @@ -56,6 +57,10 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro static const ::google::protobuf::Descriptor* descriptor(); static const FieldMask& default_instance(); + static inline const FieldMask* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(FieldMask* other); // implements Message ---------------------------------------------- @@ -70,7 +75,7 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -86,6 +91,7 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(FieldMask* other); + void UnsafeMergeFrom(const FieldMask& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -121,15 +127,15 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; ::google::protobuf::RepeatedPtrField< ::std::string> paths_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto(); void InitAsDefaultInstance(); - static FieldMask* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/field_mask.proto b/src/google/protobuf/field_mask.proto index c51de09a..b6d32a79 100644 --- a/src/google/protobuf/field_mask.proto +++ b/src/google/protobuf/field_mask.proto @@ -37,7 +37,6 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "FieldMaskProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; -option java_generate_equals_and_hash = true; // `FieldMask` represents a set of symbolic field paths, for example: // @@ -82,7 +81,7 @@ option java_generate_equals_and_hash = true; // } // // A repeated field is not allowed except at the last position of a -// field mask. +// paths string. // // If a FieldMask object is not present in a get operation, the // operation applies to all fields (as if a FieldMask of all fields @@ -109,8 +108,8 @@ option java_generate_equals_and_hash = true; // // If a repeated field is specified for an update operation, the existing // repeated values in the target resource will be overwritten by the new values. -// Note that a repeated field is only allowed in the last position of a field -// mask. +// Note that a repeated field is only allowed in the last position of a `paths` +// string. // // If a sub-message is specified in the last position of the field mask for an // update operation, then the existing sub-message in the target resource is diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index d1f7b5ca..6f418433 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -173,62 +173,43 @@ static void ReportReflectionUsageEnumTypeError( // =================================================================== GeneratedMessageReflection::GeneratedMessageReflection( - const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, - const DescriptorPool* descriptor_pool, - MessageFactory* factory, - int object_size, - int arena_offset, - int is_default_instance_offset) - : descriptor_ (descriptor), - default_instance_ (default_instance), - offsets_ (offsets), - has_bits_offset_ (has_bits_offset), - unknown_fields_offset_(unknown_fields_offset), - extensions_offset_(extensions_offset), - arena_offset_ (arena_offset), - is_default_instance_offset_(is_default_instance_offset), - object_size_ (object_size), - descriptor_pool_ ((descriptor_pool == NULL) ? - DescriptorPool::generated_pool() : - descriptor_pool), - message_factory_ (factory) { -} + const Descriptor* descriptor, const Message* default_instance, + const int offsets[], int has_bits_offset, int unknown_fields_offset, + int extensions_offset, const DescriptorPool* descriptor_pool, + MessageFactory* factory, int object_size, int arena_offset) + : descriptor_(descriptor), + default_instance_(default_instance), + offsets_(offsets), + has_bits_offset_(has_bits_offset), + unknown_fields_offset_(unknown_fields_offset), + extensions_offset_(extensions_offset), + arena_offset_(arena_offset), + object_size_(object_size), + descriptor_pool_((descriptor_pool == NULL) + ? DescriptorPool::generated_pool() + : descriptor_pool), + message_factory_(factory) {} GeneratedMessageReflection::GeneratedMessageReflection( - const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, - const void* default_oneof_instance, - int oneof_case_offset, - const DescriptorPool* descriptor_pool, - MessageFactory* factory, - int object_size, - int arena_offset, - int is_default_instance_offset) - : descriptor_ (descriptor), - default_instance_ (default_instance), - default_oneof_instance_ (default_oneof_instance), - offsets_ (offsets), - has_bits_offset_ (has_bits_offset), - oneof_case_offset_(oneof_case_offset), - unknown_fields_offset_(unknown_fields_offset), - extensions_offset_(extensions_offset), - arena_offset_ (arena_offset), - is_default_instance_offset_(is_default_instance_offset), - object_size_ (object_size), - descriptor_pool_ ((descriptor_pool == NULL) ? - DescriptorPool::generated_pool() : - descriptor_pool), - message_factory_ (factory) { -} + const Descriptor* descriptor, const Message* default_instance, + const int offsets[], int has_bits_offset, int unknown_fields_offset, + int extensions_offset, const void* default_oneof_instance, + int oneof_case_offset, const DescriptorPool* descriptor_pool, + MessageFactory* factory, int object_size, int arena_offset) + : descriptor_(descriptor), + default_instance_(default_instance), + default_oneof_instance_(default_oneof_instance), + offsets_(offsets), + has_bits_offset_(has_bits_offset), + oneof_case_offset_(oneof_case_offset), + unknown_fields_offset_(unknown_fields_offset), + extensions_offset_(extensions_offset), + arena_offset_(arena_offset), + object_size_(object_size), + descriptor_pool_((descriptor_pool == NULL) + ? DescriptorPool::generated_pool() + : descriptor_pool), + message_factory_(factory) {} GeneratedMessageReflection::~GeneratedMessageReflection() {} @@ -1026,6 +1007,11 @@ struct FieldNumberSorter { return left->number() < right->number(); } }; + +inline bool IsIndexInHasBitSet(const uint32* has_bit_set, uint32 index) { + return ((has_bit_set[index / 32] >> (index % 32)) & static_cast(1)) + != 0; +} } // namespace void GeneratedMessageReflection::ListFields( @@ -1036,6 +1022,12 @@ void GeneratedMessageReflection::ListFields( // Optimization: The default instance never has any fields set. if (&message == default_instance_) return; + // Optimization: Avoid calling GetHasBits() and HasOneofField() many times + // within the field loop. + const uint32* const has_bits = GetHasBits(message); + const uint32* const oneof_case_array = reinterpret_cast( + reinterpret_cast(&message) + oneof_case_offset_); + output->reserve(descriptor_->field_count()); for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); @@ -1044,11 +1036,18 @@ void GeneratedMessageReflection::ListFields( output->push_back(field); } } else { - if (field->containing_oneof()) { - if (HasOneofField(message, field)) { + const OneofDescriptor* containing_oneof = field->containing_oneof(); + if (containing_oneof) { + // Equivalent to: HasOneofField(message, field) + if (oneof_case_array[containing_oneof->index()] == field->number()) { output->push_back(field); } - } else if (HasBit(message, field)) { + } else if (has_bits) { + // Equivalent to: HasBit(message, field) + if (IsIndexInHasBitSet(has_bits, i)) { + output->push_back(field); + } + } else if (HasBit(message, field)) { // Fall back on proto3-style HasBit. output->push_back(field); } } @@ -2001,12 +2000,7 @@ GeneratedMessageReflection::MutableInternalMetadataWithArena( inline bool GeneratedMessageReflection::GetIsDefaultInstance( const Message& message) const { - if (is_default_instance_offset_ == kHasNoDefaultInstanceField) { - return false; - } - const void* ptr = reinterpret_cast(&message) + - is_default_instance_offset_; - return *reinterpret_cast(ptr); + return &message == default_instance_; } // Simple accessors for manipulating has_bits_. @@ -2063,8 +2057,7 @@ inline bool GeneratedMessageReflection::HasBit( } } } - return GetHasBits(message)[field->index() / 32] & - (1 << (field->index() % 32)); + return IsIndexInHasBitSet(GetHasBits(message), field->index()); } inline void GeneratedMessageReflection::SetBit( @@ -2072,7 +2065,9 @@ inline void GeneratedMessageReflection::SetBit( if (has_bits_offset_ == -1) { return; } - MutableHasBits(message)[field->index() / 32] |= (1 << (field->index() % 32)); + const uint32 index = static_cast(field->index()); + MutableHasBits(message)[index / 32] |= + (static_cast(1) << (index % 32)); } inline void GeneratedMessageReflection::ClearBit( @@ -2080,7 +2075,9 @@ inline void GeneratedMessageReflection::ClearBit( if (has_bits_offset_ == -1) { return; } - MutableHasBits(message)[field->index() / 32] &= ~(1 << (field->index() % 32)); + const uint32 index = static_cast(field->index()); + MutableHasBits(message)[index / 32] &= + ~(static_cast(1) << (index % 32)); } inline void GeneratedMessageReflection::SwapBit( @@ -2275,19 +2272,11 @@ GeneratedMessageReflection::NewGeneratedMessageReflection( int object_size, int arena_offset, int is_default_instance_offset) { - return new GeneratedMessageReflection(descriptor, - default_instance, - offsets, - has_bits_offset, - unknown_fields_offset, - extensions_offset, - default_oneof_instance, - oneof_case_offset, - DescriptorPool::generated_pool(), - MessageFactory::generated_factory(), - object_size, - arena_offset, - is_default_instance_offset); + return new GeneratedMessageReflection( + descriptor, default_instance, offsets, has_bits_offset, + unknown_fields_offset, extensions_offset, default_oneof_instance, + oneof_case_offset, DescriptorPool::generated_pool(), + MessageFactory::generated_factory(), object_size, arena_offset); } GeneratedMessageReflection* @@ -2301,17 +2290,11 @@ GeneratedMessageReflection::NewGeneratedMessageReflection( int object_size, int arena_offset, int is_default_instance_offset) { - return new GeneratedMessageReflection(descriptor, - default_instance, - offsets, - has_bits_offset, - unknown_fields_offset, - extensions_offset, - DescriptorPool::generated_pool(), - MessageFactory::generated_factory(), - object_size, - arena_offset, - is_default_instance_offset); + return new GeneratedMessageReflection( + descriptor, default_instance, offsets, has_bits_offset, + unknown_fields_offset, extensions_offset, + DescriptorPool::generated_pool(), MessageFactory::generated_factory(), + object_size, arena_offset); } } // namespace internal diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index 15fc802c..1413b110 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -132,15 +132,11 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { // by sizeof(). GeneratedMessageReflection(const Descriptor* descriptor, const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, + const int offsets[], int has_bits_offset, + int unknown_fields_offset, int extensions_offset, const DescriptorPool* pool, - MessageFactory* factory, - int object_size, - int arena_offset, - int is_default_instance_offset = -1); + MessageFactory* factory, int object_size, + int arena_offset); // Similar with the construction above. Call this construction if the // message has oneof definition. @@ -168,17 +164,12 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { // other parameters are the same with the construction above. GeneratedMessageReflection(const Descriptor* descriptor, const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, + const int offsets[], int has_bits_offset, + int unknown_fields_offset, int extensions_offset, const void* default_oneof_instance, - int oneof_case_offset, - const DescriptorPool* pool, - MessageFactory* factory, - int object_size, - int arena_offset, - int is_default_instance_offset = -1); + int oneof_case_offset, const DescriptorPool* pool, + MessageFactory* factory, int object_size, + int arena_offset); ~GeneratedMessageReflection(); // Shorter-to-call helpers for the above two constructions that work if the @@ -226,11 +217,11 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { Message* ReleaseLast(Message* message, const FieldDescriptor* field) const; void Swap(Message* message1, Message* message2) const; void SwapFields(Message* message1, Message* message2, - const vector& fields) const; + const std::vector& fields) const; void SwapElements(Message* message, const FieldDescriptor* field, int index1, int index2) const; void ListFields(const Message& message, - vector* output) const; + std::vector* output) const; int32 GetInt32 (const Message& message, const FieldDescriptor* field) const; @@ -448,11 +439,8 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { int unknown_fields_offset_; int extensions_offset_; int arena_offset_; - int is_default_instance_offset_; int object_size_; - static const int kHasNoDefaultInstanceField = -1; - const DescriptorPool* descriptor_pool_; MessageFactory* message_factory_; diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index 7ad6d61c..73f55927 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -48,15 +48,15 @@ double NaN() { return std::numeric_limits::quiet_NaN(); } -const ::std::string* empty_string_; +ExplicitlyConstructed< ::std::string> fixed_address_empty_string; GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_); void DeleteEmptyString() { - delete empty_string_; + GetEmptyStringAlreadyInited().~string(); } void InitEmptyString() { - empty_string_ = new string; + fixed_address_empty_string.DefaultConstruct(); OnShutdown(&DeleteEmptyString); } diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h index 8967726e..871acca5 100644 --- a/src/google/protobuf/generated_message_util.h +++ b/src/google/protobuf/generated_message_util.h @@ -43,6 +43,7 @@ #include #include +#include namespace google { @@ -70,22 +71,49 @@ namespace internal { LIBPROTOBUF_EXPORT double Infinity(); LIBPROTOBUF_EXPORT double NaN(); +// This type is used to define a global variable, without it's constructor +// and destructor run on start and end of the program lifetime. This circumvents +// the initial construction order fiasco, while keeping the address of the +// empty string a compile time constant. +template +class ExplicitlyConstructed { + public: + void DefaultConstruct() { + new (&union_) T(); + init_ = true; + } + + bool IsInitialized() { return init_; } + + const T& get() const { return reinterpret_cast(union_); } + T* get_mutable() { return reinterpret_cast(&union_); } + + private: + // Prefer c++14 aligned_storage, but for compatibility this will do. + union AlignedUnion { + char space[sizeof(T)]; + int64 align_to_int64; + void* align_to_ptr; + } union_; + bool init_; // false by linker +}; + // TODO(jieluo): Change to template. We have tried to use template, // but it causes net/rpc/python:rpcutil_test fail (the empty string will // init twice). It may related to swig. Change to template after we // found the solution. -// Default empty string object. Don't use the pointer directly. Instead, call +// Default empty string object. Don't use this directly. Instead, call // GetEmptyString() to get the reference. -LIBPROTOBUF_EXPORT extern const ::std::string* empty_string_; +extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string; LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_; LIBPROTOBUF_EXPORT void InitEmptyString(); LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() { - assert(empty_string_ != NULL); - return *empty_string_; + return fixed_address_empty_string.get(); } + LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyString() { ::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString); return GetEmptyStringAlreadyInited(); @@ -106,20 +134,28 @@ template bool AllAreInitialized(const Type& t) { return true; } -class ArenaString; - -// Read a length (varint32), followed by a string, from *input. Return a -// pointer to a copy of the string that resides in *arena. Requires both -// args to be non-NULL. If something goes wrong while reading the data -// then NULL is returned (e.g., input does not start with a valid varint). -LIBPROTOBUF_EXPORT ArenaString* ReadArenaString( - ::google::protobuf::io::CodedInputStream* input, - ::google::protobuf::Arena* arena); - // Helper function to crash on merge failure. // Moved out of generated code to reduce binary size. LIBPROTOBUF_EXPORT void MergeFromFail(const char* file, int line) GOOGLE_ATTRIBUTE_NORETURN; +// We compute sizes as size_t but cache them as int. This function converts a +// computed size to a cached size. Since we don't proceed with serialization if +// the total size was > INT_MAX, it is not important what this function returns +// for inputs > INT_MAX. +inline int ToCachedSize(size_t size) { + return static_cast(size); +} + +// We mainly calculate sizes in terms of size_t, but some functions that compute +// sizes return "int". These int sizes are expected to always be positive. +// This function is more efficient than casting an int to size_t directly on +// 64-bit platforms because it avoids making the compiler emit a sign extending +// instruction, which we don't want and don't want to pay for. +inline size_t FromIntSize(int size) { + // Convert to unsigned before widening so sign extension is not necessary. + return static_cast(size); +} + } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/has_bits.h b/src/google/protobuf/has_bits.h new file mode 100644 index 00000000..133bc02a --- /dev/null +++ b/src/google/protobuf/has_bits.h @@ -0,0 +1,72 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef GOOGLE_PROTOBUF_HAS_BITS_H__ +#define GOOGLE_PROTOBUF_HAS_BITS_H__ + +#include + +namespace google { +namespace protobuf { +namespace internal { + +template +class HasBits { + public: + HasBits() GOOGLE_ATTRIBUTE_ALWAYS_INLINE { Clear(); } + + void Clear() GOOGLE_ATTRIBUTE_ALWAYS_INLINE { + memset(has_bits_, 0, sizeof(has_bits_)); + } + + ::google::protobuf::uint32& operator[](int index) GOOGLE_ATTRIBUTE_ALWAYS_INLINE { + return has_bits_[index]; + } + + const ::google::protobuf::uint32& operator[](int index) const GOOGLE_ATTRIBUTE_ALWAYS_INLINE { + return has_bits_[index]; + } + + bool operator==(const HasBits& rhs) const { + return memcmp(has_bits_, rhs.has_bits_, sizeof(has_bits_)) == 0; + } + + bool operator!=(const HasBits& rhs) const { + return !(*this == rhs); + } + private: + ::google::protobuf::uint32 has_bits_[doublewords]; +}; + +} // namespace internal +} // namespace protobuf + +} // namespace google +#endif // GOOGLE_PROTOBUF_HAS_BITS_H__ diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc index a5675e79..08394ca7 100644 --- a/src/google/protobuf/io/coded_stream.cc +++ b/src/google/protobuf/io/coded_stream.cc @@ -47,6 +47,7 @@ #include #include #include +#include namespace google { @@ -902,46 +903,18 @@ bool CodedOutputStream::Refresh() { } } -int CodedOutputStream::VarintSize32Fallback(uint32 value) { +size_t CodedOutputStream::VarintSize32Fallback(uint32 value) { + GOOGLE_DCHECK_NE(0, value); // This is enforced by our caller. + + return 1 + Bits::Log2FloorNonZero(value) / 7; +} + +size_t CodedOutputStream::VarintSize64(uint64 value) { if (value < (1 << 7)) { return 1; - } else if (value < (1 << 14)) { - return 2; - } else if (value < (1 << 21)) { - return 3; - } else if (value < (1 << 28)) { - return 4; - } else { - return 5; } -} -int CodedOutputStream::VarintSize64(uint64 value) { - if (value < (1ull << 35)) { - if (value < (1ull << 7)) { - return 1; - } else if (value < (1ull << 14)) { - return 2; - } else if (value < (1ull << 21)) { - return 3; - } else if (value < (1ull << 28)) { - return 4; - } else { - return 5; - } - } else { - if (value < (1ull << 42)) { - return 6; - } else if (value < (1ull << 49)) { - return 7; - } else if (value < (1ull << 56)) { - return 8; - } else if (value < (1ull << 63)) { - return 9; - } else { - return 10; - } - } + return 1 + Bits::Log2FloorNonZero64(value) / 7; } uint8* CodedOutputStream::WriteStringWithSizeToArray(const string& str, diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index 316da765..1402cc17 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -784,17 +784,17 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { uint8* target); // Returns the number of bytes needed to encode the given value as a varint. - static int VarintSize32(uint32 value); + static size_t VarintSize32(uint32 value); // Returns the number of bytes needed to encode the given value as a varint. - static int VarintSize64(uint64 value); + static size_t VarintSize64(uint64 value); // If negative, 10 bytes. Otheriwse, same as VarintSize32(). - static int VarintSize32SignExtended(int32 value); + static size_t VarintSize32SignExtended(int32 value); // Compile-time equivalent of VarintSize32(). template struct StaticVarintSize32 { - static const int value = + static const size_t value = (Value < (1 << 7)) ? 1 : (Value < (1 << 14)) @@ -890,7 +890,7 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { GOOGLE_ATTRIBUTE_ALWAYS_INLINE static uint8* WriteVarint64ToArrayInline( uint64 value, uint8* target); - static int VarintSize32Fallback(uint32 value); + static size_t VarintSize32Fallback(uint32 value); // See above. Other projects may use "friend" to allow them to call this. static void SetDefaultSerializationDeterministic() { @@ -1225,7 +1225,7 @@ inline uint8* CodedOutputStream::WriteTagToArray( return WriteVarint32ToArray(value, target); } -inline int CodedOutputStream::VarintSize32(uint32 value) { +inline size_t CodedOutputStream::VarintSize32(uint32 value) { if (value < (1 << 7)) { return 1; } else { @@ -1233,7 +1233,7 @@ inline int CodedOutputStream::VarintSize32(uint32 value) { } } -inline int CodedOutputStream::VarintSize32SignExtended(int32 value) { +inline size_t CodedOutputStream::VarintSize32SignExtended(int32 value) { if (value < 0) { return 10; // TODO(kenton): Make this a symbolic constant. } else { diff --git a/src/google/protobuf/io/coded_stream_unittest.cc b/src/google/protobuf/io/coded_stream_unittest.cc index a8108e45..9f1ebc3f 100644 --- a/src/google/protobuf/io/coded_stream_unittest.cc +++ b/src/google/protobuf/io/coded_stream_unittest.cc @@ -58,6 +58,7 @@ #define ULL(x) GOOGLE_ULONGLONG(x) namespace google { + namespace protobuf { namespace io { namespace { diff --git a/src/google/protobuf/io/zero_copy_stream_impl.h b/src/google/protobuf/io/zero_copy_stream_impl.h index 0746fa6a..3365790e 100644 --- a/src/google/protobuf/io/zero_copy_stream_impl.h +++ b/src/google/protobuf/io/zero_copy_stream_impl.h @@ -218,7 +218,7 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { // If a block_size is given, it specifies the number of bytes that // should be read and returned with each call to Next(). Otherwise, // a reasonable default is used. - explicit IstreamInputStream(istream* stream, int block_size = -1); + explicit IstreamInputStream(std::istream* stream, int block_size = -1); ~IstreamInputStream(); // implements ZeroCopyInputStream ---------------------------------- @@ -230,7 +230,7 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { private: class LIBPROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream { public: - CopyingIstreamInputStream(istream* input); + CopyingIstreamInputStream(std::istream* input); ~CopyingIstreamInputStream(); // implements CopyingInputStream --------------------------------- @@ -239,7 +239,7 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { private: // The stream. - istream* input_; + std::istream* input_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingIstreamInputStream); }; @@ -262,7 +262,7 @@ class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream { // If a block_size is given, it specifies the size of the buffers // that should be returned by Next(). Otherwise, a reasonable default // is used. - explicit OstreamOutputStream(ostream* stream, int block_size = -1); + explicit OstreamOutputStream(std::ostream* stream, int block_size = -1); ~OstreamOutputStream(); // implements ZeroCopyOutputStream --------------------------------- @@ -273,7 +273,7 @@ class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream { private: class LIBPROTOBUF_EXPORT CopyingOstreamOutputStream : public CopyingOutputStream { public: - CopyingOstreamOutputStream(ostream* output); + CopyingOstreamOutputStream(std::ostream* output); ~CopyingOstreamOutputStream(); // implements CopyingOutputStream -------------------------------- @@ -281,7 +281,7 @@ class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream { private: // The stream. - ostream* output_; + std::ostream* output_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingOstreamOutputStream); }; diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index bfc63b0f..2d295510 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -565,7 +565,7 @@ class Map { void Init() { if (old_style_) deprecated_elements_ = Arena::Create( - arena_, 0, hasher(), equal_to(), + arena_, 0, hasher(), std::equal_to(), MapAllocator*> >(arena_)); else elements_ = @@ -596,7 +596,7 @@ class Map { // If arena is not given, malloc needs to be called which doesn't // construct element object. if (arena_ == NULL) { - return reinterpret_cast(malloc(n * sizeof(value_type))); + return static_cast(::operator new(n * sizeof(value_type))); } else { return reinterpret_cast( Arena::CreateArray(arena_, n * sizeof(value_type))); @@ -605,7 +605,11 @@ class Map { void deallocate(pointer p, size_type n) { if (arena_ == NULL) { - free(p); +#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) + ::operator delete(p, n * sizeof(value_type)); +#else + ::operator delete(p); +#endif } } @@ -1351,7 +1355,7 @@ class Map { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(InnerMap); }; // end of class InnerMap - typedef hash_map, equal_to, + typedef hash_map, std::equal_to, MapAllocator*> > > DeprecatedInnerMap; diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h index e87eda64..abcd4529 100644 --- a/src/google/protobuf/map_entry.h +++ b/src/google/protobuf/map_entry.h @@ -158,8 +158,8 @@ class MapEntry : public MapEntryBase { return entry_lite_.MergePartialFromCodedStream(input); } - int ByteSize() const { - return entry_lite_.ByteSize(); + size_t ByteSizeLong() const { + return entry_lite_.ByteSizeLong(); } void SerializeWithCachedSizes(::google::protobuf::io::CodedOutputStream* output) const { diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h index 4dedfd57..3fb58220 100644 --- a/src/google/protobuf/map_entry_lite.h +++ b/src/google/protobuf/map_entry_lite.h @@ -119,7 +119,7 @@ class MapEntryLite : public MessageLite { kKeyFieldNumber, KeyTypeHandler::kWireType); static const uint8 kValueTag = GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG( kValueFieldNumber, ValueTypeHandler::kWireType); - static const int kTagSize = 1; + static const size_t kTagSize = 1; public: ~MapEntryLite() { @@ -201,8 +201,8 @@ class MapEntryLite : public MessageLite { } } - int ByteSize() const { - int size = 0; + size_t ByteSizeLong() const { + size_t size = 0; size += has_key() ? kTagSize + KeyTypeHandler::ByteSize(key()) : 0; size += has_value() ? kTagSize + ValueTypeHandler::ByteSize(value()) : 0; return size; diff --git a/src/google/protobuf/map_type_handler.h b/src/google/protobuf/map_type_handler.h index 685a770f..a21c92d9 100644 --- a/src/google/protobuf/map_type_handler.h +++ b/src/google/protobuf/map_type_handler.h @@ -158,7 +158,7 @@ class MapTypeHandler { MapWireFieldTypeTraits::kIsEnum; // Functions used in parsing and serialization. =================== - static inline int ByteSize(const MapEntryAccessorType& value); + static inline size_t ByteSize(const MapEntryAccessorType& value); static inline int GetCachedSize(const MapEntryAccessorType& value); static inline bool Read(io::CodedInputStream* input, MapEntryAccessorType* value); @@ -276,7 +276,7 @@ MAP_HANDLER(BOOL) #undef MAP_HANDLER template -inline int +inline size_t MapTypeHandler::ByteSize( const MapEntryAccessorType& value) { return WireFormatLite::MessageSizeNoVirtual(value); diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index f18077dd..c8de458c 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -46,9 +46,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -146,9 +146,9 @@ void Message::SerializeWithCachedSizes( WireFormat::SerializeWithCachedSizes(*this, GetCachedSize(), output); } -int Message::ByteSize() const { - int size = WireFormat::ByteSize(*this); - SetCachedSize(size); +size_t Message::ByteSizeLong() const { + size_t size = WireFormat::ByteSize(*this); + SetCachedSize(internal::ToCachedSize(size)); return size; } @@ -299,8 +299,8 @@ class GeneratedMessageFactory : public MessageFactory { hash_map, streq> file_map_; - // Initialized lazily, so requires locking. Mutex mutex_; + // Initialized lazily, so requires locking. hash_map type_map_; }; diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index 9705e97e..bee25f77 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -271,10 +271,10 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite { bool ParsePartialFromFileDescriptor(int file_descriptor); // Parse a protocol buffer from a C++ istream. If successful, the entire // input will be consumed. - bool ParseFromIstream(istream* input); + bool ParseFromIstream(std::istream* input); // Like ParseFromIstream(), but accepts messages that are missing // required fields. - bool ParsePartialFromIstream(istream* input); + bool ParsePartialFromIstream(std::istream* input); // Serialize the message and write it to the given file descriptor. All // required fields must be set. @@ -283,9 +283,9 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite { bool SerializePartialToFileDescriptor(int file_descriptor) const; // Serialize the message and write it to the given C++ ostream. All // required fields must be set. - bool SerializeToOstream(ostream* output) const; + bool SerializeToOstream(std::ostream* output) const; // Like SerializeToOstream(), but allows missing required fields. - bool SerializePartialToOstream(ostream* output) const; + bool SerializePartialToOstream(std::ostream* output) const; // Reflection-based methods ---------------------------------------- @@ -297,7 +297,7 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite { virtual bool IsInitialized() const; virtual void CheckTypeAndMergeFrom(const MessageLite& other); virtual bool MergePartialFromCodedStream(io::CodedInputStream* input); - virtual int ByteSize() const; + virtual size_t ByteSizeLong() const; virtual void SerializeWithCachedSizes(io::CodedOutputStream* output) const; private: diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc index ba56db95..9d6da264 100644 --- a/src/google/protobuf/message_lite.cc +++ b/src/google/protobuf/message_lite.cc @@ -33,8 +33,9 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include #include +#include +#include #include #include #include @@ -58,9 +59,9 @@ namespace { // protobuf implementation but is more likely caused by concurrent modification // of the message. This function attempts to distinguish between the two and // provide a useful error message. -void ByteSizeConsistencyError(int byte_size_before_serialization, - int byte_size_after_serialization, - int bytes_produced_by_serialization, +void ByteSizeConsistencyError(size_t byte_size_before_serialization, + size_t byte_size_after_serialization, + size_t bytes_produced_by_serialization, const MessageLite& message) { GOOGLE_CHECK_EQ(byte_size_before_serialization, byte_size_after_serialization) << message.GetTypeName() @@ -236,12 +237,15 @@ bool MessageLite::SerializeToCodedStream(io::CodedOutputStream* output) const { return SerializePartialToCodedStream(output); } +size_t MessageLite::ByteSizeLong() const { + return internal::FromIntSize(ByteSize()); +} + bool MessageLite::SerializePartialToCodedStream( io::CodedOutputStream* output) const { - const int size = ByteSize(); // Force size to be cached. - if (size < 0) { - // Messages >2G cannot be serialized due to overflow computing ByteSize. - GOOGLE_LOG(ERROR) << "Error computing ByteSize (possible overflow?)."; + const size_t size = ByteSizeLong(); // Force size to be cached. + if (size > INT_MAX) { + GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB."; return false; } @@ -249,7 +253,7 @@ bool MessageLite::SerializePartialToCodedStream( if (buffer != NULL) { uint8* end = SerializeWithCachedSizesToArray(buffer); if (end - buffer != size) { - ByteSizeConsistencyError(size, ByteSize(), end - buffer, *this); + ByteSizeConsistencyError(size, ByteSizeLong(), end - buffer, *this); } return true; } else { @@ -261,7 +265,7 @@ bool MessageLite::SerializePartialToCodedStream( int final_byte_count = output->ByteCount(); if (final_byte_count - original_byte_count != size) { - ByteSizeConsistencyError(size, ByteSize(), + ByteSizeConsistencyError(size, ByteSizeLong(), final_byte_count - original_byte_count, *this); } @@ -287,11 +291,10 @@ bool MessageLite::AppendToString(string* output) const { } bool MessageLite::AppendPartialToString(string* output) const { - int old_size = output->size(); - int byte_size = ByteSize(); - if (byte_size < 0) { - // Messages >2G cannot be serialized due to overflow computing ByteSize. - GOOGLE_LOG(ERROR) << "Error computing ByteSize (possible overflow?)."; + size_t old_size = output->size(); + size_t byte_size = ByteSizeLong(); + if (byte_size > INT_MAX) { + GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB."; return false; } @@ -300,7 +303,7 @@ bool MessageLite::AppendPartialToString(string* output) const { reinterpret_cast(io::mutable_string_data(output) + old_size); uint8* end = SerializeWithCachedSizesToArray(start); if (end - start != byte_size) { - ByteSizeConsistencyError(byte_size, ByteSize(), end - start, *this); + ByteSizeConsistencyError(byte_size, ByteSizeLong(), end - start, *this); } return true; } @@ -321,12 +324,12 @@ bool MessageLite::SerializeToArray(void* data, int size) const { } bool MessageLite::SerializePartialToArray(void* data, int size) const { - int byte_size = ByteSize(); + int byte_size = ByteSizeLong(); if (size < byte_size) return false; uint8* start = reinterpret_cast(data); uint8* end = SerializeWithCachedSizesToArray(start); if (end - start != byte_size) { - ByteSizeConsistencyError(byte_size, ByteSize(), end - start, *this); + ByteSizeConsistencyError(byte_size, ByteSizeLong(), end - start, *this); } return true; } diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index 2bdfe496..d3c3b1f0 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -239,12 +239,13 @@ class LIBPROTOBUF_EXPORT MessageLite { bool AppendPartialToString(string* output) const; // Computes the serialized size of the message. This recursively calls - // ByteSize() on all embedded messages. If a subclass does not override - // this, it MUST override SetCachedSize(). + // ByteSize() on all embedded messages. Subclasses MUST override either + // ByteSize() or ByteSizeLong() (overriding both is fine). // // ByteSize() is generally linear in the number of fields defined for the // proto. - virtual int ByteSize() const = 0; + virtual int ByteSize() const { return ByteSizeLong(); } + virtual size_t ByteSizeLong() const; // Serializes the message without recomputing the size. The message must // not have changed since the last call to ByteSize(); if it has, the results diff --git a/src/google/protobuf/message_unittest.cc b/src/google/protobuf/message_unittest.cc index d668a1a6..3af05808 100644 --- a/src/google/protobuf/message_unittest.cc +++ b/src/google/protobuf/message_unittest.cc @@ -265,6 +265,24 @@ TEST(MessageTest, CheckOverflow) { EXPECT_FALSE(message.AppendToCord(&serialized)); } +TEST(MessageTest, CheckBigOverflow) { + unittest::TestAllTypes message; + // Create a message with size just over 4GB. We should be able to detect this + // too, even though it will make a plain "int" wrap back to a positive number. + const string data(1024, 'x'); + Cord one_megabyte; + for (int i = 0; i < 1024; i++) { + one_megabyte.Append(data); + } + + for (int i = 0; i < 4 * 1024 + 1; ++i) { + message.add_repeated_cord()->CopyFrom(one_megabyte); + } + + Cord serialized; + EXPECT_FALSE(message.AppendToCord(&serialized)); +} + #endif // PROTOBUF_HAS_DEATH_TEST namespace { @@ -272,6 +290,12 @@ namespace { class NegativeByteSize : public unittest::TestRequired { public: virtual int ByteSize() const { return -1; } + + // The implementation of ByteSizeLong() from MessageLite, to simulate what + // would happen if TestRequired *hadn't* overridden it already. + virtual size_t ByteSizeLong() const { + return static_cast(ByteSize()); + } }; } // namespace @@ -319,6 +343,18 @@ TEST(MessageTest, ParseFailsOnInvalidMessageEnd) { EXPECT_FALSE(message.ParseFromArray("\014", 1)); } +// Regression test for b/23630858 +TEST(MessageTest, MessageIsStillValidAfterParseFails) { + unittest::TestAllTypes message; + + // 9 0xFFs for the "optional_uint64" field. + string invalid_data = "\x20\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"; + + EXPECT_FALSE(message.ParseFromString(invalid_data)); + message.Clear(); + EXPECT_EQ(0, message.optional_uint64()); +} + namespace { void ExpectMessageMerged(const unittest::TestAllTypes& message) { diff --git a/src/google/protobuf/metadata.h b/src/google/protobuf/metadata.h index fdee150b..6e3eef63 100644 --- a/src/google/protobuf/metadata.h +++ b/src/google/protobuf/metadata.h @@ -152,10 +152,6 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena { } }; -// Temporary compatibility typedef. Remove once this is released in components -// and upb CL is submitted. -typedef InternalMetadataWithArena InternalMetadata; - } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/reflection.h b/src/google/protobuf/reflection.h index 2391f453..d5a6653c 100755 --- a/src/google/protobuf/reflection.h +++ b/src/google/protobuf/reflection.h @@ -80,6 +80,12 @@ class RepeatedFieldRef< typedef IteratorType iterator; typedef IteratorType const_iterator; + typedef T value_type; + typedef T& reference; + typedef const T& const_reference; + typedef int size_type; + typedef ptrdiff_t difference_type; + iterator begin() const { return iterator(data_, accessor_, true); } @@ -202,11 +208,18 @@ class RepeatedFieldRef< typedef IteratorType iterator; typedef IteratorType const_iterator; + typedef T value_type; + typedef T& reference; + typedef const T& const_reference; + typedef int size_type; + typedef ptrdiff_t difference_type; + iterator begin() const { return iterator(data_, accessor_, true, NewMessage()); } iterator end() const { - return iterator(data_, accessor_, false, NewMessage()); + // The end iterator must not be dereferenced, no need for scratch space. + return iterator(data_, accessor_, false, NULL); } private: @@ -428,13 +441,13 @@ class RepeatedFieldRefIterator public: // Constructor for non-message fields. RepeatedFieldRefIterator(const void* data, - const RepeatedFieldAccessor* accessor, - bool begin) - : data_(data), accessor_(accessor), - iterator_(begin ? accessor->BeginIterator(data) : - accessor->EndIterator(data)), - scratch_space_(new AccessorValueType) { - } + const RepeatedFieldAccessor* accessor, bool begin) + : data_(data), + accessor_(accessor), + iterator_(begin ? accessor->BeginIterator(data) + : accessor->EndIterator(data)), + // The end iterator must not be dereferenced, no need for scratch space. + scratch_space_(begin ? new AccessorValueType : NULL) {} // Constructor for message fields. RepeatedFieldRefIterator(const void* data, const RepeatedFieldAccessor* accessor, diff --git a/src/google/protobuf/reflection_ops.h b/src/google/protobuf/reflection_ops.h index 4775911e..45d8c650 100644 --- a/src/google/protobuf/reflection_ops.h +++ b/src/google/protobuf/reflection_ops.h @@ -67,7 +67,7 @@ class LIBPROTOBUF_EXPORT ReflectionOps { // the front of each name. static void FindInitializationErrors(const Message& message, const string& prefix, - vector* errors); + std::vector* errors); private: // All methods are static. No need to construct. diff --git a/src/google/protobuf/repeated_field.cc b/src/google/protobuf/repeated_field.cc index 77004f59..5ca964c1 100644 --- a/src/google/protobuf/repeated_field.cc +++ b/src/google/protobuf/repeated_field.cc @@ -58,14 +58,16 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) { (std::numeric_limits::max() - kRepHeaderSize) / sizeof(old_rep->elements[0])) << "Requested size is too large to fit into size_t."; + size_t bytes = kRepHeaderSize + sizeof(old_rep->elements[0]) * new_size; if (arena == NULL) { - rep_ = reinterpret_cast( - new char[kRepHeaderSize + sizeof(old_rep->elements[0]) * new_size]); + rep_ = reinterpret_cast(::operator new(bytes)); } else { rep_ = reinterpret_cast( - ::google::protobuf::Arena::CreateArray(arena, - kRepHeaderSize + sizeof(old_rep->elements[0]) * new_size)); + ::google::protobuf::Arena::CreateArray(arena, bytes)); } +#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) + const int old_total_size = total_size_; +#endif total_size_ = new_size; if (old_rep && old_rep->allocated_size > 0) { memcpy(rep_->elements, old_rep->elements, @@ -75,7 +77,13 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) { rep_->allocated_size = 0; } if (arena == NULL) { - delete [] reinterpret_cast(old_rep); +#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) + const size_t old_size = + old_total_size * sizeof(rep_->elements[0]) + kRepHeaderSize; + ::operator delete(static_cast(old_rep), old_size); +#else + ::operator delete(static_cast(old_rep)); +#endif } return &rep_->elements[current_size_]; } diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index bc567555..0a41495f 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -120,6 +120,10 @@ class RepeatedField { const Element& Get(int index) const; Element* Mutable(int index); + + const Element& operator[](int index) const { return Get(index); } + Element& operator[](int index) { return *Mutable(index); } + void Set(int index, const Element& value); void Add(const Element& value); Element* Add(); @@ -134,6 +138,7 @@ class RepeatedField { void Clear(); void MergeFrom(const RepeatedField& other); + void UnsafeMergeFrom(const RepeatedField& other); void CopyFrom(const RepeatedField& other); // Reserve space to expand the field to at least the given size. If the @@ -284,7 +289,12 @@ class RepeatedField { e->Element::~Element(); } if (rep->arena == NULL) { - delete[] reinterpret_cast(rep); +#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) + const size_t bytes = size * sizeof(*e) + kRepHeaderSize; + ::operator delete(static_cast(rep), bytes); +#else + ::operator delete(static_cast(rep)); +#endif } } } @@ -742,6 +752,9 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase { Element* Mutable(int index); Element* Add(); + const Element& operator[](int index) const { return Get(index); } + Element& operator[](int index) { return *Mutable(index); } + // Remove the last element in the array. // Ownership of the element is retained by the array. void RemoveLast(); @@ -753,6 +766,7 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase { void Clear(); void MergeFrom(const RepeatedPtrField& other); + void UnsafeMergeFrom(const RepeatedPtrField& other) { MergeFrom(other); } void CopyFrom(const RepeatedPtrField& other); // Reserve space to expand the field to at least the given size. This only @@ -1138,8 +1152,7 @@ inline void RepeatedField::Clear() { } template -inline void RepeatedField::MergeFrom(const RepeatedField& other) { - GOOGLE_CHECK_NE(&other, this); +inline void RepeatedField::UnsafeMergeFrom(const RepeatedField& other) { if (other.current_size_ != 0) { Reserve(current_size_ + other.current_size_); CopyArray(rep_->elements + current_size_, @@ -1148,6 +1161,12 @@ inline void RepeatedField::MergeFrom(const RepeatedField& other) { } } +template +inline void RepeatedField::MergeFrom(const RepeatedField& other) { + GOOGLE_CHECK_NE(&other, this); + UnsafeMergeFrom(other); +} + template inline void RepeatedField::CopyFrom(const RepeatedField& other) { if (&other == this) return; @@ -1265,13 +1284,12 @@ void RepeatedField::Reserve(int new_size) { (std::numeric_limits::max() - kRepHeaderSize) / sizeof(Element)) << "Requested size is too large to fit into size_t."; + size_t bytes = kRepHeaderSize + sizeof(Element) * new_size; if (arena == NULL) { - rep_ = reinterpret_cast( - new char[kRepHeaderSize + sizeof(Element) * new_size]); + rep_ = static_cast(::operator new(bytes)); } else { rep_ = reinterpret_cast( - ::google::protobuf::Arena::CreateArray(arena, - kRepHeaderSize + sizeof(Element) * new_size)); + ::google::protobuf::Arena::CreateArray(arena, bytes)); } rep_->arena = arena; int old_total_size = total_size_; @@ -1363,7 +1381,12 @@ void RepeatedPtrFieldBase::Destroy() { for (int i = 0; i < n; i++) { TypeHandler::Delete(cast(elements[i]), NULL); } - delete[] reinterpret_cast(rep_); +#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) + const size_t size = total_size_ * sizeof(elements[0]) + kRepHeaderSize; + ::operator delete(static_cast(rep_), size); +#else + ::operator delete(static_cast(rep_)); +#endif } rep_ = NULL; } diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc index 39b24b33..33547146 100644 --- a/src/google/protobuf/repeated_field_unittest.cc +++ b/src/google/protobuf/repeated_field_unittest.cc @@ -95,7 +95,7 @@ TEST(RepeatedField, Small) { EXPECT_EQ(field.size(), 0); // Additional bytes are for 'struct Rep' header. int expected_usage = 4 * sizeof(int) + sizeof(Arena*); - EXPECT_EQ(field.SpaceUsedExcludingSelf(), expected_usage); + EXPECT_GE(field.SpaceUsedExcludingSelf(), expected_usage); } @@ -207,7 +207,7 @@ TEST(RepeatedField, ReserveMoreThanDouble) { RepeatedField field; field.Reserve(20); - EXPECT_EQ(20, ReservedSpace(&field)); + EXPECT_LE(20, ReservedSpace(&field)); } TEST(RepeatedField, ReserveLessThanDouble) { @@ -215,9 +215,10 @@ TEST(RepeatedField, ReserveLessThanDouble) { // field to grow by double instead. RepeatedField field; field.Reserve(20); - field.Reserve(30); + int capacity = field.Capacity(); + field.Reserve(capacity * 1.5); - EXPECT_EQ(40, ReservedSpace(&field)); + EXPECT_LE(2 * capacity, ReservedSpace(&field)); } TEST(RepeatedField, ReserveLessThanExisting) { @@ -229,7 +230,7 @@ TEST(RepeatedField, ReserveLessThanExisting) { field.Reserve(10); EXPECT_EQ(previous_ptr, field.data()); - EXPECT_EQ(20, ReservedSpace(&field)); + EXPECT_LE(20, ReservedSpace(&field)); } TEST(RepeatedField, Resize) { @@ -397,6 +398,16 @@ TEST(RepeatedField, MutableDataIsMutable) { EXPECT_EQ(2, field.Get(0)); } +TEST(RepeatedField, SubscriptOperators) { + RepeatedField field; + field.Add(1); + EXPECT_EQ(1, field.Get(0)); + EXPECT_EQ(1, field[0]); + EXPECT_EQ(field.Mutable(0), &field[0]); + const RepeatedField& const_field = field; + EXPECT_EQ(field.data(), &const_field[0]); +} + TEST(RepeatedField, Truncate) { RepeatedField field; @@ -470,11 +481,11 @@ TEST(RepeatedField, ClearThenReserveMore) { EXPECT_EQ(32, field.size()); field.Clear(); EXPECT_EQ(0, field.size()); - EXPECT_EQ(32, field.Capacity()); + EXPECT_LE(32, field.Capacity()); field.Reserve(1024); EXPECT_EQ(0, field.size()); - EXPECT_EQ(1024, field.Capacity()); + EXPECT_LE(1024, field.Capacity()); // Finish test -- |field| should destroy the cleared-but-not-yet-destroyed // strings. } @@ -629,15 +640,18 @@ TEST(RepeatedPtrField, ReserveMoreThanDouble) { RepeatedPtrField field; field.Reserve(20); - EXPECT_EQ(20, ReservedSpace(&field)); + EXPECT_LE(20, ReservedSpace(&field)); } TEST(RepeatedPtrField, ReserveLessThanDouble) { RepeatedPtrField field; field.Reserve(20); - field.Reserve(30); - EXPECT_EQ(40, ReservedSpace(&field)); + int capacity = field.Capacity(); + // Grow by 1.5x + field.Reserve(capacity + (capacity >> 2)); + + EXPECT_LE(2 * capacity, ReservedSpace(&field)); } TEST(RepeatedPtrField, ReserveLessThanExisting) { @@ -647,7 +661,7 @@ TEST(RepeatedPtrField, ReserveLessThanExisting) { field.Reserve(10); EXPECT_EQ(previous_ptr, field.data()); - EXPECT_EQ(20, ReservedSpace(&field)); + EXPECT_LE(20, ReservedSpace(&field)); } TEST(RepeatedPtrField, ReserveDoesntLoseAllocated) { @@ -918,6 +932,16 @@ TEST(RepeatedPtrField, MutableDataIsMutable) { EXPECT_EQ("2", field.Get(0)); } +TEST(RepeatedPtrField, SubscriptOperators) { + RepeatedPtrField field; + *field.Add() = "1"; + EXPECT_EQ("1", field.Get(0)); + EXPECT_EQ("1", field[0]); + EXPECT_EQ(field.Mutable(0), &field[0]); + const RepeatedPtrField& const_field = field; + EXPECT_EQ(*field.data(), &const_field[0]); +} + TEST(RepeatedPtrField, ExtractSubrange) { // Exhaustively test every subrange in arrays of all sizes from 0 through 9 // with 0 through 3 cleared elements at the end. diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index 019ccf15..195a5d49 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -43,20 +43,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() { SourceContext_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( SourceContext_descriptor_, - SourceContext::default_instance_, + SourceContext::internal_default_instance(), SourceContext_offsets_, -1, -1, -1, sizeof(SourceContext), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_)); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { +void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto); } @@ -65,36 +64,48 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceContext_descriptor_, &SourceContext::default_instance()); + SourceContext_descriptor_, SourceContext::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto() { - delete SourceContext::default_instance_; delete SourceContext_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::internal::GetEmptyString(); + SourceContext::default_instance_.DefaultConstruct(); + SourceContext::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n$google/protobuf/source_context.proto\022\017" "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile" - "_name\030\001 \001(\tBU\n\023com.google.protobufB\022Sour" - "ceContextProtoP\001\240\001\001\242\002\003GPB\252\002\036Google.Proto" - "buf.WellKnownTypesb\006proto3", 186); + "_name\030\001 \001(\tBR\n\023com.google.protobufB\022Sour" + "ceContextProtoP\001\242\002\003GPB\252\002\036Google.Protobuf" + ".WellKnownTypesb\006proto3", 183); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/source_context.proto", &protobuf_RegisterTypes); - SourceContext::default_instance_ = new SourceContext(); - SourceContext::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto() { @@ -102,6 +113,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto } } static_descriptor_initializer_google_2fprotobuf_2fsource_5fcontext_2eproto_; +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; +static void MergeFromFail(int line) { + ::google::protobuf::internal::MergeFromFail(__FILE__, line); +} + +} // namespace + + // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -110,27 +131,25 @@ const int SourceContext::kFileNameFieldNumber; SourceContext::SourceContext() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.SourceContext) } void SourceContext::InitAsDefaultInstance() { - _is_default_instance_ = true; } SourceContext::SourceContext(const SourceContext& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext) } void SourceContext::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; file_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + _cached_size_ = 0; } SourceContext::~SourceContext() { @@ -140,8 +159,6 @@ SourceContext::~SourceContext() { void SourceContext::SharedDtor() { file_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - } } void SourceContext::SetCachedSize(int size) const { @@ -155,11 +172,11 @@ const ::google::protobuf::Descriptor* SourceContext::descriptor() { } const SourceContext& SourceContext::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); + return *internal_default_instance(); } -SourceContext* SourceContext::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed SourceContext::default_instance_; SourceContext* SourceContext::New(::google::protobuf::Arena* arena) const { SourceContext* n = new SourceContext; @@ -256,9 +273,9 @@ void SourceContext::SerializeWithCachedSizes( return target; } -int SourceContext::ByteSize() const { +size_t SourceContext::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceContext) - int total_size = 0; + size_t total_size = 0; // optional string file_name = 1; if (this->file_name().size() > 0) { @@ -267,18 +284,17 @@ int SourceContext::ByteSize() const { this->file_name()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void SourceContext::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceContext) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const SourceContext* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const SourceContext* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -286,15 +302,21 @@ void SourceContext::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceContext) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void SourceContext::MergeFrom(const SourceContext& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceContext) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void SourceContext::UnsafeMergeFrom(const SourceContext& from) { + GOOGLE_DCHECK(&from != this); if (from.file_name().size() > 0) { file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_); @@ -312,7 +334,7 @@ void SourceContext::CopyFrom(const SourceContext& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceContext) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool SourceContext::IsInitialized() const { @@ -345,37 +367,37 @@ void SourceContext::InternalSwap(SourceContext* other) { void SourceContext::clear_file_name() { file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - const ::std::string& SourceContext::file_name() const { +const ::std::string& SourceContext::file_name() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name) return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void SourceContext::set_file_name(const ::std::string& value) { +void SourceContext::set_file_name(const ::std::string& value) { file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name) } - void SourceContext::set_file_name(const char* value) { +void SourceContext::set_file_name(const char* value) { file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceContext.file_name) } - void SourceContext::set_file_name(const char* value, size_t size) { +void SourceContext::set_file_name(const char* value, size_t size) { file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceContext.file_name) } - ::std::string* SourceContext::mutable_file_name() { +::std::string* SourceContext::mutable_file_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.SourceContext.file_name) return file_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* SourceContext::release_file_name() { +::std::string* SourceContext::release_file_name() { // @@protoc_insertion_point(field_release:google.protobuf.SourceContext.file_name) return file_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void SourceContext::set_allocated_file_name(::std::string* file_name) { +void SourceContext::set_allocated_file_name(::std::string* file_name) { if (file_name != NULL) { } else { diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 163b1eb0..b82f1f27 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -34,6 +34,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto(); @@ -56,6 +57,10 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ static const ::google::protobuf::Descriptor* descriptor(); static const SourceContext& default_instance(); + static inline const SourceContext* internal_default_instance() { + return &default_instance_.get(); + } + void Swap(SourceContext* other); // implements Message ---------------------------------------------- @@ -70,7 +75,7 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -86,6 +91,7 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(SourceContext* other); + void UnsafeMergeFrom(const SourceContext& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -116,15 +122,15 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; ::google::protobuf::internal::ArenaStringPtr file_name_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto(); void InitAsDefaultInstance(); - static SourceContext* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/source_context.proto b/src/google/protobuf/source_context.proto index a2c08e2b..79137ce8 100644 --- a/src/google/protobuf/source_context.proto +++ b/src/google/protobuf/source_context.proto @@ -36,7 +36,6 @@ option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option java_package = "com.google.protobuf"; option java_outer_classname = "SourceContextProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; // `SourceContext` represents information about the source of a diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index 998ea0e0..c609f879 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -59,14 +59,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() { Struct_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Struct_descriptor_, - Struct::default_instance_, + Struct::internal_default_instance(), Struct_offsets_, -1, -1, -1, sizeof(Struct), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _internal_metadata_)); Struct_FieldsEntry_descriptor_ = Struct_descriptor_->nested_type(0); Value_descriptor_ = file->message_type(1); static const int Value_offsets_[7] = { @@ -81,7 +80,7 @@ void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() { Value_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Value_descriptor_, - Value::default_instance_, + Value::internal_default_instance(), Value_offsets_, -1, -1, @@ -89,8 +88,7 @@ void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() { Value_default_oneof_instance_, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _oneof_case_[0]), sizeof(Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _internal_metadata_)); ListValue_descriptor_ = file->message_type(2); static const int ListValue_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, values_), @@ -98,21 +96,20 @@ void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() { ListValue_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ListValue_descriptor_, - ListValue::default_instance_, + ListValue::internal_default_instance(), ListValue_offsets_, -1, -1, -1, sizeof(ListValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_)); NullValue_descriptor_ = file->enum_type(0); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { +void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto); } @@ -121,7 +118,7 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Struct_descriptor_, &Struct::default_instance()); + Struct_descriptor_, Struct::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( Struct_FieldsEntry_descriptor_, ::google::protobuf::internal::MapEntry< @@ -132,30 +129,43 @@ void protobuf_RegisterTypes(const ::std::string&) { 0>::CreateDefaultInstance( Struct_FieldsEntry_descriptor_)); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Value_descriptor_, &Value::default_instance()); + Value_descriptor_, Value::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ListValue_descriptor_, &ListValue::default_instance()); + ListValue_descriptor_, ListValue::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto() { - delete Struct::default_instance_; delete Struct_reflection_; - delete Value::default_instance_; delete Value_default_oneof_instance_; delete Value_reflection_; - delete ListValue::default_instance_; delete ListValue_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::internal::GetEmptyString(); + Struct::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + Value::default_instance_.DefaultConstruct(); + Value_default_oneof_instance_ = new ValueOneofInstance(); + ListValue::default_instance_.DefaultConstruct(); + Struct::default_instance_.get_mutable()->InitAsDefaultInstance(); + Value::default_instance_.get_mutable()->InitAsDefaultInstance(); + ListValue::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\034google/protobuf/struct.proto\022\017google.p" "rotobuf\"\204\001\n\006Struct\0223\n\006fields\030\001 \003(\0132#.goo" @@ -171,21 +181,19 @@ void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto() { "es\030\001 \003(\0132\026.google.protobuf.Value*\033\n\tNull" "Value\022\016\n\nNULL_VALUE\020\000B\201\001\n\023com.google.pro" "tobufB\013StructProtoP\001Z1github.com/golang/" - "protobuf/ptypes/struct;structpb\240\001\001\242\002\003GPB" + "protobuf/ptypes/struct;structpb\370\001\001\242\002\003GPB" "\252\002\036Google.Protobuf.WellKnownTypesb\006proto" "3", 641); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/struct.proto", &protobuf_RegisterTypes); - Struct::default_instance_ = new Struct(); - Value::default_instance_ = new Value(); - Value_default_oneof_instance_ = new ValueOneofInstance(); - ListValue::default_instance_ = new ListValue(); - Struct::default_instance_->InitAsDefaultInstance(); - Value::default_instance_->InitAsDefaultInstance(); - ListValue::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto() { @@ -197,7 +205,7 @@ const ::google::protobuf::EnumDescriptor* NullValue_descriptor() { return NullValue_descriptor_; } bool NullValue_IsValid(int value) { - switch(value) { + switch (value) { case 0: return true; default: @@ -206,6 +214,16 @@ bool NullValue_IsValid(int value) { } +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; +static void MergeFromFail(int line) { + ::google::protobuf::internal::MergeFromFail(__FILE__, line); +} + +} // namespace + + // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -214,30 +232,39 @@ const int Struct::kFieldsFieldNumber; Struct::Struct() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Struct) } +Struct::Struct(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + fields_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Struct) +} void Struct::InitAsDefaultInstance() { - _is_default_instance_ = true; } Struct::Struct(const Struct& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Struct) } void Struct::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; fields_.SetAssignDescriptorCallback( protobuf_AssignDescriptorsOnce); fields_.SetEntryDescriptor( &::google::protobuf::Struct_FieldsEntry_descriptor_); + _cached_size_ = 0; } Struct::~Struct() { @@ -246,10 +273,19 @@ Struct::~Struct() { } void Struct::SharedDtor() { - if (this != default_instance_) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + } +void Struct::ArenaDtor(void* object) { + Struct* _this = reinterpret_cast< Struct* >(object); + (void)_this; +} +void Struct::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Struct::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -261,18 +297,14 @@ const ::google::protobuf::Descriptor* Struct::descriptor() { } const Struct& Struct::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + return *internal_default_instance(); } -Struct* Struct::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Struct::default_instance_; Struct* Struct::New(::google::protobuf::Arena* arena) const { - Struct* n = new Struct; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage(arena); } void Struct::Clear() { @@ -373,6 +405,9 @@ void Struct::SerializeWithCachedSizes( items[i]->first, items[i]->second)); ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 1, *entry, output); + if (entry->GetArena() != NULL) { + entry.release(); + } Utf8Check::Check(items[i]); } } else { @@ -384,6 +419,9 @@ void Struct::SerializeWithCachedSizes( it->first, it->second)); ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 1, *entry, output); + if (entry->GetArena() != NULL) { + entry.release(); + } Utf8Check::Check(&*it); } } @@ -431,6 +469,9 @@ void Struct::SerializeWithCachedSizes( InternalWriteMessageNoVirtualToArray( 1, *entry, deterministic, target); ; + if (entry->GetArena() != NULL) { + entry.release(); + } Utf8Check::Check(items[i]); } } else { @@ -444,6 +485,9 @@ void Struct::SerializeWithCachedSizes( InternalWriteMessageNoVirtualToArray( 1, *entry, deterministic, target); ; + if (entry->GetArena() != NULL) { + entry.release(); + } Utf8Check::Check(&*it); } } @@ -453,35 +497,41 @@ void Struct::SerializeWithCachedSizes( return target; } -int Struct::ByteSize() const { +size_t Struct::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Struct) - int total_size = 0; + size_t total_size = 0; // map fields = 1; - total_size += 1 * this->fields_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->fields_size()); { ::google::protobuf::scoped_ptr entry; for (::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_iterator it = this->fields().begin(); it != this->fields().end(); ++it) { + if (entry.get() != NULL && entry->GetArena() != NULL) { + entry.release(); + } entry.reset(fields_.NewEntryWrapper(it->first, it->second)); total_size += ::google::protobuf::internal::WireFormatLite:: MessageSizeNoVirtual(*entry); } + if (entry.get() != NULL && entry->GetArena() != NULL) { + entry.release(); + } } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Struct::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Struct) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Struct* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Struct* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -489,15 +539,21 @@ void Struct::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Struct) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Struct::MergeFrom(const Struct& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Struct) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Struct::UnsafeMergeFrom(const Struct& from) { + GOOGLE_DCHECK(&from != this); fields_.MergeFrom(from.fields_); } @@ -512,7 +568,7 @@ void Struct::CopyFrom(const Struct& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Struct) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Struct::IsInitialized() const { @@ -522,6 +578,18 @@ bool Struct::IsInitialized() const { void Struct::Swap(Struct* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + Struct temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void Struct::UnsafeArenaSwap(Struct* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void Struct::InternalSwap(Struct* other) { @@ -574,33 +642,43 @@ const int Value::kListValueFieldNumber; Value::Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Value) } +Value::Value(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Value) +} void Value::InitAsDefaultInstance() { - _is_default_instance_ = true; Value_default_oneof_instance_->null_value_ = 0; Value_default_oneof_instance_->number_value_ = 0; Value_default_oneof_instance_->string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); Value_default_oneof_instance_->bool_value_ = false; - Value_default_oneof_instance_->struct_value_ = const_cast< ::google::protobuf::Struct*>(&::google::protobuf::Struct::default_instance()); - Value_default_oneof_instance_->list_value_ = const_cast< ::google::protobuf::ListValue*>(&::google::protobuf::ListValue::default_instance()); + Value_default_oneof_instance_->struct_value_ = const_cast< ::google::protobuf::Struct*>( + ::google::protobuf::Struct::internal_default_instance()); + Value_default_oneof_instance_->list_value_ = const_cast< ::google::protobuf::ListValue*>( + ::google::protobuf::ListValue::internal_default_instance()); } Value::Value(const Value& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Value) } void Value::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; clear_has_kind(); + _cached_size_ = 0; } Value::~Value() { @@ -609,13 +687,22 @@ Value::~Value() { } void Value::SharedDtor() { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; + } + if (has_kind()) { clear_kind(); } - if (this != default_instance_) { - } } +void Value::ArenaDtor(void* object) { + Value* _this = reinterpret_cast< Value* >(object); + (void)_this; +} +void Value::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Value::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -627,23 +714,19 @@ const ::google::protobuf::Descriptor* Value::descriptor() { } const Value& Value::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + return *internal_default_instance(); } -Value* Value::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Value::default_instance_; Value* Value::New(::google::protobuf::Arena* arena) const { - Value* n = new Value; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage(arena); } void Value::clear_kind() { // @@protoc_insertion_point(one_of_clear_start:google.protobuf.Value) - switch(kind_case()) { + switch (kind_case()) { case kNullValue: { // No need to clear break; @@ -653,7 +736,8 @@ void Value::clear_kind() { break; } case kStringValue: { - kind_.string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + kind_.string_value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); break; } case kBoolValue: { @@ -661,11 +745,15 @@ void Value::clear_kind() { break; } case kStructValue: { - delete kind_.struct_value_; + if (GetArenaNoVirtual() == NULL) { + delete kind_.struct_value_; + } break; } case kListValue: { - delete kind_.list_value_; + if (GetArenaNoVirtual() == NULL) { + delete kind_.list_value_; + } break; } case KIND_NOT_SET: { @@ -702,14 +790,13 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(17)) goto parse_number_value; + goto after_list_value; break; } // optional double number_value = 2; case 2: { if (tag == 17) { - parse_number_value: clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -718,14 +805,13 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_string_value; + goto after_list_value; break; } // optional string string_value = 3; case 3: { if (tag == 26) { - parse_string_value: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_string_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -735,14 +821,13 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(32)) goto parse_bool_value; + goto after_list_value; break; } // optional bool bool_value = 4; case 4: { if (tag == 32) { - parse_bool_value: clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -751,14 +836,13 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(42)) goto parse_struct_value; + goto after_list_value; break; } // optional .google.protobuf.Struct struct_value = 5; case 5: { if (tag == 42) { - parse_struct_value: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_struct_value())); } else { @@ -777,6 +861,7 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } + after_list_value: if (input->ExpectAtEnd()) goto success; break; } @@ -895,9 +980,9 @@ void Value::SerializeWithCachedSizes( return target; } -int Value::ByteSize() const { +size_t Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Value) - int total_size = 0; + size_t total_size = 0; switch (kind_case()) { // optional .google.protobuf.NullValue null_value = 1; @@ -941,18 +1026,17 @@ int Value::ByteSize() const { break; } } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Value* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Value* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -960,15 +1044,21 @@ void Value::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Value) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Value::MergeFrom(const Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Value::UnsafeMergeFrom(const Value& from) { + GOOGLE_DCHECK(&from != this); switch (from.kind_case()) { case kNullValue: { set_null_value(from.null_value()); @@ -1011,7 +1101,7 @@ void Value::CopyFrom(const Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Value) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Value::IsInitialized() const { @@ -1021,6 +1111,18 @@ bool Value::IsInitialized() const { void Value::Swap(Value* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + Value temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void Value::UnsafeArenaSwap(Value* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void Value::InternalSwap(Value* other) { @@ -1054,14 +1156,14 @@ void Value::clear_null_value() { clear_has_kind(); } } - ::google::protobuf::NullValue Value::null_value() const { +::google::protobuf::NullValue Value::null_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.null_value) if (has_null_value()) { return static_cast< ::google::protobuf::NullValue >(kind_.null_value_); } return static_cast< ::google::protobuf::NullValue >(0); } - void Value::set_null_value(::google::protobuf::NullValue value) { +void Value::set_null_value(::google::protobuf::NullValue value) { if (!has_null_value()) { clear_kind(); set_has_null_value(); @@ -1083,14 +1185,14 @@ void Value::clear_number_value() { clear_has_kind(); } } - double Value::number_value() const { +double Value::number_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.number_value) if (has_number_value()) { return kind_.number_value_; } return 0; } - void Value::set_number_value(double value) { +void Value::set_number_value(double value) { if (!has_number_value()) { clear_kind(); set_has_number_value(); @@ -1108,77 +1210,105 @@ void Value::set_has_string_value() { } void Value::clear_string_value() { if (has_string_value()) { - kind_.string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + kind_.string_value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); clear_has_kind(); } } - const ::std::string& Value::string_value() const { +const ::std::string& Value::string_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.string_value) if (has_string_value()) { - return kind_.string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return kind_.string_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); } - void Value::set_string_value(const ::std::string& value) { - // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) +void Value::set_string_value(const ::std::string& value) { if (!has_string_value()) { clear_kind(); set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) } - void Value::set_string_value(const char* value) { +void Value::set_string_value(const char* value) { if (!has_string_value()) { clear_kind(); set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(value)); + kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Value.string_value) } - void Value::set_string_value(const char* value, size_t size) { +void Value::set_string_value(const char* value, + size_t size) { if (!has_string_value()) { clear_kind(); set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size)); + kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value) } - ::std::string* Value::mutable_string_value() { +::std::string* Value::mutable_string_value() { if (!has_string_value()) { clear_kind(); set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } + return kind_.string_value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_mutable:google.protobuf.Value.string_value) - return kind_.string_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Value::release_string_value() { +::std::string* Value::release_string_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.string_value) if (has_string_value()) { clear_has_kind(); - return kind_.string_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return kind_.string_value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } else { return NULL; } } - void Value::set_allocated_string_value(::std::string* string_value) { +::std::string* Value::unsafe_arena_release_string_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.string_value) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (has_string_value()) { + clear_has_kind(); + return kind_.string_value_.UnsafeArenaRelease( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + } else { + return NULL; + } +} +void Value::set_allocated_string_value(::std::string* string_value) { if (!has_string_value()) { kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } clear_kind(); if (string_value != NULL) { set_has_string_value(); - kind_.string_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - string_value); + kind_.string_value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value, + GetArenaNoVirtual()); } // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.string_value) } +void Value::unsafe_arena_set_allocated_string_value(::std::string* string_value) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (!has_string_value()) { + kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + clear_kind(); + if (string_value) { + set_has_string_value(); + kind_.string_value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value, GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.string_value) +} // optional bool bool_value = 4; bool Value::has_bool_value() const { @@ -1193,14 +1323,14 @@ void Value::clear_bool_value() { clear_has_kind(); } } - bool Value::bool_value() const { +bool Value::bool_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.bool_value) if (has_bool_value()) { return kind_.bool_value_; } return false; } - void Value::set_bool_value(bool value) { +void Value::set_bool_value(bool value) { if (!has_bool_value()) { clear_kind(); set_has_bool_value(); @@ -1218,7 +1348,9 @@ void Value::set_has_struct_value() { } void Value::clear_struct_value() { if (has_struct_value()) { - delete kind_.struct_value_; + if (GetArenaNoVirtual() == NULL) { + delete kind_.struct_value_; + } clear_has_kind(); } } @@ -1232,13 +1364,51 @@ void Value::clear_struct_value() { if (!has_struct_value()) { clear_kind(); set_has_struct_value(); - kind_.struct_value_ = new ::google::protobuf::Struct; + kind_.struct_value_ = + ::google::protobuf::Arena::CreateMessage< ::google::protobuf::Struct >( + GetArenaNoVirtual()); } // @@protoc_insertion_point(field_mutable:google.protobuf.Value.struct_value) return kind_.struct_value_; } ::google::protobuf::Struct* Value::release_struct_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.struct_value) + if (has_struct_value()) { + clear_has_kind(); + if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Struct* temp = new ::google::protobuf::Struct(*kind_.struct_value_); + kind_.struct_value_ = NULL; + return temp; + } else { + ::google::protobuf::Struct* temp = kind_.struct_value_; + kind_.struct_value_ = NULL; + return temp; + } + } else { + return NULL; + } +} +void Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value) { + clear_kind(); + if (struct_value) { + if (GetArenaNoVirtual() != NULL && + ::google::protobuf::Arena::GetArena(struct_value) == NULL) { + GetArenaNoVirtual()->Own(struct_value); + } else if (GetArenaNoVirtual() != + ::google::protobuf::Arena::GetArena(struct_value)) { + ::google::protobuf::Struct* new_struct_value = + ::google::protobuf::Arena::CreateMessage< ::google::protobuf::Struct >( + GetArenaNoVirtual()); + new_struct_value->CopyFrom(*struct_value); + struct_value = new_struct_value; + } + set_has_struct_value(); + kind_.struct_value_ = struct_value; + } + // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value) +} + ::google::protobuf::Struct* Value::unsafe_arena_release_struct_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.struct_value) if (has_struct_value()) { clear_has_kind(); ::google::protobuf::Struct* temp = kind_.struct_value_; @@ -1248,13 +1418,13 @@ void Value::clear_struct_value() { return NULL; } } -void Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value) { + void Value::unsafe_arena_set_allocated_struct_value(::google::protobuf::Struct* struct_value) { clear_kind(); if (struct_value) { set_has_struct_value(); kind_.struct_value_ = struct_value; } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value) } // optional .google.protobuf.ListValue list_value = 6; @@ -1266,7 +1436,9 @@ void Value::set_has_list_value() { } void Value::clear_list_value() { if (has_list_value()) { - delete kind_.list_value_; + if (GetArenaNoVirtual() == NULL) { + delete kind_.list_value_; + } clear_has_kind(); } } @@ -1280,13 +1452,51 @@ void Value::clear_list_value() { if (!has_list_value()) { clear_kind(); set_has_list_value(); - kind_.list_value_ = new ::google::protobuf::ListValue; + kind_.list_value_ = + ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ListValue >( + GetArenaNoVirtual()); } // @@protoc_insertion_point(field_mutable:google.protobuf.Value.list_value) return kind_.list_value_; } ::google::protobuf::ListValue* Value::release_list_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.list_value) + if (has_list_value()) { + clear_has_kind(); + if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::ListValue* temp = new ::google::protobuf::ListValue(*kind_.list_value_); + kind_.list_value_ = NULL; + return temp; + } else { + ::google::protobuf::ListValue* temp = kind_.list_value_; + kind_.list_value_ = NULL; + return temp; + } + } else { + return NULL; + } +} +void Value::set_allocated_list_value(::google::protobuf::ListValue* list_value) { + clear_kind(); + if (list_value) { + if (GetArenaNoVirtual() != NULL && + ::google::protobuf::Arena::GetArena(list_value) == NULL) { + GetArenaNoVirtual()->Own(list_value); + } else if (GetArenaNoVirtual() != + ::google::protobuf::Arena::GetArena(list_value)) { + ::google::protobuf::ListValue* new_list_value = + ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ListValue >( + GetArenaNoVirtual()); + new_list_value->CopyFrom(*list_value); + list_value = new_list_value; + } + set_has_list_value(); + kind_.list_value_ = list_value; + } + // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value) +} + ::google::protobuf::ListValue* Value::unsafe_arena_release_list_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.list_value) if (has_list_value()) { clear_has_kind(); ::google::protobuf::ListValue* temp = kind_.list_value_; @@ -1296,13 +1506,13 @@ void Value::clear_list_value() { return NULL; } } -void Value::set_allocated_list_value(::google::protobuf::ListValue* list_value) { + void Value::unsafe_arena_set_allocated_list_value(::google::protobuf::ListValue* list_value) { clear_kind(); if (list_value) { set_has_list_value(); kind_.list_value_ = list_value; } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.list_value) } bool Value::has_kind() const { @@ -1324,24 +1534,34 @@ const int ListValue::kValuesFieldNumber; ListValue::ListValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ListValue) } +ListValue::ListValue(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + values_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.ListValue) +} void ListValue::InitAsDefaultInstance() { - _is_default_instance_ = true; } ListValue::ListValue(const ListValue& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.ListValue) } void ListValue::SharedCtor() { - _is_default_instance_ = false; _cached_size_ = 0; } @@ -1351,10 +1571,19 @@ ListValue::~ListValue() { } void ListValue::SharedDtor() { - if (this != default_instance_) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + } +void ListValue::ArenaDtor(void* object) { + ListValue* _this = reinterpret_cast< ListValue* >(object); + (void)_this; +} +void ListValue::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void ListValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -1366,18 +1595,14 @@ const ::google::protobuf::Descriptor* ListValue::descriptor() { } const ListValue& ListValue::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + return *internal_default_instance(); } -ListValue* ListValue::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ListValue::default_instance_; ListValue* ListValue::New(::google::protobuf::Arena* arena) const { - ListValue* n = new ListValue; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage(arena); } void ListValue::Clear() { @@ -1459,30 +1684,32 @@ void ListValue::SerializeWithCachedSizes( return target; } -int ListValue::ByteSize() const { +size_t ListValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.ListValue) - int total_size = 0; + size_t total_size = 0; // repeated .google.protobuf.Value values = 1; - total_size += 1 * this->values_size(); - for (int i = 0; i < this->values_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->values(i)); + { + unsigned int count = this->values_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->values(i)); + } } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void ListValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ListValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const ListValue* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ListValue* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -1490,15 +1717,21 @@ void ListValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ListValue) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void ListValue::MergeFrom(const ListValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ListValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void ListValue::UnsafeMergeFrom(const ListValue& from) { + GOOGLE_DCHECK(&from != this); values_.MergeFrom(from.values_); } @@ -1513,7 +1746,7 @@ void ListValue::CopyFrom(const ListValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ListValue) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ListValue::IsInitialized() const { @@ -1523,6 +1756,18 @@ bool ListValue::IsInitialized() const { void ListValue::Swap(ListValue* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ListValue temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void ListValue::UnsafeArenaSwap(ListValue* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void ListValue::InternalSwap(ListValue* other) { diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index d98a12e2..34b9bfb8 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -37,6 +37,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); @@ -78,9 +79,18 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc return *this; } + inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } + inline void* GetMaybeArenaPointer() const { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const Struct& default_instance(); + static inline const Struct* internal_default_instance() { + return &default_instance_.get(); + } + + void UnsafeArenaSwap(Struct* other); void Swap(Struct* other); // implements Message ---------------------------------------------- @@ -95,7 +105,7 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -111,6 +121,12 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Struct* other); + void UnsafeMergeFrom(const Struct& from); + protected: + explicit Struct(::google::protobuf::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -140,7 +156,9 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; + friend class ::google::protobuf::Arena; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; typedef ::google::protobuf::internal::MapEntryLite< ::std::string, ::google::protobuf::Value, ::google::protobuf::internal::WireFormatLite::TYPE_STRING, @@ -153,12 +171,13 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > fields_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); void InitAsDefaultInstance(); - static Struct* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -174,6 +193,10 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ return *this; } + inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } + inline void* GetMaybeArenaPointer() const { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const Value& default_instance(); @@ -187,6 +210,11 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ KIND_NOT_SET = 0, }; + static inline const Value* internal_default_instance() { + return &default_instance_.get(); + } + + void UnsafeArenaSwap(Value* other); void Swap(Value* other); // implements Message ---------------------------------------------- @@ -201,7 +229,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -217,6 +245,12 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Value* other); + void UnsafeMergeFrom(const Value& from); + protected: + explicit Value(::google::protobuf::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -263,6 +297,9 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ ::std::string* mutable_string_value(); ::std::string* release_string_value(); void set_allocated_string_value(::std::string* string_value); + ::std::string* unsafe_arena_release_string_value(); + void unsafe_arena_set_allocated_string_value( + ::std::string* string_value); // optional bool bool_value = 4; private: @@ -277,19 +314,37 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ bool has_struct_value() const; void clear_struct_value(); static const int kStructValueFieldNumber = 5; + private: + void _slow_mutable_struct_value(); + void _slow_set_allocated_struct_value( + ::google::protobuf::Arena* message_arena, ::google::protobuf::Struct** struct_value); + ::google::protobuf::Struct* _slow_release_struct_value(); + public: const ::google::protobuf::Struct& struct_value() const; ::google::protobuf::Struct* mutable_struct_value(); ::google::protobuf::Struct* release_struct_value(); void set_allocated_struct_value(::google::protobuf::Struct* struct_value); + ::google::protobuf::Struct* unsafe_arena_release_struct_value(); + void unsafe_arena_set_allocated_struct_value( + ::google::protobuf::Struct* struct_value); // optional .google.protobuf.ListValue list_value = 6; bool has_list_value() const; void clear_list_value(); static const int kListValueFieldNumber = 6; + private: + void _slow_mutable_list_value(); + void _slow_set_allocated_list_value( + ::google::protobuf::Arena* message_arena, ::google::protobuf::ListValue** list_value); + ::google::protobuf::ListValue* _slow_release_list_value(); + public: const ::google::protobuf::ListValue& list_value() const; ::google::protobuf::ListValue* mutable_list_value(); ::google::protobuf::ListValue* release_list_value(); void set_allocated_list_value(::google::protobuf::ListValue* list_value); + ::google::protobuf::ListValue* unsafe_arena_release_list_value(); + void unsafe_arena_set_allocated_list_value( + ::google::protobuf::ListValue* list_value); KindCase kind_case() const; // @@protoc_insertion_point(class_scope:google.protobuf.Value) @@ -306,7 +361,9 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ inline void clear_has_kind(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; + friend class ::google::protobuf::Arena; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; union KindUnion { KindUnion() {} int null_value_; @@ -319,12 +376,13 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ mutable int _cached_size_; ::google::protobuf::uint32 _oneof_case_[1]; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); void InitAsDefaultInstance(); - static Value* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // ------------------------------------------------------------------- @@ -340,9 +398,18 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro return *this; } + inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } + inline void* GetMaybeArenaPointer() const { + return MaybeArenaPtr(); + } static const ::google::protobuf::Descriptor* descriptor(); static const ListValue& default_instance(); + static inline const ListValue* internal_default_instance() { + return &default_instance_.get(); + } + + void UnsafeArenaSwap(ListValue* other); void Swap(ListValue* other); // implements Message ---------------------------------------------- @@ -357,7 +424,7 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -373,6 +440,12 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(ListValue* other); + void UnsafeMergeFrom(const ListValue& from); + protected: + explicit ListValue(::google::protobuf::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); @@ -404,15 +477,18 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; - bool _is_default_instance_; + friend class ::google::protobuf::Arena; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value > values_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); void InitAsDefaultInstance(); - static ListValue* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // =================================================================== @@ -511,25 +587,26 @@ inline void Value::set_has_string_value() { } inline void Value::clear_string_value() { if (has_string_value()) { - kind_.string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + kind_.string_value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); clear_has_kind(); } } inline const ::std::string& Value::string_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.string_value) if (has_string_value()) { - return kind_.string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return kind_.string_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); } inline void Value::set_string_value(const ::std::string& value) { - // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) if (!has_string_value()) { clear_kind(); set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) } inline void Value::set_string_value(const char* value) { @@ -538,18 +615,20 @@ inline void Value::set_string_value(const char* value) { set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(value)); + kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Value.string_value) } -inline void Value::set_string_value(const char* value, size_t size) { +inline void Value::set_string_value(const char* value, + size_t size) { if (!has_string_value()) { clear_kind(); set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size)); + kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value) } inline ::std::string* Value::mutable_string_value() { @@ -558,14 +637,27 @@ inline ::std::string* Value::mutable_string_value() { set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } + return kind_.string_value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_mutable:google.protobuf.Value.string_value) - return kind_.string_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* Value::release_string_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.string_value) if (has_string_value()) { clear_has_kind(); - return kind_.string_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return kind_.string_value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); + } else { + return NULL; + } +} +inline ::std::string* Value::unsafe_arena_release_string_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.string_value) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (has_string_value()) { + clear_has_kind(); + return kind_.string_value_.UnsafeArenaRelease( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } else { return NULL; } @@ -577,11 +669,23 @@ inline void Value::set_allocated_string_value(::std::string* string_value) { clear_kind(); if (string_value != NULL) { set_has_string_value(); - kind_.string_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - string_value); + kind_.string_value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value, + GetArenaNoVirtual()); } // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.string_value) } +inline void Value::unsafe_arena_set_allocated_string_value(::std::string* string_value) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (!has_string_value()) { + kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + clear_kind(); + if (string_value) { + set_has_string_value(); + kind_.string_value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value, GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.string_value) +} // optional bool bool_value = 4; inline bool Value::has_bool_value() const { @@ -621,7 +725,9 @@ inline void Value::set_has_struct_value() { } inline void Value::clear_struct_value() { if (has_struct_value()) { - delete kind_.struct_value_; + if (GetArenaNoVirtual() == NULL) { + delete kind_.struct_value_; + } clear_has_kind(); } } @@ -635,13 +741,51 @@ inline ::google::protobuf::Struct* Value::mutable_struct_value() { if (!has_struct_value()) { clear_kind(); set_has_struct_value(); - kind_.struct_value_ = new ::google::protobuf::Struct; + kind_.struct_value_ = + ::google::protobuf::Arena::CreateMessage< ::google::protobuf::Struct >( + GetArenaNoVirtual()); } // @@protoc_insertion_point(field_mutable:google.protobuf.Value.struct_value) return kind_.struct_value_; } inline ::google::protobuf::Struct* Value::release_struct_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.struct_value) + if (has_struct_value()) { + clear_has_kind(); + if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Struct* temp = new ::google::protobuf::Struct(*kind_.struct_value_); + kind_.struct_value_ = NULL; + return temp; + } else { + ::google::protobuf::Struct* temp = kind_.struct_value_; + kind_.struct_value_ = NULL; + return temp; + } + } else { + return NULL; + } +} +inline void Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value) { + clear_kind(); + if (struct_value) { + if (GetArenaNoVirtual() != NULL && + ::google::protobuf::Arena::GetArena(struct_value) == NULL) { + GetArenaNoVirtual()->Own(struct_value); + } else if (GetArenaNoVirtual() != + ::google::protobuf::Arena::GetArena(struct_value)) { + ::google::protobuf::Struct* new_struct_value = + ::google::protobuf::Arena::CreateMessage< ::google::protobuf::Struct >( + GetArenaNoVirtual()); + new_struct_value->CopyFrom(*struct_value); + struct_value = new_struct_value; + } + set_has_struct_value(); + kind_.struct_value_ = struct_value; + } + // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value) +} +inline ::google::protobuf::Struct* Value::unsafe_arena_release_struct_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.struct_value) if (has_struct_value()) { clear_has_kind(); ::google::protobuf::Struct* temp = kind_.struct_value_; @@ -651,13 +795,13 @@ inline ::google::protobuf::Struct* Value::release_struct_value() { return NULL; } } -inline void Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value) { +inline void Value::unsafe_arena_set_allocated_struct_value(::google::protobuf::Struct* struct_value) { clear_kind(); if (struct_value) { set_has_struct_value(); kind_.struct_value_ = struct_value; } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value) } // optional .google.protobuf.ListValue list_value = 6; @@ -669,7 +813,9 @@ inline void Value::set_has_list_value() { } inline void Value::clear_list_value() { if (has_list_value()) { - delete kind_.list_value_; + if (GetArenaNoVirtual() == NULL) { + delete kind_.list_value_; + } clear_has_kind(); } } @@ -683,13 +829,51 @@ inline ::google::protobuf::ListValue* Value::mutable_list_value() { if (!has_list_value()) { clear_kind(); set_has_list_value(); - kind_.list_value_ = new ::google::protobuf::ListValue; + kind_.list_value_ = + ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ListValue >( + GetArenaNoVirtual()); } // @@protoc_insertion_point(field_mutable:google.protobuf.Value.list_value) return kind_.list_value_; } inline ::google::protobuf::ListValue* Value::release_list_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.list_value) + if (has_list_value()) { + clear_has_kind(); + if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::ListValue* temp = new ::google::protobuf::ListValue(*kind_.list_value_); + kind_.list_value_ = NULL; + return temp; + } else { + ::google::protobuf::ListValue* temp = kind_.list_value_; + kind_.list_value_ = NULL; + return temp; + } + } else { + return NULL; + } +} +inline void Value::set_allocated_list_value(::google::protobuf::ListValue* list_value) { + clear_kind(); + if (list_value) { + if (GetArenaNoVirtual() != NULL && + ::google::protobuf::Arena::GetArena(list_value) == NULL) { + GetArenaNoVirtual()->Own(list_value); + } else if (GetArenaNoVirtual() != + ::google::protobuf::Arena::GetArena(list_value)) { + ::google::protobuf::ListValue* new_list_value = + ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ListValue >( + GetArenaNoVirtual()); + new_list_value->CopyFrom(*list_value); + list_value = new_list_value; + } + set_has_list_value(); + kind_.list_value_ = list_value; + } + // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value) +} +inline ::google::protobuf::ListValue* Value::unsafe_arena_release_list_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.list_value) if (has_list_value()) { clear_has_kind(); ::google::protobuf::ListValue* temp = kind_.list_value_; @@ -699,13 +883,13 @@ inline ::google::protobuf::ListValue* Value::release_list_value() { return NULL; } } -inline void Value::set_allocated_list_value(::google::protobuf::ListValue* list_value) { +inline void Value::unsafe_arena_set_allocated_list_value(::google::protobuf::ListValue* list_value) { clear_kind(); if (list_value) { set_has_list_value(); kind_.list_value_ = list_value; } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.list_value) } inline bool Value::has_kind() const { diff --git a/src/google/protobuf/struct.proto b/src/google/protobuf/struct.proto index beeba811..7d7808e7 100644 --- a/src/google/protobuf/struct.proto +++ b/src/google/protobuf/struct.proto @@ -33,11 +33,11 @@ syntax = "proto3"; package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option cc_enable_arenas = true; option go_package = "github.com/golang/protobuf/ptypes/struct;structpb"; option java_package = "com.google.protobuf"; option java_outer_classname = "StructProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index d7f93b4c..376be5f7 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -326,6 +326,61 @@ static inline uint64 bswap_64(uint64 x) { #endif +// =================================================================== +// from google3/util/bits/bits.h + +class Bits { + public: + static uint32 Log2FloorNonZero(uint32 n) { +#if defined(__GNUC__) + return 31 ^ __builtin_clz(n); +#elif defined(COMPILER_MSVC) && defined(_M_IX86) + _asm { + bsr ebx, n + mov n, ebx + } + return n; +#else + return Log2FloorNonZero_Portable(n); +#endif + } + + static uint64 Log2FloorNonZero64(uint64 n) { +#if defined(__GNUC__) + return 63 ^ __builtin_clzll(n); +#else + return Log2FloorNonZero64_Portable(n); +#endif + } + private: + static int Log2FloorNonZero_Portable(uint32 n) { + if (n == 0) + return -1; + int log = 0; + uint32 value = n; + for (int i = 4; i >= 0; --i) { + int shift = (1 << i); + uint32 x = value >> shift; + if (x != 0) { + value = x; + log += shift; + } + } + assert(value == 1); + return log; + } + + static int Log2FloorNonZero64_Portable(uint64 n) { + const uint32 topbits = static_cast(n >> 32); + if (topbits == 0) { + // Top bits are zero, so scan in bottom bits + return Log2FloorNonZero(static_cast(n)); + } else { + return 32 + Log2FloorNonZero(topbits); + } + } +}; + // =================================================================== // from google3/util/endian/endian.h LIBPROTOBUF_EXPORT uint32 ghtonl(uint32 x); diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index 7ba92e8f..4fa8e99f 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -93,6 +93,21 @@ void StripString(string* s, const char* remove, char replacewith) { } } +// ---------------------------------------------------------------------- +// ReplaceCharacters +// Replaces any occurrence of the character 'remove' (or the characters +// in 'remove') with the character 'replacewith'. +// ---------------------------------------------------------------------- +void ReplaceCharacters(string *s, const char *remove, char replacewith) { + const char *str_start = s->c_str(); + const char *str = str_start; + for (str = strpbrk(str, remove); + str != NULL; + str = strpbrk(str + 1, remove)) { + (*s)[str - str_start] = replacewith; + } +} + void StripWhitespace(string* str) { int str_length = str->length(); diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h index 8bdd6110..df28c94d 100644 --- a/src/google/protobuf/stubs/strutil.h +++ b/src/google/protobuf/stubs/strutil.h @@ -147,7 +147,7 @@ inline string StripSuffixString(const string& str, const string& suffix) { } // ---------------------------------------------------------------------- -// StripString +// ReplaceCharacters // Replaces any occurrence of the character 'remove' (or the characters // in 'remove') with the character 'replacewith'. // Good for keeping html characters or protocol characters (\t) out @@ -155,6 +155,8 @@ inline string StripSuffixString(const string& str, const string& suffix) { // StripWhitespace // Removes whitespaces from both ends of the given string. // ---------------------------------------------------------------------- +LIBPROTOBUF_EXPORT void ReplaceCharacters(string* s, const char* remove, + char replacewith); LIBPROTOBUF_EXPORT void StripString(string* s, const char* remove, char replacewith); diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index 66b2648b..5192eca9 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc @@ -393,6 +393,16 @@ class TextFormat::Parser::ParserImpl { DO(ConsumeAnyValue(full_type_name, message->GetDescriptor()->file()->pool(), &serialized_value)); + if (singular_overwrite_policy_ == FORBID_SINGULAR_OVERWRITES) { + // Fail if any_type_url_field has already been specified. + if ((!any_type_url_field->is_repeated() && + reflection->HasField(*message, any_type_url_field)) || + (!any_value_field->is_repeated() && + reflection->HasField(*message, any_value_field))) { + ReportError("Non-repeated Any specified multiple times."); + return false; + } + } reflection->SetString( message, any_type_url_field, string(prefix + full_type_name)); @@ -515,18 +525,21 @@ class TextFormat::Parser::ParserImpl { } if (field->is_repeated() && TryConsume("[")) { - // Short repeated format, e.g. "foo: [1, 2, 3]" - while (true) { - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - // Perform special handling for embedded message types. - DO(ConsumeFieldMessage(message, reflection, field)); - } else { - DO(ConsumeFieldValue(message, reflection, field)); - } - if (TryConsume("]")) { - break; + // Short repeated format, e.g. "foo: [1, 2, 3]". + if (!TryConsume("]")) { + // "foo: []" is treated as empty. + while (true) { + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + // Perform special handling for embedded message types. + DO(ConsumeFieldMessage(message, reflection, field)); + } else { + DO(ConsumeFieldValue(message, reflection, field)); + } + if (TryConsume("]")) { + break; + } + DO(Consume(",")); } - DO(Consume(",")); } } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { DO(ConsumeFieldMessage(message, reflection, field)); diff --git a/src/google/protobuf/text_format.h b/src/google/protobuf/text_format.h index ef3d4a8f..2873d339 100644 --- a/src/google/protobuf/text_format.h +++ b/src/google/protobuf/text_format.h @@ -75,6 +75,8 @@ class LIBPROTOBUF_EXPORT TextFormat { io::ZeroCopyOutputStream* output); // Like Print(), but outputs directly to a string. + // Note: output will be cleared before prior to printing, and will + // be left empty even if printing fails. static bool PrintToString(const Message& message, string* output); // Like PrintUnknownFields(), but outputs directly to a string. @@ -301,8 +303,8 @@ class LIBPROTOBUF_EXPORT TextFormat { int64 truncate_string_field_longer_than_; google::protobuf::scoped_ptr default_field_value_printer_; - typedef map CustomPrinterMap; + typedef std::map CustomPrinterMap; CustomPrinterMap custom_printers_; }; @@ -391,11 +393,13 @@ class LIBPROTOBUF_EXPORT TextFormat { ParseInfoTree* CreateNested(const FieldDescriptor* field); // Defines the map from the index-th field descriptor to its parse location. - typedef map > LocationMap; + typedef std::map > LocationMap; // Defines the map from the index-th field descriptor to the nested parse // info tree. - typedef map > NestedMap; + typedef std::map > NestedMap; LocationMap locations_; NestedMap nested_; diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc index c9521cc3..2f1bd455 100644 --- a/src/google/protobuf/text_format_unittest.cc +++ b/src/google/protobuf/text_format_unittest.cc @@ -157,7 +157,21 @@ TEST_F(TextFormatTest, ShortPrimitiveRepeateds) { TextFormat::Printer printer; printer.SetUseShortRepeatedPrimitives(true); string text; - printer.PrintToString(proto_, &text); + EXPECT_TRUE(printer.PrintToString(proto_, &text)); + + EXPECT_EQ("optional_int32: 123\n" + "repeated_int32: [456, 789]\n" + "repeated_string: \"foo\"\n" + "repeated_string: \"bar\"\n" + "repeated_nested_message {\n bb: 2\n}\n" + "repeated_nested_message {\n bb: 3\n}\n" + "repeated_nested_enum: [FOO, BAR]\n", + text); + + // Verify that any existing data in the string is cleared when + // PrintToString() is called. + text = "just some data here...\n\nblah blah"; + EXPECT_TRUE(printer.PrintToString(proto_, &text)); EXPECT_EQ("optional_int32: 123\n" "repeated_int32: [456, 789]\n" @@ -170,7 +184,7 @@ TEST_F(TextFormatTest, ShortPrimitiveRepeateds) { // Try in single-line mode. printer.SetSingleLineMode(true); - printer.PrintToString(proto_, &text); + EXPECT_TRUE(printer.PrintToString(proto_, &text)); EXPECT_EQ("optional_int32: 123 " "repeated_int32: [456, 789] " @@ -659,6 +673,87 @@ TEST_F(TextFormatTest, ParseShortRepeatedForm) { EXPECT_EQ(4, proto_.repeatedgroup(1).a()); } +TEST_F(TextFormatTest, ParseShortRepeatedWithTrailingComma) { + string parse_string = "repeated_int32: [456,]\n"; + ASSERT_FALSE(TextFormat::ParseFromString(parse_string, &proto_)); + parse_string = "repeated_nested_enum: [ FOO , ]"; + ASSERT_FALSE(TextFormat::ParseFromString(parse_string, &proto_)); + parse_string = "repeated_string: [ \"foo\", ]"; + ASSERT_FALSE(TextFormat::ParseFromString(parse_string, &proto_)); + parse_string = "repeated_nested_message: [ { bb: 1 }, ]"; + ASSERT_FALSE(TextFormat::ParseFromString(parse_string, &proto_)); + parse_string = "RepeatedGroup [{ a: 3 },]\n"; +} + +TEST_F(TextFormatTest, ParseShortRepeatedEmpty) { + string parse_string = + "repeated_int32: []\n" + "repeated_nested_enum: []\n" + "repeated_string: []\n" + "repeated_nested_message: []\n" + "RepeatedGroup []\n"; + + ASSERT_TRUE(TextFormat::ParseFromString(parse_string, &proto_)); + + EXPECT_EQ(0, proto_.repeated_int32_size()); + EXPECT_EQ(0, proto_.repeated_nested_enum_size()); + EXPECT_EQ(0, proto_.repeated_string_size()); + EXPECT_EQ(0, proto_.repeated_nested_message_size()); + EXPECT_EQ(0, proto_.repeatedgroup_size()); +} + +TEST_F(TextFormatTest, ParseShortRepeatedConcatenatedWithEmpty) { + string parse_string = + // Starting with empty [] should have no impact. + "repeated_int32: []\n" + "repeated_nested_enum: []\n" + "repeated_string: []\n" + "repeated_nested_message: []\n" + "RepeatedGroup []\n" + // Mixed short-form and long-form are simply concatenated. + "repeated_int32: 1\n" + "repeated_int32: [456, 789]\n" + "repeated_nested_enum: [ FOO ,BAR, # comment\n" + " 3]\n" + // Note that while the printer won't print repeated strings in short-form, + // the parser will accept them. + "repeated_string: [ \"foo\", 'bar' ]\n" + // Repeated message + "repeated_nested_message: [ { bb: 1 }, { bb : 2 }]\n" + // Repeated group + "RepeatedGroup [{ a: 3 },{ a: 4 }]\n" + // Adding empty [] should have no impact. + "repeated_int32: []\n" + "repeated_nested_enum: []\n" + "repeated_string: []\n" + "repeated_nested_message: []\n" + "RepeatedGroup []\n"; + + ASSERT_TRUE(TextFormat::ParseFromString(parse_string, &proto_)); + + ASSERT_EQ(3, proto_.repeated_int32_size()); + EXPECT_EQ(1, proto_.repeated_int32(0)); + EXPECT_EQ(456, proto_.repeated_int32(1)); + EXPECT_EQ(789, proto_.repeated_int32(2)); + + ASSERT_EQ(3, proto_.repeated_nested_enum_size()); + EXPECT_EQ(unittest::TestAllTypes::FOO, proto_.repeated_nested_enum(0)); + EXPECT_EQ(unittest::TestAllTypes::BAR, proto_.repeated_nested_enum(1)); + EXPECT_EQ(unittest::TestAllTypes::BAZ, proto_.repeated_nested_enum(2)); + + ASSERT_EQ(2, proto_.repeated_string_size()); + EXPECT_EQ("foo", proto_.repeated_string(0)); + EXPECT_EQ("bar", proto_.repeated_string(1)); + + ASSERT_EQ(2, proto_.repeated_nested_message_size()); + EXPECT_EQ(1, proto_.repeated_nested_message(0).bb()); + EXPECT_EQ(2, proto_.repeated_nested_message(1).bb()); + + ASSERT_EQ(2, proto_.repeatedgroup_size()); + EXPECT_EQ(3, proto_.repeatedgroup(0).a()); + EXPECT_EQ(4, proto_.repeatedgroup(1).a()); +} + TEST_F(TextFormatTest, Comments) { // Test that comments are ignored. diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index e6c9c58b..54c6e868 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -44,20 +44,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto() { Timestamp_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Timestamp_descriptor_, - Timestamp::default_instance_, + Timestamp::internal_default_instance(), Timestamp_offsets_, -1, -1, -1, sizeof(Timestamp), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _internal_metadata_)); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { +void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto); } @@ -66,37 +65,48 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Timestamp_descriptor_, &Timestamp::default_instance()); + Timestamp_descriptor_, Timestamp::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto() { - delete Timestamp::default_instance_; delete Timestamp_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + Timestamp::default_instance_.DefaultConstruct(); + Timestamp::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\037google/protobuf/timestamp.proto\022\017googl" "e.protobuf\"+\n\tTimestamp\022\017\n\007seconds\030\001 \001(\003" - "\022\r\n\005nanos\030\002 \001(\005B\201\001\n\023com.google.protobufB" - "\016TimestampProtoP\001Z+github.com/golang/pro" - "tobuf/ptypes/timestamp\240\001\001\370\001\001\242\002\003GPB\252\002\036Goo" - "gle.Protobuf.WellKnownTypesb\006proto3", 235); + "\022\r\n\005nanos\030\002 \001(\005B~\n\023com.google.protobufB\016" + "TimestampProtoP\001Z+github.com/golang/prot" + "obuf/ptypes/timestamp\370\001\001\242\002\003GPB\252\002\036Google." + "Protobuf.WellKnownTypesb\006proto3", 231); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/timestamp.proto", &protobuf_RegisterTypes); - Timestamp::default_instance_ = new Timestamp(); - Timestamp::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto() { @@ -104,6 +114,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2ftimestamp_2eproto_; +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; +static void MergeFromFail(int line) { + ::google::protobuf::internal::MergeFromFail(__FILE__, line); +} + +} // namespace + + // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -113,35 +133,36 @@ const int Timestamp::kNanosFieldNumber; Timestamp::Timestamp() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Timestamp) } - Timestamp::Timestamp(::google::protobuf::Arena* arena) : ::google::protobuf::Message(), _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Timestamp) } void Timestamp::InitAsDefaultInstance() { - _is_default_instance_ = true; } Timestamp::Timestamp(const Timestamp& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Timestamp) } void Timestamp::SharedCtor() { - _is_default_instance_ = false; + ::memset(&seconds_, 0, reinterpret_cast(&nanos_) - + reinterpret_cast(&seconds_) + sizeof(nanos_)); _cached_size_ = 0; - seconds_ = GOOGLE_LONGLONG(0); - nanos_ = 0; } Timestamp::~Timestamp() { @@ -150,12 +171,11 @@ Timestamp::~Timestamp() { } void Timestamp::SharedDtor() { - if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { return; } - if (this != default_instance_) { - } } void Timestamp::ArenaDtor(void* object) { @@ -175,11 +195,11 @@ const ::google::protobuf::Descriptor* Timestamp::descriptor() { } const Timestamp& Timestamp::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); + return *internal_default_instance(); } -Timestamp* Timestamp::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Timestamp::default_instance_; Timestamp* Timestamp::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage(arena); @@ -223,10 +243,10 @@ bool Timestamp::MergePartialFromCodedStream( // optional int64 seconds = 1; case 1: { if (tag == 8) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( input, &seconds_))); - } else { goto handle_unusual; } @@ -238,10 +258,10 @@ bool Timestamp::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_nanos: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &nanos_))); - } else { goto handle_unusual; } @@ -304,9 +324,9 @@ void Timestamp::SerializeWithCachedSizes( return target; } -int Timestamp::ByteSize() const { +size_t Timestamp::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Timestamp) - int total_size = 0; + size_t total_size = 0; // optional int64 seconds = 1; if (this->seconds() != 0) { @@ -322,18 +342,17 @@ int Timestamp::ByteSize() const { this->nanos()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Timestamp::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Timestamp) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Timestamp* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Timestamp* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -341,15 +360,21 @@ void Timestamp::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Timestamp) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Timestamp::MergeFrom(const Timestamp& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Timestamp) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Timestamp::UnsafeMergeFrom(const Timestamp& from) { + GOOGLE_DCHECK(&from != this); if (from.seconds() != 0) { set_seconds(from.seconds()); } @@ -369,7 +394,7 @@ void Timestamp::CopyFrom(const Timestamp& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Timestamp) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Timestamp::IsInitialized() const { @@ -383,7 +408,7 @@ void Timestamp::Swap(Timestamp* other) { InternalSwap(other); } else { Timestamp temp; - temp.MergeFrom(*this); + temp.UnsafeMergeFrom(*this); CopyFrom(*other); other->CopyFrom(temp); } @@ -415,11 +440,11 @@ void Timestamp::InternalSwap(Timestamp* other) { void Timestamp::clear_seconds() { seconds_ = GOOGLE_LONGLONG(0); } - ::google::protobuf::int64 Timestamp::seconds() const { +::google::protobuf::int64 Timestamp::seconds() const { // @@protoc_insertion_point(field_get:google.protobuf.Timestamp.seconds) return seconds_; } - void Timestamp::set_seconds(::google::protobuf::int64 value) { +void Timestamp::set_seconds(::google::protobuf::int64 value) { seconds_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.seconds) @@ -429,11 +454,11 @@ void Timestamp::clear_seconds() { void Timestamp::clear_nanos() { nanos_ = 0; } - ::google::protobuf::int32 Timestamp::nanos() const { +::google::protobuf::int32 Timestamp::nanos() const { // @@protoc_insertion_point(field_get:google.protobuf.Timestamp.nanos) return nanos_; } - void Timestamp::set_nanos(::google::protobuf::int32 value) { +void Timestamp::set_nanos(::google::protobuf::int32 value) { nanos_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.nanos) diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 2d685120..acc1e7d3 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -34,6 +34,7 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto(); void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto(); @@ -60,6 +61,10 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro static const ::google::protobuf::Descriptor* descriptor(); static const Timestamp& default_instance(); + static inline const Timestamp* internal_default_instance() { + return &default_instance_.get(); + } + void UnsafeArenaSwap(Timestamp* other); void Swap(Timestamp* other); @@ -75,7 +80,7 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( @@ -91,6 +96,7 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Timestamp* other); + void UnsafeMergeFrom(const Timestamp& from); protected: explicit Timestamp(::google::protobuf::Arena* arena); private: @@ -130,16 +136,16 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool _is_default_instance_; ::google::protobuf::int64 seconds_; ::google::protobuf::int32 nanos_; mutable int _cached_size_; - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl(); friend void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto(); void InitAsDefaultInstance(); - static Timestamp* default_instance_; + static ::google::protobuf::internal::ExplicitlyConstructed default_instance_; }; // =================================================================== diff --git a/src/google/protobuf/timestamp.proto b/src/google/protobuf/timestamp.proto index 7992a858..67e2eba4 100644 --- a/src/google/protobuf/timestamp.proto +++ b/src/google/protobuf/timestamp.proto @@ -38,7 +38,6 @@ option go_package = "github.com/golang/protobuf/ptypes/timestamp"; option java_package = "com.google.protobuf"; option java_outer_classname = "TimestampProto"; option java_multiple_files = true; -option java_generate_equals_and_hash = true; option objc_class_prefix = "GPB"; // A Timestamp represents a point in time independent of any time zone @@ -90,16 +89,14 @@ option objc_class_prefix = "GPB"; // // Example 5: Compute Timestamp from current time in Python. // -// now = time.time() -// seconds = int(now) -// nanos = int((now - seconds) * 10**9) -// timestamp = Timestamp(seconds=seconds, nanos=nanos) +// timestamp = Timestamp() +// timestamp.GetCurrentTime() // // message Timestamp { // Represents seconds of UTC time since Unix epoch - // 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to + // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to // 9999-12-31T23:59:59Z inclusive. int64 seconds = 1; diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index fc7d5332..0c6de296 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -63,14 +63,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { Type_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Type_descriptor_, - Type::default_instance_, + Type::internal_default_instance(), Type_offsets_, -1, -1, -1, sizeof(Type), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_)); Field_descriptor_ = file->message_type(1); static const int Field_offsets_[10] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, kind_), @@ -87,14 +86,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { Field_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Field_descriptor_, - Field::default_instance_, + Field::internal_default_instance(), Field_offsets_, -1, -1, -1, sizeof(Field), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _internal_metadata_)); Field_Kind_descriptor_ = Field_descriptor_->enum_type(0); Field_Cardinality_descriptor_ = Field_descriptor_->enum_type(1); Enum_descriptor_ = file->message_type(2); @@ -108,14 +106,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { Enum_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Enum_descriptor_, - Enum::default_instance_, + Enum::internal_default_instance(), Enum_offsets_, -1, -1, -1, sizeof(Enum), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_)); EnumValue_descriptor_ = file->message_type(3); static const int EnumValue_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, name_), @@ -125,14 +122,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { EnumValue_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( EnumValue_descriptor_, - EnumValue::default_instance_, + EnumValue::internal_default_instance(), EnumValue_offsets_, -1, -1, -1, sizeof(EnumValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_)); Option_descriptor_ = file->message_type(4); static const int Option_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, name_), @@ -141,21 +137,20 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { Option_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Option_descriptor_, - Option::default_instance_, + Option::internal_default_instance(), Option_offsets_, -1, -1, -1, sizeof(Option), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_)); Syntax_descriptor_ = file->enum_type(0); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { +void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto); } @@ -164,41 +159,58 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Type_descriptor_, &Type::default_instance()); + Type_descriptor_, Type::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Field_descriptor_, &Field::default_instance()); + Field_descriptor_, Field::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Enum_descriptor_, &Enum::default_instance()); + Enum_descriptor_, Enum::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValue_descriptor_, &EnumValue::default_instance()); + EnumValue_descriptor_, EnumValue::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Option_descriptor_, &Option::default_instance()); + Option_descriptor_, Option::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto() { - delete Type::default_instance_; delete Type_reflection_; - delete Field::default_instance_; delete Field_reflection_; - delete Enum::default_instance_; delete Enum_reflection_; - delete EnumValue::default_instance_; delete EnumValue_reflection_; - delete Option::default_instance_; delete Option_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); + ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); + ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); + ::google::protobuf::internal::GetEmptyString(); + Type::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + Field::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + Enum::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + EnumValue::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + Option::default_instance_.DefaultConstruct(); + Type::default_instance_.get_mutable()->InitAsDefaultInstance(); + Field::default_instance_.get_mutable()->InitAsDefaultInstance(); + Enum::default_instance_.get_mutable()->InitAsDefaultInstance(); + EnumValue::default_instance_.get_mutable()->InitAsDefaultInstance(); + Option::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\032google/protobuf/type.proto\022\017google.pro" "tobuf\032\031google/protobuf/any.proto\032$google" @@ -237,23 +249,20 @@ void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto() { "\022\014\n\004name\030\001 \001(\t\022#\n\005value\030\002 \001(\0132\024.google.p" "rotobuf.Any*.\n\006Syntax\022\021\n\rSYNTAX_PROTO2\020\000" "\022\021\n\rSYNTAX_PROTO3\020\001BL\n\023com.google.protob" - "ufB\tTypeProtoP\001\240\001\001\242\002\003GPB\252\002\036Google.Protob" + "ufB\tTypeProtoP\001\370\001\001\242\002\003GPB\252\002\036Google.Protob" "uf.WellKnownTypesb\006proto3", 1545); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/type.proto", &protobuf_RegisterTypes); - Type::default_instance_ = new Type(); - Field::default_instance_ = new Field(); - Enum::default_instance_ = new Enum(); - EnumValue::default_instance_ = new EnumValue(); - Option::default_instance_ = new Option(); - Type::default_instance_->InitAsDefaultInstance(); - Field::default_instance_->InitAsDefaultInstance(); - Enum::default_instance_->InitAsDefaultInstance(); - EnumValue::default_instance_->InitAsDefaultInstance(); - Option::default_instance_->InitAsDefaultInstance(); + ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); + ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto() { @@ -265,7 +274,7 @@ const ::google::protobuf::EnumDescriptor* Syntax_descriptor() { return Syntax_descriptor_; } bool Syntax_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: return true; @@ -275,8 +284,51 @@ bool Syntax_IsValid(int value) { } +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; +static void MergeFromFail(int line) { + ::google::protobuf::internal::MergeFromFail(__FILE__, line); +} + +} // namespace + + // =================================================================== +void Type::_slow_mutable_source_context() { + source_context_ = ::google::protobuf::Arena::Create< ::google::protobuf::SourceContext >( + GetArenaNoVirtual()); +} +::google::protobuf::SourceContext* Type::_slow_release_source_context() { + if (source_context_ == NULL) { + return NULL; + } else { + ::google::protobuf::SourceContext* temp = new ::google::protobuf::SourceContext(*source_context_); + source_context_ = NULL; + return temp; + } +} +::google::protobuf::SourceContext* Type::unsafe_arena_release_source_context() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Type.source_context) + + ::google::protobuf::SourceContext* temp = source_context_; + source_context_ = NULL; + return temp; +} +void Type::unsafe_arena_set_allocated_source_context( + ::google::protobuf::SourceContext* source_context) { + if (GetArenaNoVirtual() == NULL) { + delete source_context_; + } + source_context_ = source_context; + if (source_context) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Type.source_context) +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Type::kNameFieldNumber; const int Type::kFieldsFieldNumber; @@ -288,30 +340,42 @@ const int Type::kSyntaxFieldNumber; Type::Type() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Type) } +Type::Type(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + fields_(arena), + oneofs_(arena), + options_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Type) +} void Type::InitAsDefaultInstance() { - _is_default_instance_ = true; - source_context_ = const_cast< ::google::protobuf::SourceContext*>(&::google::protobuf::SourceContext::default_instance()); + source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); } Type::Type(const Type& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Type) } void Type::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); source_context_ = NULL; syntax_ = 0; + _cached_size_ = 0; } Type::~Type() { @@ -320,12 +384,21 @@ Type::~Type() { } void Type::SharedDtor() { - name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete source_context_; + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + + name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + delete source_context_; } +void Type::ArenaDtor(void* object) { + Type* _this = reinterpret_cast< Type* >(object); + (void)_this; +} +void Type::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Type::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -337,23 +410,19 @@ const ::google::protobuf::Descriptor* Type::descriptor() { } const Type& Type::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + return *internal_default_instance(); } -Type* Type::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Type::default_instance_; Type* Type::New(::google::protobuf::Arena* arena) const { - Type* n = new Type; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage(arena); } void Type::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Type) - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; source_context_ = NULL; syntax_ = 0; @@ -597,9 +666,9 @@ void Type::SerializeWithCachedSizes( return target; } -int Type::ByteSize() const { +size_t Type::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Type) - int total_size = 0; + size_t total_size = 0; // optional string name = 1; if (this->name().size() > 0) { @@ -622,40 +691,46 @@ int Type::ByteSize() const { } // repeated .google.protobuf.Field fields = 2; - total_size += 1 * this->fields_size(); - for (int i = 0; i < this->fields_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->fields(i)); + { + unsigned int count = this->fields_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->fields(i)); + } } // repeated string oneofs = 3; - total_size += 1 * this->oneofs_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->oneofs_size()); for (int i = 0; i < this->oneofs_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->oneofs(i)); } // repeated .google.protobuf.Option options = 4; - total_size += 1 * this->options_size(); - for (int i = 0; i < this->options_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(i)); + } } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Type::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Type) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Type* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Type* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -663,21 +738,26 @@ void Type::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Type) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Type::MergeFrom(const Type& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Type) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Type::UnsafeMergeFrom(const Type& from) { + GOOGLE_DCHECK(&from != this); fields_.MergeFrom(from.fields_); - oneofs_.MergeFrom(from.oneofs_); + oneofs_.UnsafeMergeFrom(from.oneofs_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { - - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (from.has_source_context()) { mutable_source_context()->::google::protobuf::SourceContext::MergeFrom(from.source_context()); @@ -698,7 +778,7 @@ void Type::CopyFrom(const Type& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Type) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Type::IsInitialized() const { @@ -708,6 +788,18 @@ bool Type::IsInitialized() const { void Type::Swap(Type* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + Type temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void Type::UnsafeArenaSwap(Type* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void Type::InternalSwap(Type* other) { @@ -734,47 +826,69 @@ void Type::InternalSwap(Type* other) { // optional string name = 1; void Type::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& Type::name() const { +const ::std::string& Type::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Type::set_name(const ::std::string& value) { +void Type::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Type.name) } - void Type::set_name(const char* value) { +void Type::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Type.name) } - void Type::set_name(const char* value, size_t size) { +void Type::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.name) } - ::std::string* Type::mutable_name() { +::std::string* Type::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Type.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* Type::release_name() { +::std::string* Type::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Type.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - void Type::set_allocated_name(::std::string* name) { +::std::string* Type::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Type.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +void Type::set_allocated_name(::std::string* name) { if (name != NULL) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name) } +void Type::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Type.name) +} // repeated .google.protobuf.Field fields = 2; int Type::fields_size() const { @@ -813,49 +927,49 @@ int Type::oneofs_size() const { void Type::clear_oneofs() { oneofs_.Clear(); } - const ::std::string& Type::oneofs(int index) const { +const ::std::string& Type::oneofs(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.Type.oneofs) return oneofs_.Get(index); } - ::std::string* Type::mutable_oneofs(int index) { +::std::string* Type::mutable_oneofs(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Type.oneofs) return oneofs_.Mutable(index); } - void Type::set_oneofs(int index, const ::std::string& value) { +void Type::set_oneofs(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) oneofs_.Mutable(index)->assign(value); } - void Type::set_oneofs(int index, const char* value) { +void Type::set_oneofs(int index, const char* value) { oneofs_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.Type.oneofs) } - void Type::set_oneofs(int index, const char* value, size_t size) { +void Type::set_oneofs(int index, const char* value, size_t size) { oneofs_.Mutable(index)->assign( reinterpret_cast(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.oneofs) } - ::std::string* Type::add_oneofs() { +::std::string* Type::add_oneofs() { // @@protoc_insertion_point(field_add_mutable:google.protobuf.Type.oneofs) return oneofs_.Add(); } - void Type::add_oneofs(const ::std::string& value) { +void Type::add_oneofs(const ::std::string& value) { oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) } - void Type::add_oneofs(const char* value) { +void Type::add_oneofs(const char* value) { oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.Type.oneofs) } - void Type::add_oneofs(const char* value, size_t size) { +void Type::add_oneofs(const char* value, size_t size) { oneofs_.Add()->assign(reinterpret_cast(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.Type.oneofs) } - const ::google::protobuf::RepeatedPtrField< ::std::string>& +const ::google::protobuf::RepeatedPtrField< ::std::string>& Type::oneofs() const { // @@protoc_insertion_point(field_list:google.protobuf.Type.oneofs) return oneofs_; } - ::google::protobuf::RepeatedPtrField< ::std::string>* +::google::protobuf::RepeatedPtrField< ::std::string>* Type::mutable_oneofs() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.oneofs) return &oneofs_; @@ -893,7 +1007,7 @@ Type::options() const { // optional .google.protobuf.SourceContext source_context = 5; bool Type::has_source_context() const { - return !_is_default_instance_ && source_context_ != NULL; + return this != internal_default_instance() && source_context_ != NULL; } void Type::clear_source_context() { if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; @@ -901,12 +1015,13 @@ void Type::clear_source_context() { } const ::google::protobuf::SourceContext& Type::source_context() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.source_context) - return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_; + return source_context_ != NULL ? *source_context_ + : *::google::protobuf::SourceContext::internal_default_instance(); } ::google::protobuf::SourceContext* Type::mutable_source_context() { if (source_context_ == NULL) { - source_context_ = new ::google::protobuf::SourceContext; + _slow_mutable_source_context(); } // @@protoc_insertion_point(field_mutable:google.protobuf.Type.source_context) return source_context_; @@ -914,12 +1029,24 @@ const ::google::protobuf::SourceContext& Type::source_context() const { ::google::protobuf::SourceContext* Type::release_source_context() { // @@protoc_insertion_point(field_release:google.protobuf.Type.source_context) - ::google::protobuf::SourceContext* temp = source_context_; - source_context_ = NULL; - return temp; + if (GetArenaNoVirtual() != NULL) { + return _slow_release_source_context(); + } else { + ::google::protobuf::SourceContext* temp = source_context_; + source_context_ = NULL; + return temp; + } } -void Type::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { - delete source_context_; + void Type::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete source_context_; + } + if (source_context != NULL) { + if (message_arena != NULL) { + message_arena->Own(source_context); + } + } source_context_ = source_context; if (source_context) { @@ -933,11 +1060,11 @@ void Type::set_allocated_source_context(::google::protobuf::SourceContext* sourc void Type::clear_syntax() { syntax_ = 0; } - ::google::protobuf::Syntax Type::syntax() const { +::google::protobuf::Syntax Type::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.syntax) return static_cast< ::google::protobuf::Syntax >(syntax_); } - void Type::set_syntax(::google::protobuf::Syntax value) { +void Type::set_syntax(::google::protobuf::Syntax value) { syntax_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Type.syntax) @@ -952,7 +1079,7 @@ const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor() { return Field_Kind_descriptor_; } bool Field_Kind_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -1007,7 +1134,7 @@ const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor() { return Field_Cardinality_descriptor_; } bool Field_Cardinality_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -1042,35 +1169,41 @@ const int Field::kDefaultValueFieldNumber; Field::Field() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Field) } +Field::Field(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + options_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Field) +} void Field::InitAsDefaultInstance() { - _is_default_instance_ = true; } Field::Field(const Field& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Field) } void Field::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; - kind_ = 0; - cardinality_ = 0; - number_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - oneof_index_ = 0; - packed_ = false; json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::memset(&kind_, 0, reinterpret_cast(&packed_) - + reinterpret_cast(&kind_) + sizeof(packed_)); + _cached_size_ = 0; } Field::~Field() { @@ -1079,14 +1212,23 @@ Field::~Field() { } void Field::SharedDtor() { - name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - type_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - json_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - default_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + + name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + type_url_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + json_name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + default_value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); } +void Field::ArenaDtor(void* object) { + Field* _this = reinterpret_cast< Field* >(object); + (void)_this; +} +void Field::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Field::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -1098,18 +1240,14 @@ const ::google::protobuf::Descriptor* Field::descriptor() { } const Field& Field::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + return *internal_default_instance(); } -Field* Field::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Field::default_instance_; Field* Field::New(::google::protobuf::Arena* arena) const { - Field* n = new Field; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage(arena); } void Field::Clear() { @@ -1130,13 +1268,11 @@ void Field::Clear() { ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ } while (0) - ZR_(kind_, cardinality_); - ZR_(number_, oneof_index_); - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - packed_ = false; - json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ZR_(kind_, packed_); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); #undef ZR_HELPER_ #undef ZR_ @@ -1189,10 +1325,10 @@ bool Field::MergePartialFromCodedStream( case 3: { if (tag == 24) { parse_number: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &number_))); - } else { goto handle_unusual; } @@ -1238,10 +1374,10 @@ bool Field::MergePartialFromCodedStream( case 7: { if (tag == 56) { parse_oneof_index: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &oneof_index_))); - } else { goto handle_unusual; } @@ -1253,10 +1389,10 @@ bool Field::MergePartialFromCodedStream( case 8: { if (tag == 64) { parse_packed: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &packed_))); - } else { goto handle_unusual; } @@ -1501,9 +1637,9 @@ void Field::SerializeWithCachedSizes( return target; } -int Field::ByteSize() const { +size_t Field::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Field) - int total_size = 0; + size_t total_size = 0; // optional .google.protobuf.Field.Kind kind = 1; if (this->kind() != 0) { @@ -1565,25 +1701,27 @@ int Field::ByteSize() const { } // repeated .google.protobuf.Option options = 9; - total_size += 1 * this->options_size(); - for (int i = 0; i < this->options_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(i)); + } } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Field::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Field) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Field* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Field* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -1591,15 +1729,21 @@ void Field::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Field) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Field::MergeFrom(const Field& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Field) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Field::UnsafeMergeFrom(const Field& from) { + GOOGLE_DCHECK(&from != this); options_.MergeFrom(from.options_); if (from.kind() != 0) { set_kind(from.kind()); @@ -1611,12 +1755,10 @@ void Field::MergeFrom(const Field& from) { set_number(from.number()); } if (from.name().size() > 0) { - - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (from.type_url().size() > 0) { - - type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_); + set_type_url(from.type_url()); } if (from.oneof_index() != 0) { set_oneof_index(from.oneof_index()); @@ -1625,12 +1767,10 @@ void Field::MergeFrom(const Field& from) { set_packed(from.packed()); } if (from.json_name().size() > 0) { - - json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_); + set_json_name(from.json_name()); } if (from.default_value().size() > 0) { - - default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_); + set_default_value(from.default_value()); } } @@ -1645,7 +1785,7 @@ void Field::CopyFrom(const Field& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Field) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Field::IsInitialized() const { @@ -1655,6 +1795,18 @@ bool Field::IsInitialized() const { void Field::Swap(Field* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + Field temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void Field::UnsafeArenaSwap(Field* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void Field::InternalSwap(Field* other) { @@ -1687,11 +1839,11 @@ void Field::InternalSwap(Field* other) { void Field::clear_kind() { kind_ = 0; } - ::google::protobuf::Field_Kind Field::kind() const { +::google::protobuf::Field_Kind Field::kind() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.kind) return static_cast< ::google::protobuf::Field_Kind >(kind_); } - void Field::set_kind(::google::protobuf::Field_Kind value) { +void Field::set_kind(::google::protobuf::Field_Kind value) { kind_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Field.kind) @@ -1701,11 +1853,11 @@ void Field::clear_kind() { void Field::clear_cardinality() { cardinality_ = 0; } - ::google::protobuf::Field_Cardinality Field::cardinality() const { +::google::protobuf::Field_Cardinality Field::cardinality() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.cardinality) return static_cast< ::google::protobuf::Field_Cardinality >(cardinality_); } - void Field::set_cardinality(::google::protobuf::Field_Cardinality value) { +void Field::set_cardinality(::google::protobuf::Field_Cardinality value) { cardinality_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Field.cardinality) @@ -1715,11 +1867,11 @@ void Field::clear_cardinality() { void Field::clear_number() { number_ = 0; } - ::google::protobuf::int32 Field::number() const { +::google::protobuf::int32 Field::number() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.number) return number_; } - void Field::set_number(::google::protobuf::int32 value) { +void Field::set_number(::google::protobuf::int32 value) { number_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Field.number) @@ -1727,101 +1879,145 @@ void Field::clear_number() { // optional string name = 4; void Field::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& Field::name() const { +const ::std::string& Field::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Field::set_name(const ::std::string& value) { +void Field::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.name) } - void Field::set_name(const char* value) { +void Field::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.name) } - void Field::set_name(const char* value, size_t size) { +void Field::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.name) } - ::std::string* Field::mutable_name() { +::std::string* Field::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* Field::release_name() { +::std::string* Field::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Field.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - void Field::set_allocated_name(::std::string* name) { +::std::string* Field::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +void Field::set_allocated_name(::std::string* name) { if (name != NULL) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name) } +void Field::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.name) +} // optional string type_url = 6; void Field::clear_type_url() { - type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& Field::type_url() const { +const ::std::string& Field::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url) - return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Field::set_type_url(const ::std::string& value) { +void Field::set_type_url(const ::std::string& value) { - type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.type_url) } - void Field::set_type_url(const char* value) { +void Field::set_type_url(const char* value) { - type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.type_url) } - void Field::set_type_url(const char* value, size_t size) { +void Field::set_type_url(const char* value, + size_t size) { - type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.type_url) } - ::std::string* Field::mutable_type_url() { +::std::string* Field::mutable_type_url() { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.type_url) - return type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* Field::release_type_url() { +::std::string* Field::release_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Field.type_url) - return type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - void Field::set_allocated_type_url(::std::string* type_url) { +::std::string* Field::unsafe_arena_release_type_url() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.type_url) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return type_url_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +void Field::set_allocated_type_url(::std::string* type_url) { if (type_url != NULL) { } else { } - type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_url); + type_url_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_url, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url) } +void Field::unsafe_arena_set_allocated_type_url( + ::std::string* type_url) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (type_url != NULL) { + + } else { + + } + type_url_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + type_url, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.type_url) +} // optional int32 oneof_index = 7; void Field::clear_oneof_index() { oneof_index_ = 0; } - ::google::protobuf::int32 Field::oneof_index() const { +::google::protobuf::int32 Field::oneof_index() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.oneof_index) return oneof_index_; } - void Field::set_oneof_index(::google::protobuf::int32 value) { +void Field::set_oneof_index(::google::protobuf::int32 value) { oneof_index_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Field.oneof_index) @@ -1831,11 +2027,11 @@ void Field::clear_oneof_index() { void Field::clear_packed() { packed_ = false; } - bool Field::packed() const { +bool Field::packed() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.packed) return packed_; } - void Field::set_packed(bool value) { +void Field::set_packed(bool value) { packed_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Field.packed) @@ -1873,96 +2069,173 @@ Field::options() const { // optional string json_name = 10; void Field::clear_json_name() { - json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& Field::json_name() const { +const ::std::string& Field::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name) - return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Field::set_json_name(const ::std::string& value) { +void Field::set_json_name(const ::std::string& value) { - json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.json_name) } - void Field::set_json_name(const char* value) { +void Field::set_json_name(const char* value) { - json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.json_name) } - void Field::set_json_name(const char* value, size_t size) { +void Field::set_json_name(const char* value, + size_t size) { - json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.json_name) } - ::std::string* Field::mutable_json_name() { +::std::string* Field::mutable_json_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.json_name) - return json_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* Field::release_json_name() { +::std::string* Field::release_json_name() { // @@protoc_insertion_point(field_release:google.protobuf.Field.json_name) - return json_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +::std::string* Field::unsafe_arena_release_json_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.json_name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return json_name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } - void Field::set_allocated_json_name(::std::string* json_name) { +void Field::set_allocated_json_name(::std::string* json_name) { if (json_name != NULL) { } else { } - json_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), json_name); + json_name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), json_name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name) } +void Field::unsafe_arena_set_allocated_json_name( + ::std::string* json_name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (json_name != NULL) { + + } else { + + } + json_name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + json_name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.json_name) +} // optional string default_value = 11; void Field::clear_default_value() { - default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& Field::default_value() const { +const ::std::string& Field::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value) - return default_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Field::set_default_value(const ::std::string& value) { +void Field::set_default_value(const ::std::string& value) { - default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Field.default_value) } - void Field::set_default_value(const char* value) { +void Field::set_default_value(const char* value) { - default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Field.default_value) } - void Field::set_default_value(const char* value, size_t size) { +void Field::set_default_value(const char* value, + size_t size) { - default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.default_value) } - ::std::string* Field::mutable_default_value() { +::std::string* Field::mutable_default_value() { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.default_value) - return default_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* Field::release_default_value() { +::std::string* Field::release_default_value() { // @@protoc_insertion_point(field_release:google.protobuf.Field.default_value) - return default_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +::std::string* Field::unsafe_arena_release_default_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.default_value) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return default_value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } - void Field::set_allocated_default_value(::std::string* default_value) { +void Field::set_allocated_default_value(::std::string* default_value) { if (default_value != NULL) { } else { } - default_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), default_value); + default_value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), default_value, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value) } +void Field::unsafe_arena_set_allocated_default_value( + ::std::string* default_value) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (default_value != NULL) { + + } else { + + } + default_value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + default_value, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.default_value) +} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== +void Enum::_slow_mutable_source_context() { + source_context_ = ::google::protobuf::Arena::Create< ::google::protobuf::SourceContext >( + GetArenaNoVirtual()); +} +::google::protobuf::SourceContext* Enum::_slow_release_source_context() { + if (source_context_ == NULL) { + return NULL; + } else { + ::google::protobuf::SourceContext* temp = new ::google::protobuf::SourceContext(*source_context_); + source_context_ = NULL; + return temp; + } +} +::google::protobuf::SourceContext* Enum::unsafe_arena_release_source_context() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Enum.source_context) + + ::google::protobuf::SourceContext* temp = source_context_; + source_context_ = NULL; + return temp; +} +void Enum::unsafe_arena_set_allocated_source_context( + ::google::protobuf::SourceContext* source_context) { + if (GetArenaNoVirtual() == NULL) { + delete source_context_; + } + source_context_ = source_context; + if (source_context) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Enum.source_context) +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Enum::kNameFieldNumber; const int Enum::kEnumvalueFieldNumber; @@ -1973,30 +2246,41 @@ const int Enum::kSyntaxFieldNumber; Enum::Enum() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Enum) } +Enum::Enum(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + enumvalue_(arena), + options_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Enum) +} void Enum::InitAsDefaultInstance() { - _is_default_instance_ = true; - source_context_ = const_cast< ::google::protobuf::SourceContext*>(&::google::protobuf::SourceContext::default_instance()); + source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); } Enum::Enum(const Enum& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Enum) } void Enum::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); source_context_ = NULL; syntax_ = 0; + _cached_size_ = 0; } Enum::~Enum() { @@ -2005,12 +2289,21 @@ Enum::~Enum() { } void Enum::SharedDtor() { - name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete source_context_; + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + + name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + delete source_context_; } +void Enum::ArenaDtor(void* object) { + Enum* _this = reinterpret_cast< Enum* >(object); + (void)_this; +} +void Enum::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Enum::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -2022,23 +2315,19 @@ const ::google::protobuf::Descriptor* Enum::descriptor() { } const Enum& Enum::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + return *internal_default_instance(); } -Enum* Enum::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Enum::default_instance_; Enum* Enum::New(::google::protobuf::Arena* arena) const { - Enum* n = new Enum; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage(arena); } void Enum::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Enum) - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; source_context_ = NULL; syntax_ = 0; @@ -2241,9 +2530,9 @@ void Enum::SerializeWithCachedSizes( return target; } -int Enum::ByteSize() const { +size_t Enum::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Enum) - int total_size = 0; + size_t total_size = 0; // optional string name = 1; if (this->name().size() > 0) { @@ -2266,33 +2555,38 @@ int Enum::ByteSize() const { } // repeated .google.protobuf.EnumValue enumvalue = 2; - total_size += 1 * this->enumvalue_size(); - for (int i = 0; i < this->enumvalue_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->enumvalue(i)); + { + unsigned int count = this->enumvalue_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->enumvalue(i)); + } } // repeated .google.protobuf.Option options = 3; - total_size += 1 * this->options_size(); - for (int i = 0; i < this->options_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(i)); + } } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Enum::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Enum) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Enum* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Enum* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -2300,20 +2594,25 @@ void Enum::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Enum) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Enum::MergeFrom(const Enum& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Enum) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Enum::UnsafeMergeFrom(const Enum& from) { + GOOGLE_DCHECK(&from != this); enumvalue_.MergeFrom(from.enumvalue_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { - - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (from.has_source_context()) { mutable_source_context()->::google::protobuf::SourceContext::MergeFrom(from.source_context()); @@ -2334,7 +2633,7 @@ void Enum::CopyFrom(const Enum& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Enum) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Enum::IsInitialized() const { @@ -2344,6 +2643,18 @@ bool Enum::IsInitialized() const { void Enum::Swap(Enum* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + Enum temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void Enum::UnsafeArenaSwap(Enum* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void Enum::InternalSwap(Enum* other) { @@ -2369,47 +2680,69 @@ void Enum::InternalSwap(Enum* other) { // optional string name = 1; void Enum::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& Enum::name() const { +const ::std::string& Enum::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void Enum::set_name(const ::std::string& value) { +void Enum::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Enum.name) } - void Enum::set_name(const char* value) { +void Enum::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Enum.name) } - void Enum::set_name(const char* value, size_t size) { +void Enum::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Enum.name) } - ::std::string* Enum::mutable_name() { +::std::string* Enum::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* Enum::release_name() { +::std::string* Enum::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Enum.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); +} +::std::string* Enum::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Enum.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } - void Enum::set_allocated_name(::std::string* name) { +void Enum::set_allocated_name(::std::string* name) { if (name != NULL) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name) } +void Enum::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Enum.name) +} // repeated .google.protobuf.EnumValue enumvalue = 2; int Enum::enumvalue_size() const { @@ -2473,7 +2806,7 @@ Enum::options() const { // optional .google.protobuf.SourceContext source_context = 4; bool Enum::has_source_context() const { - return !_is_default_instance_ && source_context_ != NULL; + return this != internal_default_instance() && source_context_ != NULL; } void Enum::clear_source_context() { if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; @@ -2481,12 +2814,13 @@ void Enum::clear_source_context() { } const ::google::protobuf::SourceContext& Enum::source_context() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.source_context) - return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_; + return source_context_ != NULL ? *source_context_ + : *::google::protobuf::SourceContext::internal_default_instance(); } ::google::protobuf::SourceContext* Enum::mutable_source_context() { if (source_context_ == NULL) { - source_context_ = new ::google::protobuf::SourceContext; + _slow_mutable_source_context(); } // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.source_context) return source_context_; @@ -2494,12 +2828,24 @@ const ::google::protobuf::SourceContext& Enum::source_context() const { ::google::protobuf::SourceContext* Enum::release_source_context() { // @@protoc_insertion_point(field_release:google.protobuf.Enum.source_context) - ::google::protobuf::SourceContext* temp = source_context_; - source_context_ = NULL; - return temp; + if (GetArenaNoVirtual() != NULL) { + return _slow_release_source_context(); + } else { + ::google::protobuf::SourceContext* temp = source_context_; + source_context_ = NULL; + return temp; + } } -void Enum::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { - delete source_context_; + void Enum::set_allocated_source_context(::google::protobuf::SourceContext* source_context) { + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete source_context_; + } + if (source_context != NULL) { + if (message_arena != NULL) { + message_arena->Own(source_context); + } + } source_context_ = source_context; if (source_context) { @@ -2513,11 +2859,11 @@ void Enum::set_allocated_source_context(::google::protobuf::SourceContext* sourc void Enum::clear_syntax() { syntax_ = 0; } - ::google::protobuf::Syntax Enum::syntax() const { +::google::protobuf::Syntax Enum::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.syntax) return static_cast< ::google::protobuf::Syntax >(syntax_); } - void Enum::set_syntax(::google::protobuf::Syntax value) { +void Enum::set_syntax(::google::protobuf::Syntax value) { syntax_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Enum.syntax) @@ -2535,28 +2881,37 @@ const int EnumValue::kOptionsFieldNumber; EnumValue::EnumValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValue) } +EnumValue::EnumValue(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + options_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValue) +} void EnumValue::InitAsDefaultInstance() { - _is_default_instance_ = true; } EnumValue::EnumValue(const EnumValue& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValue) } void EnumValue::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); number_ = 0; + _cached_size_ = 0; } EnumValue::~EnumValue() { @@ -2565,11 +2920,20 @@ EnumValue::~EnumValue() { } void EnumValue::SharedDtor() { - name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + + name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); } +void EnumValue::ArenaDtor(void* object) { + EnumValue* _this = reinterpret_cast< EnumValue* >(object); + (void)_this; +} +void EnumValue::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void EnumValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -2581,23 +2945,19 @@ const ::google::protobuf::Descriptor* EnumValue::descriptor() { } const EnumValue& EnumValue::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + return *internal_default_instance(); } -EnumValue* EnumValue::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed EnumValue::default_instance_; EnumValue* EnumValue::New(::google::protobuf::Arena* arena) const { - EnumValue* n = new EnumValue; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage(arena); } void EnumValue::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValue) - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); number_ = 0; options_.Clear(); } @@ -2632,10 +2992,10 @@ bool EnumValue::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_number: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &number_))); - } else { goto handle_unusual; } @@ -2739,9 +3099,9 @@ void EnumValue::SerializeWithCachedSizes( return target; } -int EnumValue::ByteSize() const { +size_t EnumValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValue) - int total_size = 0; + size_t total_size = 0; // optional string name = 1; if (this->name().size() > 0) { @@ -2758,25 +3118,27 @@ int EnumValue::ByteSize() const { } // repeated .google.protobuf.Option options = 3; - total_size += 1 * this->options_size(); - for (int i = 0; i < this->options_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(i)); + } } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void EnumValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const EnumValue* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const EnumValue* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -2784,19 +3146,24 @@ void EnumValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValue) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void EnumValue::MergeFrom(const EnumValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void EnumValue::UnsafeMergeFrom(const EnumValue& from) { + GOOGLE_DCHECK(&from != this); options_.MergeFrom(from.options_); if (from.name().size() > 0) { - - name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + set_name(from.name()); } if (from.number() != 0) { set_number(from.number()); @@ -2814,7 +3181,7 @@ void EnumValue::CopyFrom(const EnumValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValue) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool EnumValue::IsInitialized() const { @@ -2824,6 +3191,18 @@ bool EnumValue::IsInitialized() const { void EnumValue::Swap(EnumValue* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + EnumValue temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void EnumValue::UnsafeArenaSwap(EnumValue* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void EnumValue::InternalSwap(EnumValue* other) { @@ -2847,57 +3226,79 @@ void EnumValue::InternalSwap(EnumValue* other) { // optional string name = 1; void EnumValue::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - const ::std::string& EnumValue::name() const { +const ::std::string& EnumValue::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - void EnumValue::set_name(const ::std::string& value) { +void EnumValue::set_name(const ::std::string& value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name) } - void EnumValue::set_name(const char* value) { +void EnumValue::set_name(const char* value) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValue.name) } - void EnumValue::set_name(const char* value, size_t size) { +void EnumValue::set_name(const char* value, + size_t size) { - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValue.name) } - ::std::string* EnumValue::mutable_name() { +::std::string* EnumValue::mutable_name() { // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - ::std::string* EnumValue::release_name() { +::std::string* EnumValue::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name) - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } - void EnumValue::set_allocated_name(::std::string* name) { +::std::string* EnumValue::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumValue.name) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + + return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); +} +void EnumValue::set_allocated_name(::std::string* name) { if (name != NULL) { } else { } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name) } +void EnumValue::unsafe_arena_set_allocated_name( + ::std::string* name) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (name != NULL) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + name, GetArenaNoVirtual()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValue.name) +} // optional int32 number = 2; void EnumValue::clear_number() { number_ = 0; } - ::google::protobuf::int32 EnumValue::number() const { +::google::protobuf::int32 EnumValue::number() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.number) return number_; } - void EnumValue::set_number(::google::protobuf::int32 value) { +void EnumValue::set_number(::google::protobuf::int32 value) { number_ = value; // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.number) @@ -2937,6 +3338,39 @@ EnumValue::options() const { // =================================================================== +void Option::_slow_mutable_value() { + value_ = ::google::protobuf::Arena::Create< ::google::protobuf::Any >( + GetArenaNoVirtual()); +} +::google::protobuf::Any* Option::_slow_release_value() { + if (value_ == NULL) { + return NULL; + } else { + ::google::protobuf::Any* temp = new ::google::protobuf::Any(*value_); + value_ = NULL; + return temp; + } +} +::google::protobuf::Any* Option::unsafe_arena_release_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Option.value) + + ::google::protobuf::Any* temp = value_; + value_ = NULL; + return temp; +} +void Option::unsafe_arena_set_allocated_value( + ::google::protobuf::Any* value) { + if (GetArenaNoVirtual() == NULL) { + delete value_; + } + value_ = value; + if (value) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.value) +} #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Option::kNameFieldNumber; const int Option::kValueFieldNumber; @@ -2944,29 +3378,38 @@ const int Option::kValueFieldNumber; Option::Option() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Option) } +Option::Option(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Option) +} void Option::InitAsDefaultInstance() { - _is_default_instance_ = true; - value_ = const_cast< ::google::protobuf::Any*>(&::google::protobuf::Any::default_instance()); + value_ = const_cast< ::google::protobuf::Any*>( + ::google::protobuf::Any::internal_default_instance()); } Option::Option(const Option& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Option) } void Option::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); value_ = NULL; + _cached_size_ = 0; } Option::~Option() { @@ -2975,12 +3418,21 @@ Option::~Option() { } void Option::SharedDtor() { - name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != default_instance_) { - delete value_; + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + + name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); + delete value_; } +void Option::ArenaDtor(void* object) { + Option* _this = reinterpret_cast< Option* >(object); + (void)_this; +} +void Option::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Option::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -2992,23 +3444,19 @@ const ::google::protobuf::Descriptor* Option::descriptor() { } const Option& Option::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + return *internal_default_instance(); } -Option* Option::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed